babylon.d.ts 639 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982
  1. declare module BABYLON {
  2. class InstancingAttributeInfo {
  3. /**
  4. * Index/offset of the attribute in the vertex shader
  5. */
  6. index: number;
  7. /**
  8. * size of the attribute, 1, 2, 3 or 4
  9. */
  10. attributeSize: number;
  11. /**
  12. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  13. * default is FLOAT
  14. */
  15. attribyteType: number;
  16. /**
  17. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  18. */
  19. normalized: boolean;
  20. /**
  21. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  22. */
  23. offset: number;
  24. /**
  25. * Name of the GLSL attribute, for debugging purpose only
  26. */
  27. attributeName: string;
  28. }
  29. class EngineCapabilities {
  30. maxTexturesImageUnits: number;
  31. maxTextureSize: number;
  32. maxCubemapTextureSize: number;
  33. maxRenderTextureSize: number;
  34. standardDerivatives: boolean;
  35. s3tc: WEBGL_compressed_texture_s3tc;
  36. textureFloat: boolean;
  37. textureAnisotropicFilterExtension: EXT_texture_filter_anisotropic;
  38. maxAnisotropy: number;
  39. instancedArrays: ANGLE_instanced_arrays;
  40. uintIndices: boolean;
  41. highPrecisionShaderSupported: boolean;
  42. fragmentDepthSupported: boolean;
  43. textureFloatLinearFiltering: boolean;
  44. textureLOD: boolean;
  45. drawBuffersExtension: any;
  46. }
  47. /**
  48. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  49. */
  50. class Engine {
  51. private static _ALPHA_DISABLE;
  52. private static _ALPHA_ADD;
  53. private static _ALPHA_COMBINE;
  54. private static _ALPHA_SUBTRACT;
  55. private static _ALPHA_MULTIPLY;
  56. private static _ALPHA_MAXIMIZED;
  57. private static _ALPHA_ONEONE;
  58. private static _DELAYLOADSTATE_NONE;
  59. private static _DELAYLOADSTATE_LOADED;
  60. private static _DELAYLOADSTATE_LOADING;
  61. private static _DELAYLOADSTATE_NOTLOADED;
  62. private static _TEXTUREFORMAT_ALPHA;
  63. private static _TEXTUREFORMAT_LUMINANCE;
  64. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  65. private static _TEXTUREFORMAT_RGB;
  66. private static _TEXTUREFORMAT_RGBA;
  67. private static _TEXTURETYPE_UNSIGNED_INT;
  68. private static _TEXTURETYPE_FLOAT;
  69. static ALPHA_DISABLE: number;
  70. static ALPHA_ONEONE: number;
  71. static ALPHA_ADD: number;
  72. static ALPHA_COMBINE: number;
  73. static ALPHA_SUBTRACT: number;
  74. static ALPHA_MULTIPLY: number;
  75. static ALPHA_MAXIMIZED: number;
  76. static DELAYLOADSTATE_NONE: number;
  77. static DELAYLOADSTATE_LOADED: number;
  78. static DELAYLOADSTATE_LOADING: number;
  79. static DELAYLOADSTATE_NOTLOADED: number;
  80. static TEXTUREFORMAT_ALPHA: number;
  81. static TEXTUREFORMAT_LUMINANCE: number;
  82. static TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83. static TEXTUREFORMAT_RGB: number;
  84. static TEXTUREFORMAT_RGBA: number;
  85. static TEXTURETYPE_UNSIGNED_INT: number;
  86. static TEXTURETYPE_FLOAT: number;
  87. static Version: string;
  88. static CollisionsEpsilon: number;
  89. static CodeRepository: string;
  90. static ShadersRepository: string;
  91. isFullscreen: boolean;
  92. isPointerLock: boolean;
  93. cullBackFaces: boolean;
  94. renderEvenInBackground: boolean;
  95. enableOfflineSupport: boolean;
  96. scenes: Scene[];
  97. _gl: WebGLRenderingContext;
  98. private _renderingCanvas;
  99. private _windowIsBackground;
  100. private _webGLVersion;
  101. static audioEngine: AudioEngine;
  102. private _onBlur;
  103. private _onFocus;
  104. private _onFullscreenChange;
  105. private _onPointerLockChange;
  106. private _hardwareScalingLevel;
  107. private _caps;
  108. private _pointerLockRequested;
  109. private _alphaTest;
  110. private _loadingScreen;
  111. _drawCalls: PerfCounter;
  112. private _glVersion;
  113. private _glRenderer;
  114. private _glVendor;
  115. private _videoTextureSupported;
  116. private _renderingQueueLaunched;
  117. private _activeRenderLoops;
  118. private fpsRange;
  119. private previousFramesDuration;
  120. private fps;
  121. private deltaTime;
  122. private _depthCullingState;
  123. private _alphaState;
  124. private _alphaMode;
  125. private _loadedTexturesCache;
  126. private _maxTextureChannels;
  127. private _activeTexture;
  128. private _activeTexturesCache;
  129. private _currentEffect;
  130. private _currentProgram;
  131. private _compiledEffects;
  132. private _vertexAttribArraysEnabled;
  133. private _vertexAttribArraysToUse;
  134. private _cachedViewport;
  135. private _cachedVertexBuffers;
  136. private _cachedIndexBuffer;
  137. private _cachedEffectForVertexBuffers;
  138. private _currentRenderTarget;
  139. private _uintIndicesCurrentlySet;
  140. private _currentBoundBuffer;
  141. private _currentFramebuffer;
  142. private _currentBufferPointers;
  143. private _currentInstanceLocations;
  144. private _currentInstanceBuffers;
  145. private _textureUnits;
  146. private _workingCanvas;
  147. private _workingContext;
  148. private _externalData;
  149. private _bindedRenderFunction;
  150. /**
  151. * @constructor
  152. * @param {HTMLCanvasElement} canvas - the canvas to be used for rendering
  153. * @param {boolean} [antialias] - enable antialias
  154. * @param options - further options to be sent to the getContext function
  155. */
  156. constructor(canvas: HTMLCanvasElement, antialias?: boolean, options?: {
  157. antialias?: boolean;
  158. preserveDrawingBuffer?: boolean;
  159. limitDeviceRatio?: number;
  160. }, adaptToDeviceRatio?: boolean);
  161. webGLVersion: string;
  162. private _prepareWorkingCanvas();
  163. resetTextureCache(): void;
  164. getGlInfo(): {
  165. vendor: string;
  166. renderer: string;
  167. version: string;
  168. };
  169. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  170. getRenderWidth(useScreen?: boolean): number;
  171. getRenderHeight(useScreen?: boolean): number;
  172. getRenderingCanvas(): HTMLCanvasElement;
  173. getRenderingCanvasClientRect(): ClientRect;
  174. setHardwareScalingLevel(level: number): void;
  175. getHardwareScalingLevel(): number;
  176. getLoadedTexturesCache(): WebGLTexture[];
  177. getCaps(): EngineCapabilities;
  178. drawCalls: number;
  179. drawCallsPerfCounter: PerfCounter;
  180. getDepthFunction(): number;
  181. setDepthFunction(depthFunc: number): void;
  182. setDepthFunctionToGreater(): void;
  183. setDepthFunctionToGreaterOrEqual(): void;
  184. setDepthFunctionToLess(): void;
  185. setDepthFunctionToLessOrEqual(): void;
  186. /**
  187. * stop executing a render loop function and remove it from the execution array
  188. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  189. */
  190. stopRenderLoop(renderFunction?: () => void): void;
  191. _renderLoop(): void;
  192. /**
  193. * Register and execute a render loop. The engine can have more than one render function.
  194. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  195. * @example
  196. * engine.runRenderLoop(function () {
  197. * scene.render()
  198. * })
  199. */
  200. runRenderLoop(renderFunction: () => void): void;
  201. /**
  202. * Toggle full screen mode.
  203. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  204. * @param {any} options - an options object to be sent to the requestFullscreen function
  205. */
  206. switchFullscreen(requestPointerLock: boolean, options?: any): void;
  207. clear(color: any, backBuffer: boolean, depthStencil: boolean): void;
  208. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  209. /**
  210. * Set the WebGL's viewport
  211. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  212. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  213. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  214. */
  215. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  216. /**
  217. * Directly set the WebGL Viewport
  218. * The x, y, width & height are directly passed to the WebGL call
  219. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state.
  220. */
  221. setDirectViewport(x: number, y: number, width: number, height: number): Viewport;
  222. beginFrame(): void;
  223. endFrame(): void;
  224. /**
  225. * resize the view according to the canvas' size.
  226. * @example
  227. * window.addEventListener("resize", function () {
  228. * engine.resize();
  229. * });
  230. */
  231. resize(): void;
  232. /**
  233. * force a specific size of the canvas
  234. * @param {number} width - the new canvas' width
  235. * @param {number} height - the new canvas' height
  236. */
  237. setSize(width: number, height: number): void;
  238. bindFramebuffer(texture: WebGLTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number): void;
  239. private bindUnboundFramebuffer(framebuffer);
  240. unBindFramebuffer(texture: WebGLTexture, disableGenerateMipMaps?: boolean): void;
  241. generateMipMapsForCubemap(texture: WebGLTexture): void;
  242. flushFramebuffer(): void;
  243. restoreDefaultFramebuffer(): void;
  244. private _resetVertexBufferBinding();
  245. createVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer;
  246. createDynamicVertexBuffer(vertices: number[] | Float32Array): WebGLBuffer;
  247. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: number[] | Float32Array, offset?: number, count?: number): void;
  248. private _resetIndexBufferBinding();
  249. createIndexBuffer(indices: number[] | Int32Array): WebGLBuffer;
  250. bindArrayBuffer(buffer: WebGLBuffer): void;
  251. private bindIndexBuffer(buffer);
  252. private bindBuffer(buffer, target);
  253. updateArrayBuffer(data: Float32Array): void;
  254. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  255. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  256. bindBuffers(vertexBuffers: {
  257. [key: string]: VertexBuffer;
  258. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  259. unbindInstanceAttributes(): void;
  260. _releaseBuffer(buffer: WebGLBuffer): boolean;
  261. createInstancesBuffer(capacity: number): WebGLBuffer;
  262. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  263. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  264. applyStates(): void;
  265. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  266. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  267. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  268. _releaseEffect(effect: Effect): void;
  269. createEffect(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  270. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  271. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string): WebGLProgram;
  272. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  273. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  274. enableEffect(effect: Effect): void;
  275. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  276. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  277. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  278. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  279. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  280. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  281. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  282. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  283. setFloat(uniform: WebGLUniformLocation, value: number): void;
  284. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  285. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  286. setBool(uniform: WebGLUniformLocation, bool: number): void;
  287. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  288. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  289. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  290. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  291. setDepthBuffer(enable: boolean): void;
  292. getDepthWrite(): boolean;
  293. setDepthWrite(enable: boolean): void;
  294. setColorWrite(enable: boolean): void;
  295. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  296. getAlphaMode(): number;
  297. setAlphaTesting(enable: boolean): void;
  298. getAlphaTesting(): boolean;
  299. wipeCaches(): void;
  300. setSamplingMode(texture: WebGLTexture, samplingMode: number): void;
  301. createTexture(url: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any): WebGLTexture;
  302. private _getInternalFormat(format);
  303. updateRawTexture(texture: WebGLTexture, data: ArrayBufferView, format: number, invertY: boolean, compression?: string): void;
  304. createRawTexture(data: ArrayBufferView, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: string): WebGLTexture;
  305. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): WebGLTexture;
  306. updateTextureSamplingMode(samplingMode: number, texture: WebGLTexture): void;
  307. updateDynamicTexture(texture: WebGLTexture, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean): void;
  308. updateVideoTexture(texture: WebGLTexture, video: HTMLVideoElement, invertY: boolean): void;
  309. createRenderTargetTexture(size: any, options: any): WebGLTexture;
  310. createRenderTargetCubeTexture(size: number, options?: any): WebGLTexture;
  311. createCubeTexture(rootUrl: string, scene: Scene, files: string[], noMipmap?: boolean): WebGLTexture;
  312. updateTextureSize(texture: WebGLTexture, width: number, height: number): void;
  313. createRawCubeTexture(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer) => ArrayBufferView[], mipmmapGenerator: ((faces: ArrayBufferView[]) => ArrayBufferView[][])): WebGLTexture;
  314. _releaseTexture(texture: WebGLTexture): void;
  315. private setProgram(program);
  316. bindSamplers(effect: Effect): void;
  317. private activateTexture(texture);
  318. _bindTextureDirectly(target: number, texture: WebGLTexture): void;
  319. _bindTexture(channel: number, texture: WebGLTexture): void;
  320. setTextureFromPostProcess(channel: number, postProcess: PostProcess): void;
  321. unbindAllTextures(): void;
  322. setTexture(channel: number, uniform: WebGLUniformLocation, texture: BaseTexture): void;
  323. private _setTexture(channel, texture);
  324. setTextureArray(channel: number, uniform: WebGLUniformLocation, textures: BaseTexture[]): void;
  325. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  326. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  327. /**
  328. * Add an externaly attached data from its key.
  329. * This method call will fail and return false, if such key already exists.
  330. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  331. * @param key the unique key that identifies the data
  332. * @param data the data object to associate to the key for this Engine instance
  333. * @return true if no such key were already present and the data was added successfully, false otherwise
  334. */
  335. addExternalData<T>(key: string, data: T): boolean;
  336. /**
  337. * Get an externaly attached data from its key
  338. * @param key the unique key that identifies the data
  339. * @return the associated data, if present (can be null), or undefined if not present
  340. */
  341. getExternalData<T>(key: string): T;
  342. /**
  343. * Get an externaly attached data from its key, create it using a factory if it's not already present
  344. * @param key the unique key that identifies the data
  345. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  346. * @return the associated data, can be null if the factory returned null.
  347. */
  348. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  349. /**
  350. * Remove an externaly attached data from the Engine instance
  351. * @param key the unique key that identifies the data
  352. * @return true if the data was successfully removed, false if it doesn't exist
  353. */
  354. removeExternalData(key: any): boolean;
  355. releaseInternalTexture(texture: WebGLTexture): void;
  356. dispose(): void;
  357. displayLoadingUI(): void;
  358. hideLoadingUI(): void;
  359. loadingScreen: ILoadingScreen;
  360. loadingUIText: string;
  361. loadingUIBackgroundColor: string;
  362. getFps(): number;
  363. getDeltaTime(): number;
  364. private _measureFps();
  365. static isSupported(): boolean;
  366. }
  367. }
  368. interface Window {
  369. mozIndexedDB(func: any): any;
  370. webkitIndexedDB(func: any): any;
  371. IDBTransaction(func: any): any;
  372. webkitIDBTransaction(func: any): any;
  373. msIDBTransaction(func: any): any;
  374. IDBKeyRange(func: any): any;
  375. webkitIDBKeyRange(func: any): any;
  376. msIDBKeyRange(func: any): any;
  377. webkitURL: HTMLURL;
  378. webkitRequestAnimationFrame(func: any): any;
  379. mozRequestAnimationFrame(func: any): any;
  380. oRequestAnimationFrame(func: any): any;
  381. WebGLRenderingContext: WebGLRenderingContext;
  382. MSGesture: MSGesture;
  383. CANNON: any;
  384. SIMD: any;
  385. AudioContext: AudioContext;
  386. webkitAudioContext: AudioContext;
  387. PointerEvent: any;
  388. }
  389. interface HTMLURL {
  390. createObjectURL(param1: any, param2?: any): any;
  391. }
  392. interface Document {
  393. exitFullscreen(): void;
  394. webkitCancelFullScreen(): void;
  395. mozCancelFullScreen(): void;
  396. msCancelFullScreen(): void;
  397. mozFullScreen: boolean;
  398. msIsFullScreen: boolean;
  399. fullscreen: boolean;
  400. mozPointerLockElement: HTMLElement;
  401. msPointerLockElement: HTMLElement;
  402. webkitPointerLockElement: HTMLElement;
  403. }
  404. interface HTMLCanvasElement {
  405. requestPointerLock(): void;
  406. msRequestPointerLock(): void;
  407. mozRequestPointerLock(): void;
  408. webkitRequestPointerLock(): void;
  409. }
  410. interface CanvasRenderingContext2D {
  411. imageSmoothingEnabled: boolean;
  412. mozImageSmoothingEnabled: boolean;
  413. oImageSmoothingEnabled: boolean;
  414. webkitImageSmoothingEnabled: boolean;
  415. }
  416. interface WebGLTexture {
  417. isReady: boolean;
  418. isCube: boolean;
  419. url: string;
  420. noMipmap: boolean;
  421. samplingMode: number;
  422. references: number;
  423. generateMipMaps: boolean;
  424. _size: number;
  425. _baseWidth: number;
  426. _baseHeight: number;
  427. _width: number;
  428. _height: number;
  429. _workingCanvas: HTMLCanvasElement;
  430. _workingContext: CanvasRenderingContext2D;
  431. _framebuffer: WebGLFramebuffer;
  432. _depthBuffer: WebGLRenderbuffer;
  433. _cachedCoordinatesMode: number;
  434. _cachedWrapU: number;
  435. _cachedWrapV: number;
  436. _isDisabled: boolean;
  437. }
  438. interface WebGLBuffer {
  439. references: number;
  440. capacity: number;
  441. is32Bits: boolean;
  442. }
  443. interface MouseEvent {
  444. mozMovementX: number;
  445. mozMovementY: number;
  446. webkitMovementX: number;
  447. webkitMovementY: number;
  448. msMovementX: number;
  449. msMovementY: number;
  450. }
  451. interface MSStyleCSSProperties {
  452. webkitTransform: string;
  453. webkitTransition: string;
  454. }
  455. interface Navigator {
  456. getVRDevices: () => any;
  457. mozGetVRDevices: (any: any) => any;
  458. isCocoonJS: boolean;
  459. }
  460. interface Screen {
  461. orientation: string;
  462. mozOrientation: string;
  463. }
  464. interface HTMLMediaElement {
  465. crossOrigin: string;
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Node is the basic class for all scene objects (Mesh, Light Camera).
  470. */
  471. class Node {
  472. name: string;
  473. id: string;
  474. uniqueId: number;
  475. state: string;
  476. animations: Animation[];
  477. private _ranges;
  478. onReady: (node: Node) => void;
  479. private _childrenFlag;
  480. private _isEnabled;
  481. private _isReady;
  482. _currentRenderId: number;
  483. private _parentRenderId;
  484. _waitingParentId: string;
  485. private _scene;
  486. _cache: any;
  487. private _parentNode;
  488. private _children;
  489. parent: Node;
  490. /**
  491. * @constructor
  492. * @param {string} name - the name and id to be given to this node
  493. * @param {BABYLON.Scene} the scene this node will be added to
  494. */
  495. constructor(name: string, scene: Scene);
  496. getScene(): Scene;
  497. getEngine(): Engine;
  498. getWorldMatrix(): Matrix;
  499. _initCache(): void;
  500. updateCache(force?: boolean): void;
  501. _updateCache(ignoreParentClass?: boolean): void;
  502. _isSynchronized(): boolean;
  503. _markSyncedWithParent(): void;
  504. isSynchronizedWithParent(): boolean;
  505. isSynchronized(updateCache?: boolean): boolean;
  506. hasNewParent(update?: boolean): boolean;
  507. /**
  508. * Is this node ready to be used/rendered
  509. * @return {boolean} is it ready
  510. */
  511. isReady(): boolean;
  512. /**
  513. * Is this node enabled.
  514. * If the node has a parent and is enabled, the parent will be inspected as well.
  515. * @return {boolean} whether this node (and its parent) is enabled.
  516. * @see setEnabled
  517. */
  518. isEnabled(): boolean;
  519. /**
  520. * Set the enabled state of this node.
  521. * @param {boolean} value - the new enabled state
  522. * @see isEnabled
  523. */
  524. setEnabled(value: boolean): void;
  525. /**
  526. * Is this node a descendant of the given node.
  527. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined.
  528. * @param {BABYLON.Node} ancestor - The parent node to inspect
  529. * @see parent
  530. */
  531. isDescendantOf(ancestor: Node): boolean;
  532. /**
  533. * Evaluate the list of children and determine if they should be considered as descendants considering the given criterias
  534. * @param {BABYLON.Node[]} results the result array containing the nodes matching the given criterias
  535. * @param {boolean} directDescendantsOnly if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered.
  536. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  537. */
  538. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  539. /**
  540. * Will return all nodes that have this node as ascendant.
  541. * @param {boolean} directDescendantsOnly if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered.
  542. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  543. * @return {BABYLON.Node[]} all children nodes of all types.
  544. */
  545. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  546. /**
  547. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  548. * @Deprecated, legacy support.
  549. * use getDecendants instead.
  550. */
  551. getChildren(predicate?: (node: Node) => boolean): Node[];
  552. /**
  553. * Get all child-meshes of this node.
  554. */
  555. getChildMeshes(directDecendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  556. _setReady(state: boolean): void;
  557. getAnimationByName(name: string): Animation;
  558. createAnimationRange(name: string, from: number, to: number): void;
  559. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  560. getAnimationRange(name: string): AnimationRange;
  561. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): void;
  562. serializeAnimationRanges(): any;
  563. dispose(): void;
  564. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  565. }
  566. }
  567. declare module BABYLON {
  568. interface IDisposable {
  569. dispose(): void;
  570. }
  571. class PointerEventTypes {
  572. static _POINTERDOWN: number;
  573. static _POINTERUP: number;
  574. static _POINTERMOVE: number;
  575. static _POINTERWHEEL: number;
  576. static _POINTERPICK: number;
  577. static POINTERDOWN: number;
  578. static POINTERUP: number;
  579. static POINTERMOVE: number;
  580. static POINTERWHEEL: number;
  581. static POINTERPICK: number;
  582. }
  583. class PointerInfoBase {
  584. type: number;
  585. event: PointerEvent | MouseWheelEvent;
  586. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  587. }
  588. /**
  589. * This class is used to store pointer related info for the onPrePointerObservable event.
  590. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  591. */
  592. class PointerInfoPre extends PointerInfoBase {
  593. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: any, localY: any);
  594. localPosition: Vector2;
  595. skipOnPointerObservable: boolean;
  596. }
  597. /**
  598. * This type contains all the data related to a pointer event in Babylon.js.
  599. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  600. */
  601. class PointerInfo extends PointerInfoBase {
  602. pickInfo: PickingInfo;
  603. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: PickingInfo);
  604. }
  605. /**
  606. * Represents a scene to be rendered by the engine.
  607. * @see http://doc.babylonjs.com/page.php?p=21911
  608. */
  609. class Scene implements IAnimatable {
  610. private static _FOGMODE_NONE;
  611. private static _FOGMODE_EXP;
  612. private static _FOGMODE_EXP2;
  613. private static _FOGMODE_LINEAR;
  614. static MinDeltaTime: number;
  615. static MaxDeltaTime: number;
  616. static FOGMODE_NONE: number;
  617. static FOGMODE_EXP: number;
  618. static FOGMODE_EXP2: number;
  619. static FOGMODE_LINEAR: number;
  620. autoClear: boolean;
  621. clearColor: any;
  622. ambientColor: Color3;
  623. forceWireframe: boolean;
  624. forcePointsCloud: boolean;
  625. forceShowBoundingBoxes: boolean;
  626. clipPlane: Plane;
  627. animationsEnabled: boolean;
  628. constantlyUpdateMeshUnderPointer: boolean;
  629. hoverCursor: string;
  630. /**
  631. * An event triggered when the scene is disposed.
  632. * @type {BABYLON.Observable}
  633. */
  634. onDisposeObservable: Observable<Scene>;
  635. private _onDisposeObserver;
  636. onDispose: () => void;
  637. /**
  638. * An event triggered before rendering the scene
  639. * @type {BABYLON.Observable}
  640. */
  641. onBeforeRenderObservable: Observable<Scene>;
  642. private _onBeforeRenderObserver;
  643. beforeRender: () => void;
  644. /**
  645. * An event triggered after rendering the scene
  646. * @type {BABYLON.Observable}
  647. */
  648. onAfterRenderObservable: Observable<Scene>;
  649. private _onAfterRenderObserver;
  650. afterRender: () => void;
  651. /**
  652. * An event triggered when the scene is ready
  653. * @type {BABYLON.Observable}
  654. */
  655. onReadyObservable: Observable<Scene>;
  656. /**
  657. * An event triggered before rendering a camera
  658. * @type {BABYLON.Observable}
  659. */
  660. onBeforeCameraRenderObservable: Observable<Camera>;
  661. private _onBeforeCameraRenderObserver;
  662. beforeCameraRender: () => void;
  663. /**
  664. * An event triggered after rendering a camera
  665. * @type {BABYLON.Observable}
  666. */
  667. onAfterCameraRenderObservable: Observable<Camera>;
  668. private _onAfterCameraRenderObserver;
  669. afterCameraRender: () => void;
  670. /**
  671. * An event triggered when a camera is created
  672. * @type {BABYLON.Observable}
  673. */
  674. onNewCameraAddedObservable: Observable<Camera>;
  675. /**
  676. * An event triggered when a camera is removed
  677. * @type {BABYLON.Observable}
  678. */
  679. onCameraRemovedObservable: Observable<Camera>;
  680. /**
  681. * An event triggered when a light is created
  682. * @type {BABYLON.Observable}
  683. */
  684. onNewLightAddedObservable: Observable<Light>;
  685. /**
  686. * An event triggered when a light is removed
  687. * @type {BABYLON.Observable}
  688. */
  689. onLightRemovedObservable: Observable<Light>;
  690. /**
  691. * An event triggered when a geometry is created
  692. * @type {BABYLON.Observable}
  693. */
  694. onNewGeometryAddedObservable: Observable<Geometry>;
  695. /**
  696. * An event triggered when a geometry is removed
  697. * @type {BABYLON.Observable}
  698. */
  699. onGeometryRemovedObservable: Observable<Geometry>;
  700. /**
  701. * An event triggered when a mesh is created
  702. * @type {BABYLON.Observable}
  703. */
  704. onNewMeshAddedObservable: Observable<AbstractMesh>;
  705. /**
  706. * An event triggered when a mesh is removed
  707. * @type {BABYLON.Observable}
  708. */
  709. onMeshRemovedObservable: Observable<AbstractMesh>;
  710. animations: Animation[];
  711. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  712. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  713. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  714. private _onPointerMove;
  715. private _onPointerDown;
  716. private _onPointerUp;
  717. /**
  718. * @deprecated Use onPointerObservable instead
  719. */
  720. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  721. /**
  722. * @deprecated Use onPointerObservable instead
  723. */
  724. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  725. /**
  726. * @deprecated Use onPointerObservable instead
  727. */
  728. onPointerUp: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  729. /**
  730. * @deprecated Use onPointerObservable instead
  731. */
  732. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  733. /**
  734. * This observable event is triggered when any mouse event registered during Scene.attach() is called BEFORE the 3D engine to process anything (mesh/sprite picking for instance).
  735. * You have the possibility to skip the 3D Engine process and the call to onPointerObservable by setting PointerInfoBase.skipOnPointerObservable to true
  736. */
  737. onPrePointerObservable: Observable<PointerInfoPre>;
  738. /**
  739. * Observable event triggered each time an input event is received from the rendering canvas
  740. */
  741. onPointerObservable: Observable<PointerInfo>;
  742. unTranslatedPointer: Vector2;
  743. cameraToUseForPointers: Camera;
  744. private _pointerX;
  745. private _pointerY;
  746. private _unTranslatedPointerX;
  747. private _unTranslatedPointerY;
  748. private _startingPointerPosition;
  749. private _startingPointerTime;
  750. _mirroredCameraPosition: Vector3;
  751. private _onKeyDown;
  752. private _onKeyUp;
  753. /**
  754. * is fog enabled on this scene.
  755. * @type {boolean}
  756. */
  757. fogEnabled: boolean;
  758. fogMode: number;
  759. fogColor: Color3;
  760. fogDensity: number;
  761. fogStart: number;
  762. fogEnd: number;
  763. /**
  764. * is shadow enabled on this scene.
  765. * @type {boolean}
  766. */
  767. shadowsEnabled: boolean;
  768. /**
  769. * is light enabled on this scene.
  770. * @type {boolean}
  771. */
  772. lightsEnabled: boolean;
  773. /**
  774. * All of the lights added to this scene.
  775. * @see BABYLON.Light
  776. * @type {BABYLON.Light[]}
  777. */
  778. lights: Light[];
  779. /**
  780. * All of the cameras added to this scene.
  781. * @see BABYLON.Camera
  782. * @type {BABYLON.Camera[]}
  783. */
  784. cameras: Camera[];
  785. activeCameras: Camera[];
  786. activeCamera: Camera;
  787. /**
  788. * All of the (abstract) meshes added to this scene.
  789. * @see BABYLON.AbstractMesh
  790. * @type {BABYLON.AbstractMesh[]}
  791. */
  792. meshes: AbstractMesh[];
  793. private _geometries;
  794. materials: Material[];
  795. multiMaterials: MultiMaterial[];
  796. defaultMaterial: StandardMaterial;
  797. texturesEnabled: boolean;
  798. textures: BaseTexture[];
  799. particlesEnabled: boolean;
  800. particleSystems: ParticleSystem[];
  801. spritesEnabled: boolean;
  802. spriteManagers: SpriteManager[];
  803. layers: Layer[];
  804. skeletonsEnabled: boolean;
  805. skeletons: Skeleton[];
  806. lensFlaresEnabled: boolean;
  807. lensFlareSystems: LensFlareSystem[];
  808. collisionsEnabled: boolean;
  809. private _workerCollisions;
  810. collisionCoordinator: ICollisionCoordinator;
  811. gravity: Vector3;
  812. postProcessesEnabled: boolean;
  813. postProcessManager: PostProcessManager;
  814. postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  815. renderTargetsEnabled: boolean;
  816. dumpNextRenderTargets: boolean;
  817. customRenderTargets: RenderTargetTexture[];
  818. useDelayedTextureLoading: boolean;
  819. importedMeshesFiles: String[];
  820. probesEnabled: boolean;
  821. reflectionProbes: ReflectionProbe[];
  822. database: any;
  823. /**
  824. * This scene's action manager
  825. * @type {BABYLON.ActionManager}
  826. */
  827. actionManager: ActionManager;
  828. _actionManagers: ActionManager[];
  829. private _meshesForIntersections;
  830. proceduralTexturesEnabled: boolean;
  831. _proceduralTextures: ProceduralTexture[];
  832. mainSoundTrack: SoundTrack;
  833. soundTracks: SoundTrack[];
  834. private _audioEnabled;
  835. private _headphone;
  836. simplificationQueue: SimplificationQueue;
  837. private _engine;
  838. private _totalMeshesCounter;
  839. private _totalLightsCounter;
  840. private _totalMaterialsCounter;
  841. private _totalTexturesCounter;
  842. private _totalVertices;
  843. _activeIndices: PerfCounter;
  844. _activeParticles: PerfCounter;
  845. private _lastFrameDuration;
  846. private _evaluateActiveMeshesDuration;
  847. private _renderTargetsDuration;
  848. _particlesDuration: PerfCounter;
  849. private _renderDuration;
  850. _spritesDuration: PerfCounter;
  851. _activeBones: PerfCounter;
  852. private _animationRatio;
  853. private _animationStartDate;
  854. _cachedMaterial: Material;
  855. private _renderId;
  856. private _executeWhenReadyTimeoutId;
  857. private _intermediateRendering;
  858. _toBeDisposed: SmartArray<IDisposable>;
  859. private _pendingData;
  860. private _activeMeshes;
  861. private _processedMaterials;
  862. private _renderTargets;
  863. _activeParticleSystems: SmartArray<ParticleSystem>;
  864. private _activeSkeletons;
  865. private _softwareSkinnedMeshes;
  866. private _renderingManager;
  867. private _physicsEngine;
  868. _activeAnimatables: Animatable[];
  869. private _transformMatrix;
  870. private _pickWithRayInverseMatrix;
  871. private _edgesRenderers;
  872. private _boundingBoxRenderer;
  873. private _outlineRenderer;
  874. private _viewMatrix;
  875. private _projectionMatrix;
  876. private _frustumPlanes;
  877. private _selectionOctree;
  878. private _pointerOverMesh;
  879. private _pointerOverSprite;
  880. private _debugLayer;
  881. private _depthRenderer;
  882. private _uniqueIdCounter;
  883. private _pickedDownMesh;
  884. private _pickedDownSprite;
  885. /**
  886. * @constructor
  887. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  888. */
  889. constructor(engine: Engine);
  890. debugLayer: DebugLayer;
  891. workerCollisions: boolean;
  892. SelectionOctree: Octree<AbstractMesh>;
  893. /**
  894. * The mesh that is currently under the pointer.
  895. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  896. */
  897. meshUnderPointer: AbstractMesh;
  898. /**
  899. * Current on-screen X position of the pointer
  900. * @return {number} X position of the pointer
  901. */
  902. pointerX: number;
  903. /**
  904. * Current on-screen Y position of the pointer
  905. * @return {number} Y position of the pointer
  906. */
  907. pointerY: number;
  908. getCachedMaterial(): Material;
  909. getBoundingBoxRenderer(): BoundingBoxRenderer;
  910. getOutlineRenderer(): OutlineRenderer;
  911. getEngine(): Engine;
  912. getTotalVertices(): number;
  913. totalVerticesPerfCounter: PerfCounter;
  914. getActiveIndices(): number;
  915. totalActiveIndicesPerfCounter: PerfCounter;
  916. getActiveParticles(): number;
  917. activeParticlesPerfCounter: PerfCounter;
  918. getActiveBones(): number;
  919. activeBonesPerfCounter: PerfCounter;
  920. getLastFrameDuration(): number;
  921. lastFramePerfCounter: PerfCounter;
  922. getEvaluateActiveMeshesDuration(): number;
  923. evaluateActiveMeshesDurationPerfCounter: PerfCounter;
  924. getActiveMeshes(): SmartArray<Mesh>;
  925. getRenderTargetsDuration(): number;
  926. getRenderDuration(): number;
  927. renderDurationPerfCounter: PerfCounter;
  928. getParticlesDuration(): number;
  929. particlesDurationPerfCounter: PerfCounter;
  930. getSpritesDuration(): number;
  931. spriteDuractionPerfCounter: PerfCounter;
  932. getAnimationRatio(): number;
  933. getRenderId(): number;
  934. incrementRenderId(): void;
  935. private _updatePointerPosition(evt);
  936. /**
  937. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  938. * @param attachUp defines if you want to attach events to pointerup
  939. * @param attachDown defines if you want to attach events to pointerdown
  940. * @param attachMove defines if you want to attach events to pointermove
  941. */
  942. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  943. detachControl(): void;
  944. isReady(): boolean;
  945. resetCachedMaterial(): void;
  946. registerBeforeRender(func: () => void): void;
  947. unregisterBeforeRender(func: () => void): void;
  948. registerAfterRender(func: () => void): void;
  949. unregisterAfterRender(func: () => void): void;
  950. _addPendingData(data: any): void;
  951. _removePendingData(data: any): void;
  952. getWaitingItemsCount(): number;
  953. /**
  954. * Registers a function to be executed when the scene is ready.
  955. * @param {Function} func - the function to be executed.
  956. */
  957. executeWhenReady(func: () => void): void;
  958. _checkIsReady(): void;
  959. /**
  960. * Will start the animation sequence of a given target
  961. * @param target - the target
  962. * @param {number} from - from which frame should animation start
  963. * @param {number} to - till which frame should animation run.
  964. * @param {boolean} [loop] - should the animation loop
  965. * @param {number} [speedRatio] - the speed in which to run the animation
  966. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  967. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  968. * @return {BABYLON.Animatable} the animatable object created for this animation
  969. * @see BABYLON.Animatable
  970. * @see http://doc.babylonjs.com/page.php?p=22081
  971. */
  972. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  973. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  974. getAnimatableByTarget(target: any): Animatable;
  975. Animatables: Animatable[];
  976. /**
  977. * Will stop the animation of the given target
  978. * @param target - the target
  979. * @see beginAnimation
  980. */
  981. stopAnimation(target: any): void;
  982. private _animate();
  983. getViewMatrix(): Matrix;
  984. getProjectionMatrix(): Matrix;
  985. getTransformMatrix(): Matrix;
  986. setTransformMatrix(view: Matrix, projection: Matrix): void;
  987. addMesh(newMesh: AbstractMesh): void;
  988. removeMesh(toRemove: AbstractMesh): number;
  989. removeSkeleton(toRemove: Skeleton): number;
  990. removeLight(toRemove: Light): number;
  991. removeCamera(toRemove: Camera): number;
  992. addLight(newLight: Light): void;
  993. addCamera(newCamera: Camera): void;
  994. /**
  995. * Switch active camera
  996. * @param {Camera} newCamera - new active camera
  997. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  998. */
  999. swithActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1000. /**
  1001. * sets the active camera of the scene using its ID
  1002. * @param {string} id - the camera's ID
  1003. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1004. * @see activeCamera
  1005. */
  1006. setActiveCameraByID(id: string): Camera;
  1007. /**
  1008. * sets the active camera of the scene using its name
  1009. * @param {string} name - the camera's name
  1010. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1011. * @see activeCamera
  1012. */
  1013. setActiveCameraByName(name: string): Camera;
  1014. /**
  1015. * get a material using its id
  1016. * @param {string} the material's ID
  1017. * @return {BABYLON.Material|null} the material or null if none found.
  1018. */
  1019. getMaterialByID(id: string): Material;
  1020. /**
  1021. * get a material using its name
  1022. * @param {string} the material's name
  1023. * @return {BABYLON.Material|null} the material or null if none found.
  1024. */
  1025. getMaterialByName(name: string): Material;
  1026. getLensFlareSystemByName(name: string): LensFlareSystem;
  1027. getLensFlareSystemByID(id: string): LensFlareSystem;
  1028. getCameraByID(id: string): Camera;
  1029. getCameraByUniqueID(uniqueId: number): Camera;
  1030. /**
  1031. * get a camera using its name
  1032. * @param {string} the camera's name
  1033. * @return {BABYLON.Camera|null} the camera or null if none found.
  1034. */
  1035. getCameraByName(name: string): Camera;
  1036. /**
  1037. * get a bone using its id
  1038. * @param {string} the bone's id
  1039. * @return {BABYLON.Bone|null} the bone or null if not found
  1040. */
  1041. getBoneByID(id: string): Bone;
  1042. /**
  1043. * get a bone using its id
  1044. * @param {string} the bone's name
  1045. * @return {BABYLON.Bone|null} the bone or null if not found
  1046. */
  1047. getBoneByName(name: string): Bone;
  1048. /**
  1049. * get a light node using its name
  1050. * @param {string} the light's name
  1051. * @return {BABYLON.Light|null} the light or null if none found.
  1052. */
  1053. getLightByName(name: string): Light;
  1054. /**
  1055. * get a light node using its ID
  1056. * @param {string} the light's id
  1057. * @return {BABYLON.Light|null} the light or null if none found.
  1058. */
  1059. getLightByID(id: string): Light;
  1060. /**
  1061. * get a light node using its scene-generated unique ID
  1062. * @param {number} the light's unique id
  1063. * @return {BABYLON.Light|null} the light or null if none found.
  1064. */
  1065. getLightByUniqueID(uniqueId: number): Light;
  1066. /**
  1067. * get a particle system by id
  1068. * @param id {number} the particle system id
  1069. * @return {BABYLON.ParticleSystem|null} the corresponding system or null if none found.
  1070. */
  1071. getParticleSystemByID(id: string): ParticleSystem;
  1072. /**
  1073. * get a geometry using its ID
  1074. * @param {string} the geometry's id
  1075. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1076. */
  1077. getGeometryByID(id: string): Geometry;
  1078. /**
  1079. * add a new geometry to this scene.
  1080. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1081. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1082. * @return {boolean} was the geometry added or not
  1083. */
  1084. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1085. /**
  1086. * Removes an existing geometry
  1087. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1088. * @return {boolean} was the geometry removed or not
  1089. */
  1090. removeGeometry(geometry: Geometry): boolean;
  1091. getGeometries(): Geometry[];
  1092. /**
  1093. * Get the first added mesh found of a given ID
  1094. * @param {string} id - the id to search for
  1095. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1096. */
  1097. getMeshByID(id: string): AbstractMesh;
  1098. getMeshesByID(id: string): Array<AbstractMesh>;
  1099. /**
  1100. * Get a mesh with its auto-generated unique id
  1101. * @param {number} uniqueId - the unique id to search for
  1102. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1103. */
  1104. getMeshByUniqueID(uniqueId: number): AbstractMesh;
  1105. /**
  1106. * Get a the last added mesh found of a given ID
  1107. * @param {string} id - the id to search for
  1108. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1109. */
  1110. getLastMeshByID(id: string): AbstractMesh;
  1111. /**
  1112. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1113. * @param {string} id - the id to search for
  1114. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1115. */
  1116. getLastEntryByID(id: string): Node;
  1117. getNodeByID(id: string): Node;
  1118. getNodeByName(name: string): Node;
  1119. getMeshByName(name: string): AbstractMesh;
  1120. getSoundByName(name: string): Sound;
  1121. getLastSkeletonByID(id: string): Skeleton;
  1122. getSkeletonById(id: string): Skeleton;
  1123. getSkeletonByName(name: string): Skeleton;
  1124. isActiveMesh(mesh: Mesh): boolean;
  1125. private _evaluateSubMesh(subMesh, mesh);
  1126. _isInIntermediateRendering(): boolean;
  1127. private _evaluateActiveMeshes();
  1128. private _activeMesh(mesh);
  1129. updateTransformMatrix(force?: boolean): void;
  1130. private _renderForCamera(camera);
  1131. private _processSubCameras(camera);
  1132. private _checkIntersections();
  1133. render(): void;
  1134. private _updateAudioParameters();
  1135. audioEnabled: boolean;
  1136. private _disableAudio();
  1137. private _enableAudio();
  1138. headphone: boolean;
  1139. private _switchAudioModeForHeadphones();
  1140. private _switchAudioModeForNormalSpeakers();
  1141. enableDepthRenderer(): DepthRenderer;
  1142. disableDepthRenderer(): void;
  1143. freezeMaterials(): void;
  1144. unfreezeMaterials(): void;
  1145. dispose(): void;
  1146. disposeSounds(): void;
  1147. getWorldExtends(): {
  1148. min: Vector3;
  1149. max: Vector3;
  1150. };
  1151. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1152. createPickingRay(x: number, y: number, world: Matrix, camera: Camera, cameraViewSpace?: boolean): Ray;
  1153. createPickingRayInCameraSpace(x: number, y: number, camera: Camera): Ray;
  1154. private _internalPick(rayFunction, predicate, fastCheck?);
  1155. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1156. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Camera): PickingInfo;
  1157. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): PickingInfo;
  1158. pickWithRay(ray: Ray, predicate: (mesh: Mesh) => boolean, fastCheck?: boolean): PickingInfo;
  1159. setPointerOverMesh(mesh: AbstractMesh): void;
  1160. getPointerOverMesh(): AbstractMesh;
  1161. setPointerOverSprite(sprite: Sprite): void;
  1162. getPointerOverSprite(): Sprite;
  1163. getPhysicsEngine(): PhysicsEngine;
  1164. /**
  1165. * Enables physics to the current scene
  1166. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1167. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1168. * @return {boolean} was the physics engine initialized
  1169. */
  1170. enablePhysics(gravity?: Vector3, plugin?: IPhysicsEnginePlugin): boolean;
  1171. disablePhysicsEngine(): void;
  1172. isPhysicsEnabled(): boolean;
  1173. /**
  1174. *
  1175. * Sets the gravity of the physics engine (and NOT of the scene)
  1176. * @param {BABYLON.Vector3} [gravity] - the new gravity to be used
  1177. */
  1178. setGravity(gravity: Vector3): void;
  1179. /**
  1180. * Legacy support, using the new API
  1181. * @Deprecated
  1182. */
  1183. createCompoundImpostor(parts: any, options: PhysicsImpostorParameters): any;
  1184. deleteCompoundImpostor(compound: any): void;
  1185. createDefaultCameraOrLight(): void;
  1186. private _getByTags(list, tagsQuery, forEach?);
  1187. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1188. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1189. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1190. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. class Action {
  1195. triggerOptions: any;
  1196. trigger: number;
  1197. _actionManager: ActionManager;
  1198. private _nextActiveAction;
  1199. private _child;
  1200. private _condition;
  1201. private _triggerParameter;
  1202. constructor(triggerOptions: any, condition?: Condition);
  1203. _prepare(): void;
  1204. getTriggerParameter(): any;
  1205. _executeCurrent(evt: ActionEvent): void;
  1206. execute(evt: ActionEvent): void;
  1207. skipToNextActiveAction(): void;
  1208. then(action: Action): Action;
  1209. _getProperty(propertyPath: string): string;
  1210. _getEffectiveTarget(target: any, propertyPath: string): any;
  1211. serialize(parent: any): any;
  1212. protected _serialize(serializedAction: any, parent?: any): any;
  1213. static _SerializeValueAsString: (value: any) => string;
  1214. static _GetTargetProperty: (target: Scene | Node) => {
  1215. name: string;
  1216. targetType: string;
  1217. value: string;
  1218. };
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /**
  1223. * ActionEvent is the event beint sent when an action is triggered.
  1224. */
  1225. class ActionEvent {
  1226. source: any;
  1227. pointerX: number;
  1228. pointerY: number;
  1229. meshUnderPointer: AbstractMesh;
  1230. sourceEvent: any;
  1231. additionalData: any;
  1232. /**
  1233. * @constructor
  1234. * @param source The mesh or sprite that triggered the action.
  1235. * @param pointerX The X mouse cursor position at the time of the event
  1236. * @param pointerY The Y mouse cursor position at the time of the event
  1237. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1238. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1239. */
  1240. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: AbstractMesh, sourceEvent?: any, additionalData?: any);
  1241. /**
  1242. * Helper function to auto-create an ActionEvent from a source mesh.
  1243. * @param source The source mesh that triggered the event
  1244. * @param evt {Event} The original (browser) event
  1245. */
  1246. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1247. /**
  1248. * Helper function to auto-create an ActionEvent from a source mesh.
  1249. * @param source The source sprite that triggered the event
  1250. * @param scene Scene associated with the sprite
  1251. * @param evt {Event} The original (browser) event
  1252. */
  1253. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1254. /**
  1255. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1256. * @param scene the scene where the event occurred
  1257. * @param evt {Event} The original (browser) event
  1258. */
  1259. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1260. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1261. }
  1262. /**
  1263. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1264. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1265. */
  1266. class ActionManager {
  1267. private static _NothingTrigger;
  1268. private static _OnPickTrigger;
  1269. private static _OnLeftPickTrigger;
  1270. private static _OnRightPickTrigger;
  1271. private static _OnCenterPickTrigger;
  1272. private static _OnPickDownTrigger;
  1273. private static _OnPickUpTrigger;
  1274. private static _OnLongPressTrigger;
  1275. private static _OnPointerOverTrigger;
  1276. private static _OnPointerOutTrigger;
  1277. private static _OnEveryFrameTrigger;
  1278. private static _OnIntersectionEnterTrigger;
  1279. private static _OnIntersectionExitTrigger;
  1280. private static _OnKeyDownTrigger;
  1281. private static _OnKeyUpTrigger;
  1282. private static _OnPickOutTrigger;
  1283. static NothingTrigger: number;
  1284. static OnPickTrigger: number;
  1285. static OnLeftPickTrigger: number;
  1286. static OnRightPickTrigger: number;
  1287. static OnCenterPickTrigger: number;
  1288. static OnPickDownTrigger: number;
  1289. static OnPickUpTrigger: number;
  1290. static OnPickOutTrigger: number;
  1291. static OnLongPressTrigger: number;
  1292. static OnPointerOverTrigger: number;
  1293. static OnPointerOutTrigger: number;
  1294. static OnEveryFrameTrigger: number;
  1295. static OnIntersectionEnterTrigger: number;
  1296. static OnIntersectionExitTrigger: number;
  1297. static OnKeyDownTrigger: number;
  1298. static OnKeyUpTrigger: number;
  1299. static DragMovementThreshold: number;
  1300. static LongPressDelay: number;
  1301. actions: Action[];
  1302. private _scene;
  1303. constructor(scene: Scene);
  1304. dispose(): void;
  1305. getScene(): Scene;
  1306. /**
  1307. * Does this action manager handles actions of any of the given triggers
  1308. * @param {number[]} triggers - the triggers to be tested
  1309. * @return {boolean} whether one (or more) of the triggers is handeled
  1310. */
  1311. hasSpecificTriggers(triggers: number[]): boolean;
  1312. /**
  1313. * Does this action manager handles actions of a given trigger
  1314. * @param {number} trigger - the trigger to be tested
  1315. * @return {boolean} whether the trigger is handeled
  1316. */
  1317. hasSpecificTrigger(trigger: number): boolean;
  1318. /**
  1319. * Does this action manager has pointer triggers
  1320. * @return {boolean} whether or not it has pointer triggers
  1321. */
  1322. hasPointerTriggers: boolean;
  1323. /**
  1324. * Does this action manager has pick triggers
  1325. * @return {boolean} whether or not it has pick triggers
  1326. */
  1327. hasPickTriggers: boolean;
  1328. /**
  1329. * Registers an action to this action manager
  1330. * @param {BABYLON.Action} action - the action to be registered
  1331. * @return {BABYLON.Action} the action amended (prepared) after registration
  1332. */
  1333. registerAction(action: Action): Action;
  1334. /**
  1335. * Process a specific trigger
  1336. * @param {number} trigger - the trigger to process
  1337. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1338. */
  1339. processTrigger(trigger: number, evt: ActionEvent): void;
  1340. _getEffectiveTarget(target: any, propertyPath: string): any;
  1341. _getProperty(propertyPath: string): string;
  1342. serialize(name: string): any;
  1343. static Parse(parsedActions: any, object: AbstractMesh, scene: Scene): void;
  1344. static GetTriggerName(trigger: number): string;
  1345. }
  1346. }
  1347. declare module BABYLON {
  1348. class Condition {
  1349. _actionManager: ActionManager;
  1350. _evaluationId: number;
  1351. _currentResult: boolean;
  1352. constructor(actionManager: ActionManager);
  1353. isValid(): boolean;
  1354. _getProperty(propertyPath: string): string;
  1355. _getEffectiveTarget(target: any, propertyPath: string): any;
  1356. serialize(): any;
  1357. protected _serialize(serializedCondition: any): any;
  1358. }
  1359. class ValueCondition extends Condition {
  1360. propertyPath: string;
  1361. value: any;
  1362. operator: number;
  1363. private static _IsEqual;
  1364. private static _IsDifferent;
  1365. private static _IsGreater;
  1366. private static _IsLesser;
  1367. static IsEqual: number;
  1368. static IsDifferent: number;
  1369. static IsGreater: number;
  1370. static IsLesser: number;
  1371. _actionManager: ActionManager;
  1372. private _target;
  1373. private _effectiveTarget;
  1374. private _property;
  1375. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1376. isValid(): boolean;
  1377. serialize(): any;
  1378. static GetOperatorName(operator: number): string;
  1379. }
  1380. class PredicateCondition extends Condition {
  1381. predicate: () => boolean;
  1382. _actionManager: ActionManager;
  1383. constructor(actionManager: ActionManager, predicate: () => boolean);
  1384. isValid(): boolean;
  1385. }
  1386. class StateCondition extends Condition {
  1387. value: string;
  1388. _actionManager: ActionManager;
  1389. private _target;
  1390. constructor(actionManager: ActionManager, target: any, value: string);
  1391. isValid(): boolean;
  1392. serialize(): any;
  1393. }
  1394. }
  1395. declare module BABYLON {
  1396. class SwitchBooleanAction extends Action {
  1397. propertyPath: string;
  1398. private _target;
  1399. private _effectiveTarget;
  1400. private _property;
  1401. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1402. _prepare(): void;
  1403. execute(): void;
  1404. serialize(parent: any): any;
  1405. }
  1406. class SetStateAction extends Action {
  1407. value: string;
  1408. private _target;
  1409. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1410. execute(): void;
  1411. serialize(parent: any): any;
  1412. }
  1413. class SetValueAction extends Action {
  1414. propertyPath: string;
  1415. value: any;
  1416. private _target;
  1417. private _effectiveTarget;
  1418. private _property;
  1419. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1420. _prepare(): void;
  1421. execute(): void;
  1422. serialize(parent: any): any;
  1423. }
  1424. class IncrementValueAction extends Action {
  1425. propertyPath: string;
  1426. value: any;
  1427. private _target;
  1428. private _effectiveTarget;
  1429. private _property;
  1430. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1431. _prepare(): void;
  1432. execute(): void;
  1433. serialize(parent: any): any;
  1434. }
  1435. class PlayAnimationAction extends Action {
  1436. from: number;
  1437. to: number;
  1438. loop: boolean;
  1439. private _target;
  1440. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  1441. _prepare(): void;
  1442. execute(): void;
  1443. serialize(parent: any): any;
  1444. }
  1445. class StopAnimationAction extends Action {
  1446. private _target;
  1447. constructor(triggerOptions: any, target: any, condition?: Condition);
  1448. _prepare(): void;
  1449. execute(): void;
  1450. serialize(parent: any): any;
  1451. }
  1452. class DoNothingAction extends Action {
  1453. constructor(triggerOptions?: any, condition?: Condition);
  1454. execute(): void;
  1455. serialize(parent: any): any;
  1456. }
  1457. class CombineAction extends Action {
  1458. children: Action[];
  1459. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  1460. _prepare(): void;
  1461. execute(evt: ActionEvent): void;
  1462. serialize(parent: any): any;
  1463. }
  1464. class ExecuteCodeAction extends Action {
  1465. func: (evt: ActionEvent) => void;
  1466. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  1467. execute(evt: ActionEvent): void;
  1468. }
  1469. class SetParentAction extends Action {
  1470. private _parent;
  1471. private _target;
  1472. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  1473. _prepare(): void;
  1474. execute(): void;
  1475. serialize(parent: any): any;
  1476. }
  1477. class PlaySoundAction extends Action {
  1478. private _sound;
  1479. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1480. _prepare(): void;
  1481. execute(): void;
  1482. serialize(parent: any): any;
  1483. }
  1484. class StopSoundAction extends Action {
  1485. private _sound;
  1486. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1487. _prepare(): void;
  1488. execute(): void;
  1489. serialize(parent: any): any;
  1490. }
  1491. }
  1492. declare module BABYLON {
  1493. class InterpolateValueAction extends Action {
  1494. propertyPath: string;
  1495. value: any;
  1496. duration: number;
  1497. stopOtherAnimations: boolean;
  1498. onInterpolationDone: () => void;
  1499. private _target;
  1500. private _effectiveTarget;
  1501. private _property;
  1502. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  1503. _prepare(): void;
  1504. execute(): void;
  1505. serialize(parent: any): any;
  1506. }
  1507. }
  1508. declare module BABYLON {
  1509. class Animatable {
  1510. target: any;
  1511. fromFrame: number;
  1512. toFrame: number;
  1513. loopAnimation: boolean;
  1514. speedRatio: number;
  1515. onAnimationEnd: any;
  1516. private _localDelayOffset;
  1517. private _pausedDelay;
  1518. private _animations;
  1519. private _paused;
  1520. private _scene;
  1521. animationStarted: boolean;
  1522. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: any, animations?: any);
  1523. getAnimations(): Animation[];
  1524. appendAnimations(target: any, animations: Animation[]): void;
  1525. getAnimationByTargetProperty(property: string): Animation;
  1526. reset(): void;
  1527. enableBlending(blendingSpeed: number): void;
  1528. disableBlending(): void;
  1529. goToFrame(frame: number): void;
  1530. pause(): void;
  1531. restart(): void;
  1532. stop(): void;
  1533. _animate(delay: number): boolean;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. class AnimationRange {
  1538. name: string;
  1539. from: number;
  1540. to: number;
  1541. constructor(name: string, from: number, to: number);
  1542. clone(): AnimationRange;
  1543. }
  1544. /**
  1545. * Composed of a frame, and an action function
  1546. */
  1547. class AnimationEvent {
  1548. frame: number;
  1549. action: () => void;
  1550. onlyOnce: boolean;
  1551. isDone: boolean;
  1552. constructor(frame: number, action: () => void, onlyOnce?: boolean);
  1553. }
  1554. class PathCursor {
  1555. private path;
  1556. private _onchange;
  1557. value: number;
  1558. animations: Animation[];
  1559. constructor(path: Path2);
  1560. getPoint(): Vector3;
  1561. moveAhead(step?: number): PathCursor;
  1562. moveBack(step?: number): PathCursor;
  1563. move(step: number): PathCursor;
  1564. private ensureLimits();
  1565. private markAsDirty(propertyName);
  1566. private raiseOnChange();
  1567. onchange(f: (cursor: PathCursor) => void): PathCursor;
  1568. }
  1569. class Animation {
  1570. name: string;
  1571. targetProperty: string;
  1572. framePerSecond: number;
  1573. dataType: number;
  1574. loopMode: number;
  1575. enableBlending: boolean;
  1576. private _keys;
  1577. private _offsetsCache;
  1578. private _highLimitsCache;
  1579. private _stopped;
  1580. _target: any;
  1581. private _blendingFactor;
  1582. private _easingFunction;
  1583. private _events;
  1584. targetPropertyPath: string[];
  1585. currentFrame: number;
  1586. allowMatricesInterpolation: boolean;
  1587. blendingSpeed: number;
  1588. private _originalBlendValue;
  1589. private _ranges;
  1590. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Animation;
  1591. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Animatable;
  1592. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Animatable;
  1593. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number, enableBlending?: boolean);
  1594. /**
  1595. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  1596. */
  1597. toString(fullDetails?: boolean): string;
  1598. /**
  1599. * Add an event to this animation.
  1600. */
  1601. addEvent(event: AnimationEvent): void;
  1602. /**
  1603. * Remove all events found at the given frame
  1604. * @param frame
  1605. */
  1606. removeEvents(frame: number): void;
  1607. createRange(name: string, from: number, to: number): void;
  1608. deleteRange(name: string, deleteFrames?: boolean): void;
  1609. getRange(name: string): AnimationRange;
  1610. reset(): void;
  1611. isStopped(): boolean;
  1612. getKeys(): Array<{
  1613. frame: number;
  1614. value: any;
  1615. }>;
  1616. getHighestFrame(): number;
  1617. getEasingFunction(): IEasingFunction;
  1618. setEasingFunction(easingFunction: EasingFunction): void;
  1619. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  1620. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  1621. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  1622. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  1623. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  1624. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  1625. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  1626. clone(): Animation;
  1627. setKeys(values: Array<{
  1628. frame: number;
  1629. value: any;
  1630. }>): void;
  1631. private _getKeyValue(value);
  1632. private _interpolate(currentFrame, repeatCount, loopMode, offsetValue?, highLimitValue?);
  1633. setValue(currentValue: any, blend?: boolean): void;
  1634. goToFrame(frame: number): void;
  1635. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, blend?: boolean): boolean;
  1636. serialize(): any;
  1637. private static _ANIMATIONTYPE_FLOAT;
  1638. private static _ANIMATIONTYPE_VECTOR3;
  1639. private static _ANIMATIONTYPE_QUATERNION;
  1640. private static _ANIMATIONTYPE_MATRIX;
  1641. private static _ANIMATIONTYPE_COLOR3;
  1642. private static _ANIMATIONTYPE_VECTOR2;
  1643. private static _ANIMATIONTYPE_SIZE;
  1644. private static _ANIMATIONLOOPMODE_RELATIVE;
  1645. private static _ANIMATIONLOOPMODE_CYCLE;
  1646. private static _ANIMATIONLOOPMODE_CONSTANT;
  1647. static ANIMATIONTYPE_FLOAT: number;
  1648. static ANIMATIONTYPE_VECTOR3: number;
  1649. static ANIMATIONTYPE_VECTOR2: number;
  1650. static ANIMATIONTYPE_SIZE: number;
  1651. static ANIMATIONTYPE_QUATERNION: number;
  1652. static ANIMATIONTYPE_MATRIX: number;
  1653. static ANIMATIONTYPE_COLOR3: number;
  1654. static ANIMATIONLOOPMODE_RELATIVE: number;
  1655. static ANIMATIONLOOPMODE_CYCLE: number;
  1656. static ANIMATIONLOOPMODE_CONSTANT: number;
  1657. static Parse(parsedAnimation: any): Animation;
  1658. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  1659. }
  1660. }
  1661. declare module BABYLON {
  1662. interface IEasingFunction {
  1663. ease(gradient: number): number;
  1664. }
  1665. class EasingFunction implements IEasingFunction {
  1666. private static _EASINGMODE_EASEIN;
  1667. private static _EASINGMODE_EASEOUT;
  1668. private static _EASINGMODE_EASEINOUT;
  1669. static EASINGMODE_EASEIN: number;
  1670. static EASINGMODE_EASEOUT: number;
  1671. static EASINGMODE_EASEINOUT: number;
  1672. private _easingMode;
  1673. setEasingMode(easingMode: number): void;
  1674. getEasingMode(): number;
  1675. easeInCore(gradient: number): number;
  1676. ease(gradient: number): number;
  1677. }
  1678. class CircleEase extends EasingFunction implements IEasingFunction {
  1679. easeInCore(gradient: number): number;
  1680. }
  1681. class BackEase extends EasingFunction implements IEasingFunction {
  1682. amplitude: number;
  1683. constructor(amplitude?: number);
  1684. easeInCore(gradient: number): number;
  1685. }
  1686. class BounceEase extends EasingFunction implements IEasingFunction {
  1687. bounces: number;
  1688. bounciness: number;
  1689. constructor(bounces?: number, bounciness?: number);
  1690. easeInCore(gradient: number): number;
  1691. }
  1692. class CubicEase extends EasingFunction implements IEasingFunction {
  1693. easeInCore(gradient: number): number;
  1694. }
  1695. class ElasticEase extends EasingFunction implements IEasingFunction {
  1696. oscillations: number;
  1697. springiness: number;
  1698. constructor(oscillations?: number, springiness?: number);
  1699. easeInCore(gradient: number): number;
  1700. }
  1701. class ExponentialEase extends EasingFunction implements IEasingFunction {
  1702. exponent: number;
  1703. constructor(exponent?: number);
  1704. easeInCore(gradient: number): number;
  1705. }
  1706. class PowerEase extends EasingFunction implements IEasingFunction {
  1707. power: number;
  1708. constructor(power?: number);
  1709. easeInCore(gradient: number): number;
  1710. }
  1711. class QuadraticEase extends EasingFunction implements IEasingFunction {
  1712. easeInCore(gradient: number): number;
  1713. }
  1714. class QuarticEase extends EasingFunction implements IEasingFunction {
  1715. easeInCore(gradient: number): number;
  1716. }
  1717. class QuinticEase extends EasingFunction implements IEasingFunction {
  1718. easeInCore(gradient: number): number;
  1719. }
  1720. class SineEase extends EasingFunction implements IEasingFunction {
  1721. easeInCore(gradient: number): number;
  1722. }
  1723. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  1724. x1: number;
  1725. y1: number;
  1726. x2: number;
  1727. y2: number;
  1728. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  1729. easeInCore(gradient: number): number;
  1730. }
  1731. }
  1732. declare module BABYLON {
  1733. class Analyser {
  1734. SMOOTHING: number;
  1735. FFT_SIZE: number;
  1736. BARGRAPHAMPLITUDE: number;
  1737. DEBUGCANVASPOS: {
  1738. x: number;
  1739. y: number;
  1740. };
  1741. DEBUGCANVASSIZE: {
  1742. width: number;
  1743. height: number;
  1744. };
  1745. private _byteFreqs;
  1746. private _byteTime;
  1747. private _floatFreqs;
  1748. private _webAudioAnalyser;
  1749. private _debugCanvas;
  1750. private _debugCanvasContext;
  1751. private _scene;
  1752. private _registerFunc;
  1753. private _audioEngine;
  1754. constructor(scene: Scene);
  1755. getFrequencyBinCount(): number;
  1756. getByteFrequencyData(): Uint8Array;
  1757. getByteTimeDomainData(): Uint8Array;
  1758. getFloatFrequencyData(): Uint8Array;
  1759. drawDebugCanvas(): void;
  1760. stopDebugCanvas(): void;
  1761. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  1762. dispose(): void;
  1763. }
  1764. }
  1765. declare module BABYLON {
  1766. class AudioEngine {
  1767. private _audioContext;
  1768. private _audioContextInitialized;
  1769. canUseWebAudio: boolean;
  1770. masterGain: GainNode;
  1771. private _connectedAnalyser;
  1772. WarnedWebAudioUnsupported: boolean;
  1773. unlocked: boolean;
  1774. onAudioUnlocked: () => any;
  1775. audioContext: AudioContext;
  1776. constructor();
  1777. private _unlockiOSaudio();
  1778. private _initializeAudioContext();
  1779. dispose(): void;
  1780. getGlobalVolume(): number;
  1781. setGlobalVolume(newVolume: number): void;
  1782. connectToAnalyser(analyser: Analyser): void;
  1783. }
  1784. }
  1785. declare module BABYLON {
  1786. class Sound {
  1787. name: string;
  1788. autoplay: boolean;
  1789. loop: boolean;
  1790. useCustomAttenuation: boolean;
  1791. soundTrackId: number;
  1792. spatialSound: boolean;
  1793. refDistance: number;
  1794. rolloffFactor: number;
  1795. maxDistance: number;
  1796. distanceModel: string;
  1797. private _panningModel;
  1798. onended: () => any;
  1799. private _playbackRate;
  1800. private _streaming;
  1801. private _startTime;
  1802. private _startOffset;
  1803. private _position;
  1804. private _localDirection;
  1805. private _volume;
  1806. private _isLoaded;
  1807. private _isReadyToPlay;
  1808. isPlaying: boolean;
  1809. isPaused: boolean;
  1810. private _isDirectional;
  1811. private _readyToPlayCallback;
  1812. private _audioBuffer;
  1813. private _soundSource;
  1814. private _streamingSource;
  1815. private _soundPanner;
  1816. private _soundGain;
  1817. private _inputAudioNode;
  1818. private _ouputAudioNode;
  1819. private _coneInnerAngle;
  1820. private _coneOuterAngle;
  1821. private _coneOuterGain;
  1822. private _scene;
  1823. private _connectedMesh;
  1824. private _customAttenuationFunction;
  1825. private _registerFunc;
  1826. private _isOutputConnected;
  1827. private _htmlAudioElement;
  1828. /**
  1829. * Create a sound and attach it to a scene
  1830. * @param name Name of your sound
  1831. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  1832. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  1833. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  1834. */
  1835. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any);
  1836. dispose(): void;
  1837. private _soundLoaded(audioData);
  1838. setAudioBuffer(audioBuffer: AudioBuffer): void;
  1839. updateOptions(options: any): void;
  1840. private _createSpatialParameters();
  1841. private _updateSpatialParameters();
  1842. switchPanningModelToHRTF(): void;
  1843. switchPanningModelToEqualPower(): void;
  1844. private _switchPanningModel();
  1845. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  1846. /**
  1847. * Transform this sound into a directional source
  1848. * @param coneInnerAngle Size of the inner cone in degree
  1849. * @param coneOuterAngle Size of the outer cone in degree
  1850. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  1851. */
  1852. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  1853. setPosition(newPosition: Vector3): void;
  1854. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  1855. private _updateDirection();
  1856. updateDistanceFromListener(): void;
  1857. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  1858. /**
  1859. * Play the sound
  1860. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  1861. * @param offset (optional) Start the sound setting it at a specific time
  1862. */
  1863. play(time?: number, offset?: number): void;
  1864. private _onended();
  1865. /**
  1866. * Stop the sound
  1867. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  1868. */
  1869. stop(time?: number): void;
  1870. pause(): void;
  1871. setVolume(newVolume: number, time?: number): void;
  1872. setPlaybackRate(newPlaybackRate: number): void;
  1873. getVolume(): number;
  1874. attachToMesh(meshToConnectTo: AbstractMesh): void;
  1875. detachFromMesh(): void;
  1876. private _onRegisterAfterWorldMatrixUpdate(connectedMesh);
  1877. clone(): Sound;
  1878. getAudioBuffer(): AudioBuffer;
  1879. serialize(): any;
  1880. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  1881. }
  1882. }
  1883. declare module BABYLON {
  1884. class SoundTrack {
  1885. private _outputAudioNode;
  1886. private _inputAudioNode;
  1887. private _trackConvolver;
  1888. private _scene;
  1889. id: number;
  1890. soundCollection: Array<Sound>;
  1891. private _isMainTrack;
  1892. private _connectedAnalyser;
  1893. private _options;
  1894. private _isInitialized;
  1895. constructor(scene: Scene, options?: any);
  1896. private _initializeSoundTrackAudioGraph();
  1897. dispose(): void;
  1898. AddSound(sound: Sound): void;
  1899. RemoveSound(sound: Sound): void;
  1900. setVolume(newVolume: number): void;
  1901. switchPanningModelToHRTF(): void;
  1902. switchPanningModelToEqualPower(): void;
  1903. connectToAnalyser(analyser: Analyser): void;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. class Bone extends Node {
  1908. name: string;
  1909. children: Bone[];
  1910. animations: Animation[];
  1911. length: number;
  1912. private _skeleton;
  1913. _matrix: Matrix;
  1914. private _restPose;
  1915. private _baseMatrix;
  1916. private _worldTransform;
  1917. private _absoluteTransform;
  1918. private _invertedAbsoluteTransform;
  1919. private _parent;
  1920. constructor(name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix, restPose?: Matrix);
  1921. getParent(): Bone;
  1922. getLocalMatrix(): Matrix;
  1923. getBaseMatrix(): Matrix;
  1924. getRestPose(): Matrix;
  1925. returnToRest(): void;
  1926. getWorldMatrix(): Matrix;
  1927. getInvertedAbsoluteTransform(): Matrix;
  1928. getAbsoluteTransform(): Matrix;
  1929. updateMatrix(matrix: Matrix): void;
  1930. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  1931. markAsDirty(): void;
  1932. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Vector3): boolean;
  1933. }
  1934. }
  1935. declare module BABYLON {
  1936. class Skeleton {
  1937. name: string;
  1938. id: string;
  1939. bones: Bone[];
  1940. dimensionsAtRest: Vector3;
  1941. needInitialSkinMatrix: boolean;
  1942. private _scene;
  1943. private _isDirty;
  1944. private _transformMatrices;
  1945. private _meshesWithPoseMatrix;
  1946. private _animatables;
  1947. private _identity;
  1948. private _ranges;
  1949. constructor(name: string, id: string, scene: Scene);
  1950. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  1951. getScene(): Scene;
  1952. /**
  1953. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  1954. */
  1955. toString(fullDetails?: boolean): string;
  1956. /**
  1957. * Get bone's index searching by name
  1958. * @param {string} name is bone's name to search for
  1959. * @return {number} Indice of the bone. Returns -1 if not found
  1960. */
  1961. getBoneIndexByName(name: string): number;
  1962. createAnimationRange(name: string, from: number, to: number): void;
  1963. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  1964. getAnimationRange(name: string): AnimationRange;
  1965. /**
  1966. * Returns as an Array, all AnimationRanges defined on this skeleton
  1967. */
  1968. getAnimationRanges(): AnimationRange[];
  1969. /**
  1970. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  1971. */
  1972. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  1973. returnToRest(): void;
  1974. private _getHighestAnimationFrame();
  1975. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1976. _markAsDirty(): void;
  1977. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  1978. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  1979. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Matrix): void;
  1980. prepare(): void;
  1981. getAnimatables(): IAnimatable[];
  1982. clone(name: string, id: string): Skeleton;
  1983. enableBlending(blendingSpeed?: number): void;
  1984. dispose(): void;
  1985. serialize(): any;
  1986. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  1987. }
  1988. }
  1989. declare module BABYLON {
  1990. class ArcRotateCamera extends TargetCamera {
  1991. alpha: number;
  1992. beta: number;
  1993. radius: number;
  1994. target: Vector3;
  1995. inertialAlphaOffset: number;
  1996. inertialBetaOffset: number;
  1997. inertialRadiusOffset: number;
  1998. lowerAlphaLimit: any;
  1999. upperAlphaLimit: any;
  2000. lowerBetaLimit: number;
  2001. upperBetaLimit: number;
  2002. lowerRadiusLimit: any;
  2003. upperRadiusLimit: any;
  2004. inertialPanningX: number;
  2005. inertialPanningY: number;
  2006. angularSensibilityX: number;
  2007. angularSensibilityY: number;
  2008. pinchPrecision: number;
  2009. panningSensibility: number;
  2010. keysUp: number[];
  2011. keysDown: number[];
  2012. keysLeft: number[];
  2013. keysRight: number[];
  2014. wheelPrecision: number;
  2015. zoomOnFactor: number;
  2016. targetScreenOffset: Vector2;
  2017. allowUpsideDown: boolean;
  2018. _viewMatrix: Matrix;
  2019. _useCtrlForPanning: boolean;
  2020. _panningMouseButton: number;
  2021. inputs: ArcRotateCameraInputsManager;
  2022. _reset: () => void;
  2023. panningAxis: Vector3;
  2024. private _localDirection;
  2025. private _transformedDirection;
  2026. onCollide: (collidedMesh: AbstractMesh) => void;
  2027. checkCollisions: boolean;
  2028. collisionRadius: Vector3;
  2029. private _collider;
  2030. private _previousPosition;
  2031. private _collisionVelocity;
  2032. private _newPosition;
  2033. private _previousAlpha;
  2034. private _previousBeta;
  2035. private _previousRadius;
  2036. private _collisionTriggered;
  2037. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  2038. _initCache(): void;
  2039. _updateCache(ignoreParentClass?: boolean): void;
  2040. private _getTargetPosition();
  2041. _isSynchronizedViewMatrix(): boolean;
  2042. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  2043. detachControl(element: HTMLElement): void;
  2044. _checkInputs(): void;
  2045. private _checkLimits();
  2046. rebuildAnglesAndRadius(): void;
  2047. setPosition(position: Vector3): void;
  2048. setTarget(target: Vector3): void;
  2049. _getViewMatrix(): Matrix;
  2050. private _onCollisionPositionChange;
  2051. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  2052. focusOn(meshesOrMinMaxVectorAndDistance: any, doNotUpdateMaxZ?: boolean): void;
  2053. /**
  2054. * @override
  2055. * Override Camera.createRigCamera
  2056. */
  2057. createRigCamera(name: string, cameraIndex: number): Camera;
  2058. /**
  2059. * @override
  2060. * Override Camera._updateRigCameras
  2061. */
  2062. _updateRigCameras(): void;
  2063. dispose(): void;
  2064. getTypeName(): string;
  2065. }
  2066. }
  2067. declare module BABYLON {
  2068. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  2069. constructor(camera: ArcRotateCamera);
  2070. addMouseWheel(): ArcRotateCameraInputsManager;
  2071. addPointers(): ArcRotateCameraInputsManager;
  2072. addKeyboard(): ArcRotateCameraInputsManager;
  2073. addGamepad(): ArcRotateCameraInputsManager;
  2074. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  2075. }
  2076. }
  2077. declare module BABYLON {
  2078. class Camera extends Node {
  2079. inputs: CameraInputsManager<Camera>;
  2080. private static _PERSPECTIVE_CAMERA;
  2081. private static _ORTHOGRAPHIC_CAMERA;
  2082. private static _FOVMODE_VERTICAL_FIXED;
  2083. private static _FOVMODE_HORIZONTAL_FIXED;
  2084. private static _RIG_MODE_NONE;
  2085. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  2086. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  2087. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  2088. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  2089. private static _RIG_MODE_VR;
  2090. static PERSPECTIVE_CAMERA: number;
  2091. static ORTHOGRAPHIC_CAMERA: number;
  2092. static FOVMODE_VERTICAL_FIXED: number;
  2093. static FOVMODE_HORIZONTAL_FIXED: number;
  2094. static RIG_MODE_NONE: number;
  2095. static RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  2096. static RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  2097. static RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  2098. static RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  2099. static RIG_MODE_VR: number;
  2100. static ForceAttachControlToAlwaysPreventDefault: boolean;
  2101. position: Vector3;
  2102. upVector: Vector3;
  2103. orthoLeft: any;
  2104. orthoRight: any;
  2105. orthoBottom: any;
  2106. orthoTop: any;
  2107. fov: number;
  2108. minZ: number;
  2109. maxZ: number;
  2110. inertia: number;
  2111. mode: number;
  2112. isIntermediate: boolean;
  2113. viewport: Viewport;
  2114. layerMask: number;
  2115. fovMode: number;
  2116. cameraRigMode: number;
  2117. interaxialDistance: number;
  2118. isStereoscopicSideBySide: boolean;
  2119. _cameraRigParams: any;
  2120. _rigCameras: Camera[];
  2121. _rigPostProcess: PostProcess;
  2122. private _computedViewMatrix;
  2123. _projectionMatrix: Matrix;
  2124. private _worldMatrix;
  2125. _postProcesses: PostProcess[];
  2126. private _transformMatrix;
  2127. _activeMeshes: SmartArray<Mesh>;
  2128. private _globalPosition;
  2129. private _frustumPlanes;
  2130. private _refreshFrustumPlanes;
  2131. constructor(name: string, position: Vector3, scene: Scene);
  2132. /**
  2133. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2134. */
  2135. toString(fullDetails?: boolean): string;
  2136. globalPosition: Vector3;
  2137. getActiveMeshes(): SmartArray<Mesh>;
  2138. isActiveMesh(mesh: Mesh): boolean;
  2139. _initCache(): void;
  2140. _updateCache(ignoreParentClass?: boolean): void;
  2141. _updateFromScene(): void;
  2142. _isSynchronized(): boolean;
  2143. _isSynchronizedViewMatrix(): boolean;
  2144. _isSynchronizedProjectionMatrix(): boolean;
  2145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  2146. detachControl(element: HTMLElement): void;
  2147. _update(): void;
  2148. _checkInputs(): void;
  2149. private _cascadePostProcessesToRigCams();
  2150. attachPostProcess(postProcess: PostProcess, insertAt?: number): number;
  2151. detachPostProcess(postProcess: PostProcess, atIndices?: any): number[];
  2152. getWorldMatrix(): Matrix;
  2153. _getViewMatrix(): Matrix;
  2154. getViewMatrix(force?: boolean): Matrix;
  2155. _computeViewMatrix(force?: boolean): Matrix;
  2156. getProjectionMatrix(force?: boolean): Matrix;
  2157. getTranformationMatrix(): Matrix;
  2158. private updateFrustumPlanes();
  2159. isInFrustum(target: ICullable): boolean;
  2160. isCompletelyInFrustum(target: ICullable): boolean;
  2161. dispose(): void;
  2162. setCameraRigMode(mode: number, rigParams: any): void;
  2163. private _getVRProjectionMatrix();
  2164. setCameraRigParameter(name: string, value: any): void;
  2165. /**
  2166. * needs to be overridden by children so sub has required properties to be copied
  2167. */
  2168. createRigCamera(name: string, cameraIndex: number): Camera;
  2169. /**
  2170. * May need to be overridden by children
  2171. */
  2172. _updateRigCameras(): void;
  2173. _setupInputs(): void;
  2174. serialize(): any;
  2175. getTypeName(): string;
  2176. clone(name: string): Camera;
  2177. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  2178. static Parse(parsedCamera: any, scene: Scene): Camera;
  2179. }
  2180. }
  2181. declare module BABYLON {
  2182. var CameraInputTypes: {};
  2183. interface ICameraInput<TCamera extends BABYLON.Camera> {
  2184. camera: TCamera;
  2185. getTypeName(): string;
  2186. getSimpleName(): string;
  2187. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  2188. detachControl: (element: HTMLElement) => void;
  2189. checkInputs?: () => void;
  2190. }
  2191. interface CameraInputsMap<TCamera extends BABYLON.Camera> {
  2192. [name: string]: ICameraInput<TCamera>;
  2193. [idx: number]: ICameraInput<TCamera>;
  2194. }
  2195. class CameraInputsManager<TCamera extends BABYLON.Camera> {
  2196. attached: CameraInputsMap<TCamera>;
  2197. attachedElement: HTMLElement;
  2198. noPreventDefault: boolean;
  2199. camera: TCamera;
  2200. checkInputs: () => void;
  2201. constructor(camera: TCamera);
  2202. add(input: ICameraInput<TCamera>): void;
  2203. remove(inputToRemove: ICameraInput<TCamera>): void;
  2204. removeByType(inputType: string): void;
  2205. private _addCheckInputs(fn);
  2206. attachInput(input: ICameraInput<TCamera>): void;
  2207. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  2208. detachElement(element: HTMLElement): void;
  2209. rebuildInputCheck(): void;
  2210. clear(): void;
  2211. serialize(serializedCamera: any): void;
  2212. parse(parsedCamera: any): void;
  2213. }
  2214. }
  2215. declare module BABYLON {
  2216. class DeviceOrientationCamera extends FreeCamera {
  2217. angularSensibility: number;
  2218. moveSensibility: number;
  2219. constructor(name: string, position: Vector3, scene: Scene);
  2220. getTypeName(): string;
  2221. }
  2222. }
  2223. declare module BABYLON {
  2224. class FollowCamera extends TargetCamera {
  2225. radius: number;
  2226. rotationOffset: number;
  2227. heightOffset: number;
  2228. cameraAcceleration: number;
  2229. maxCameraSpeed: number;
  2230. target: AbstractMesh;
  2231. constructor(name: string, position: Vector3, scene: Scene, target?: AbstractMesh);
  2232. private getRadians(degrees);
  2233. private follow(cameraTarget);
  2234. _checkInputs(): void;
  2235. getTypeName(): string;
  2236. }
  2237. class ArcFollowCamera extends TargetCamera {
  2238. alpha: number;
  2239. beta: number;
  2240. radius: number;
  2241. target: AbstractMesh;
  2242. private _cartesianCoordinates;
  2243. constructor(name: string, alpha: number, beta: number, radius: number, target: AbstractMesh, scene: Scene);
  2244. private follow();
  2245. _checkInputs(): void;
  2246. getTypeName(): string;
  2247. }
  2248. }
  2249. declare module BABYLON {
  2250. class FreeCamera extends TargetCamera {
  2251. ellipsoid: Vector3;
  2252. checkCollisions: boolean;
  2253. applyGravity: boolean;
  2254. inputs: FreeCameraInputsManager;
  2255. angularSensibility: number;
  2256. keysUp: number[];
  2257. keysDown: number[];
  2258. keysLeft: number[];
  2259. keysRight: number[];
  2260. onCollide: (collidedMesh: AbstractMesh) => void;
  2261. private _collider;
  2262. private _needMoveForGravity;
  2263. private _oldPosition;
  2264. private _diffPosition;
  2265. private _newPosition;
  2266. _localDirection: Vector3;
  2267. _transformedDirection: Vector3;
  2268. constructor(name: string, position: Vector3, scene: Scene);
  2269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  2270. detachControl(element: HTMLElement): void;
  2271. _collideWithWorld(velocity: Vector3): void;
  2272. private _onCollisionPositionChange;
  2273. _checkInputs(): void;
  2274. _decideIfNeedsToMove(): boolean;
  2275. _updatePosition(): void;
  2276. dispose(): void;
  2277. getTypeName(): string;
  2278. }
  2279. }
  2280. declare module BABYLON {
  2281. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  2282. constructor(camera: FreeCamera);
  2283. addKeyboard(): FreeCameraInputsManager;
  2284. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  2285. addGamepad(): FreeCameraInputsManager;
  2286. addDeviceOrientation(): FreeCameraInputsManager;
  2287. addVRDeviceOrientation(): FreeCameraInputsManager;
  2288. addTouch(): FreeCameraInputsManager;
  2289. addVirtualJoystick(): FreeCameraInputsManager;
  2290. }
  2291. }
  2292. declare module BABYLON {
  2293. class GamepadCamera extends UniversalCamera {
  2294. gamepadAngularSensibility: number;
  2295. gamepadMoveSensibility: number;
  2296. constructor(name: string, position: Vector3, scene: Scene);
  2297. getTypeName(): string;
  2298. }
  2299. }
  2300. declare module BABYLON {
  2301. class AnaglyphFreeCamera extends FreeCamera {
  2302. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  2303. getTypeName(): string;
  2304. }
  2305. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  2306. constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, scene: Scene);
  2307. getTypeName(): string;
  2308. }
  2309. class AnaglyphGamepadCamera extends GamepadCamera {
  2310. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  2311. getTypeName(): string;
  2312. }
  2313. class AnaglyphUniversalCamera extends UniversalCamera {
  2314. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  2315. getTypeName(): string;
  2316. }
  2317. class StereoscopicFreeCamera extends FreeCamera {
  2318. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  2319. getTypeName(): string;
  2320. }
  2321. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  2322. constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  2323. getTypeName(): string;
  2324. }
  2325. class StereoscopicGamepadCamera extends GamepadCamera {
  2326. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  2327. getTypeName(): string;
  2328. }
  2329. class StereoscopicUniversalCamera extends UniversalCamera {
  2330. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  2331. getTypeName(): string;
  2332. }
  2333. }
  2334. declare module BABYLON {
  2335. class TargetCamera extends Camera {
  2336. cameraDirection: Vector3;
  2337. cameraRotation: Vector2;
  2338. rotation: Vector3;
  2339. rotationQuaternion: Quaternion;
  2340. speed: number;
  2341. noRotationConstraint: boolean;
  2342. lockedTarget: any;
  2343. _currentTarget: Vector3;
  2344. _viewMatrix: Matrix;
  2345. _camMatrix: Matrix;
  2346. _cameraTransformMatrix: Matrix;
  2347. _cameraRotationMatrix: Matrix;
  2348. private _rigCamTransformMatrix;
  2349. _referencePoint: Vector3;
  2350. private _defaultUpVector;
  2351. _transformedReferencePoint: Vector3;
  2352. _lookAtTemp: Matrix;
  2353. _tempMatrix: Matrix;
  2354. _reset: () => void;
  2355. constructor(name: string, position: Vector3, scene: Scene);
  2356. getFrontPosition(distance: number): Vector3;
  2357. _getLockedTargetPosition(): Vector3;
  2358. _initCache(): void;
  2359. _updateCache(ignoreParentClass?: boolean): void;
  2360. _isSynchronizedViewMatrix(): boolean;
  2361. _computeLocalCameraSpeed(): number;
  2362. setTarget(target: Vector3): void;
  2363. getTarget(): Vector3;
  2364. _decideIfNeedsToMove(): boolean;
  2365. _updatePosition(): void;
  2366. _checkInputs(): void;
  2367. private _updateCameraRotationMatrix();
  2368. _getViewMatrix(): Matrix;
  2369. /**
  2370. * @override
  2371. * Override Camera.createRigCamera
  2372. */
  2373. createRigCamera(name: string, cameraIndex: number): Camera;
  2374. /**
  2375. * @override
  2376. * Override Camera._updateRigCameras
  2377. */
  2378. _updateRigCameras(): void;
  2379. private _getRigCamPosition(halfSpace, result);
  2380. getTypeName(): string;
  2381. }
  2382. }
  2383. declare module BABYLON {
  2384. class TouchCamera extends FreeCamera {
  2385. touchAngularSensibility: number;
  2386. touchMoveSensibility: number;
  2387. constructor(name: string, position: Vector3, scene: Scene);
  2388. getTypeName(): string;
  2389. _setupInputs(): void;
  2390. }
  2391. }
  2392. declare module BABYLON {
  2393. class UniversalCamera extends TouchCamera {
  2394. gamepadAngularSensibility: number;
  2395. gamepadMoveSensibility: number;
  2396. constructor(name: string, position: Vector3, scene: Scene);
  2397. getTypeName(): string;
  2398. }
  2399. }
  2400. declare module BABYLON {
  2401. class VirtualJoysticksCamera extends FreeCamera {
  2402. constructor(name: string, position: Vector3, scene: Scene);
  2403. }
  2404. }
  2405. declare module BABYLON {
  2406. /**
  2407. * Stores 2D Bounding Information.
  2408. * This class handles a circle area and a bounding rectangle one.
  2409. */
  2410. class BoundingInfo2D {
  2411. /**
  2412. * The coordinate of the center of the bounding info
  2413. */
  2414. center: Vector2;
  2415. /**
  2416. * The radius of the bounding circle, from the center of the bounded object
  2417. */
  2418. radius: number;
  2419. /**
  2420. * The extent of the bounding rectangle, from the center of the bounded object.
  2421. * This is an absolute value in both X and Y of the vector which describe the right/top corner of the rectangle, you can easily reconstruct the whole rectangle by negating X &| Y.
  2422. */
  2423. extent: Vector2;
  2424. constructor();
  2425. /**
  2426. * Create a BoundingInfo2D object from a given size
  2427. * @param size the size that will be used to set the extend, radius will be computed from it.
  2428. */
  2429. static CreateFromSize(size: Size): BoundingInfo2D;
  2430. /**
  2431. * Create a BoundingInfo2D object from a given radius
  2432. * @param radius the radius to use, the extent will be computed from it.
  2433. */
  2434. static CreateFromRadius(radius: number): BoundingInfo2D;
  2435. /**
  2436. * Create a BoundingInfo2D object from a list of points.
  2437. * The resulted object will be the smallest bounding area that includes all the given points.
  2438. * @param points an array of points to compute the bounding object from.
  2439. */
  2440. static CreateFromPoints(points: Vector2[]): BoundingInfo2D;
  2441. /**
  2442. * Update a BoundingInfo2D object using the given Size as input
  2443. * @param size the bounding data will be computed from this size.
  2444. * @param b must be a valid/allocated object, it will contain the result of the operation
  2445. */
  2446. static CreateFromSizeToRef(size: Size, b: BoundingInfo2D): void;
  2447. /**
  2448. * Update a BoundingInfo2D object using the given radius as input
  2449. * @param radius the bounding data will be computed from this radius
  2450. * @param b must be a valid/allocated object, it will contain the result of the operation
  2451. */
  2452. static CreateFromRadiusToRef(radius: number, b: BoundingInfo2D): void;
  2453. /**
  2454. * Update a BoundingInfo2D object using the given points array as input
  2455. * @param points the point array to use to update the bounding data
  2456. * @param b must be a valid/allocated object, it will contain the result of the operation
  2457. */
  2458. static CreateFromPointsToRef(points: Vector2[], b: BoundingInfo2D): void;
  2459. /**
  2460. * Update a BoundingInfo2D object using the given min/max values as input
  2461. * @param xmin the smallest x coordinate
  2462. * @param xmax the biggest x coordinate
  2463. * @param ymin the smallest y coordinate
  2464. * @param ymax the buggest y coordinate
  2465. * @param b must be a valid/allocated object, it will contain the result of the operation
  2466. */
  2467. static CreateFromMinMaxToRef(xmin: number, xmax: number, ymin: number, ymax: number, b: BoundingInfo2D): void;
  2468. /**
  2469. * Duplicate this instance and return a new one
  2470. * @return the duplicated instance
  2471. */
  2472. clone(): BoundingInfo2D;
  2473. clear(): void;
  2474. copyFrom(src: BoundingInfo2D): void;
  2475. /**
  2476. * return the max extend of the bounding info
  2477. */
  2478. max(): Vector2;
  2479. /**
  2480. * Update a vector2 with the max extend of the bounding info
  2481. * @param result must be a valid/allocated vector2 that will contain the result of the operation
  2482. */
  2483. maxToRef(result: Vector2): void;
  2484. /**
  2485. * Apply a transformation matrix to this BoundingInfo2D and return a new instance containing the result
  2486. * @param matrix the transformation matrix to apply
  2487. * @return the new instance containing the result of the transformation applied on this BoundingInfo2D
  2488. */
  2489. transform(matrix: Matrix): BoundingInfo2D;
  2490. /**
  2491. * Compute the union of this BoundingInfo2D with a given one, returns a new BoundingInfo2D as a result
  2492. * @param other the second BoundingInfo2D to compute the union with this one
  2493. * @return a new instance containing the result of the union
  2494. */
  2495. union(other: BoundingInfo2D): BoundingInfo2D;
  2496. private static _transform;
  2497. /**
  2498. * Transform this BoundingInfo2D with a given matrix and store the result in an existing BoundingInfo2D instance.
  2499. * This is a GC friendly version, try to use it as much as possible, specially if your transformation is inside a loop, allocate the result object once for good outside of the loop and use it every time.
  2500. * @param matrix The matrix to use to compute the transformation
  2501. * @param result A VALID (i.e. allocated) BoundingInfo2D object where the result will be stored
  2502. */
  2503. transformToRef(matrix: Matrix, result: BoundingInfo2D): void;
  2504. /**
  2505. * Compute the union of this BoundingInfo2D with another one and store the result in a third valid BoundingInfo2D object
  2506. * This is a GC friendly version, try to use it as much as possible, specially if your transformation is inside a loop, allocate the result object once for good outside of the loop and use it every time.
  2507. * @param other the second object used to compute the union
  2508. * @param result a VALID BoundingInfo2D instance (i.e. allocated) where the result will be stored
  2509. */
  2510. unionToRef(other: BoundingInfo2D, result: BoundingInfo2D): void;
  2511. /**
  2512. * Check if the given point is inside the BoundingInfo.
  2513. * The test is first made on the radius, then inside the rectangle described by the extent
  2514. * @param pickPosition the position to test
  2515. * @return true if the point is inside, false otherwise
  2516. */
  2517. doesIntersect(pickPosition: Vector2): boolean;
  2518. }
  2519. }
  2520. declare module BABYLON {
  2521. /**
  2522. * This interface is used to implement a lockable instance pattern.
  2523. * Classes that implements it may be locked at any time, making their content immutable from now on.
  2524. * You also can query if a given instance is locked or not.
  2525. * This allow instances to be shared among several 'consumers'.
  2526. */
  2527. interface ILockable {
  2528. /**
  2529. * Query the lock state
  2530. * @returns returns true if the object is locked and immutable, false if it's not
  2531. */
  2532. isLocked(): boolean;
  2533. /**
  2534. * A call to this method will definitely lock the instance, making its content immutable
  2535. * @returns the previous lock state of the object. so if true is returned the object were already locked and this method does nothing, if false is returned it means the object wasn't locked and this call locked it for good.
  2536. */
  2537. lock(): boolean;
  2538. }
  2539. /**
  2540. * This interface defines the IBrush2D contract.
  2541. * Classes implementing a new type of Brush2D must implement this interface
  2542. */
  2543. interface IBrush2D extends ILockable {
  2544. /**
  2545. * Define if the brush will use transparency / alpha blending
  2546. * @returns true if the brush use transparency
  2547. */
  2548. isTransparent(): boolean;
  2549. /**
  2550. * It is critical for each instance of a given Brush2D type to return a unique string that identifies it because the Border instance will certainly be part of the computed ModelKey for a given Primitive
  2551. * @returns A string identifier that uniquely identify the instance
  2552. */
  2553. toString(): string;
  2554. }
  2555. /**
  2556. * Base class implementing the ILocable interface.
  2557. * The particularity of this class is to call the protected onLock() method when the instance is about to be locked for good.
  2558. */
  2559. class LockableBase implements ILockable {
  2560. isLocked(): boolean;
  2561. private _isLocked;
  2562. lock(): boolean;
  2563. /**
  2564. * Protected handler that will be called when the instance is about to be locked.
  2565. */
  2566. protected onLock(): void;
  2567. }
  2568. class SolidColorBrush2D extends LockableBase implements IBrush2D {
  2569. constructor(color: Color4, lock?: boolean);
  2570. /**
  2571. * Return true if the brush is transparent, false if it's totally opaque
  2572. */
  2573. isTransparent(): boolean;
  2574. /**
  2575. * The color used by this instance to render
  2576. * @returns the color object. Note that it's not a clone of the actual object stored in the instance so you MUST NOT modify it, otherwise unexpected behavior might occurs.
  2577. */
  2578. color: Color4;
  2579. /**
  2580. * Return a unique identifier of the instance, which is simply the hexadecimal representation (CSS Style) of the solid color.
  2581. */
  2582. toString(): string;
  2583. private _color;
  2584. }
  2585. class GradientColorBrush2D extends LockableBase implements IBrush2D {
  2586. constructor(color1: Color4, color2: Color4, translation?: Vector2, rotation?: number, scale?: number, lock?: boolean);
  2587. /**
  2588. * Return true if the brush is transparent, false if it's totally opaque
  2589. */
  2590. isTransparent(): boolean;
  2591. /**
  2592. * First color, the blend will start from this color
  2593. */
  2594. color1: Color4;
  2595. /**
  2596. * Second color, the blend will end to this color
  2597. */
  2598. color2: Color4;
  2599. /**
  2600. * Translation vector to apply on the blend
  2601. * Default is [0;0]
  2602. */
  2603. translation: Vector2;
  2604. /**
  2605. * Rotation in radian to apply to the brush
  2606. * Default direction of the brush is vertical, you can change this using this property.
  2607. * Default is 0.
  2608. */
  2609. rotation: number;
  2610. /**
  2611. * Scale factor to apply to the gradient.
  2612. * Default is 1: no scale.
  2613. */
  2614. scale: number;
  2615. /**
  2616. * Return a string describing the brush
  2617. */
  2618. toString(): string;
  2619. /**
  2620. * Build a unique key string for the given parameters
  2621. */
  2622. static BuildKey(color1: Color4, color2: Color4, translation: Vector2, rotation: number, scale: number): string;
  2623. private _color1;
  2624. private _color2;
  2625. private _translation;
  2626. private _rotation;
  2627. private _scale;
  2628. }
  2629. }
  2630. declare module BABYLON {
  2631. class Canvas2DEngineBoundData {
  2632. GetOrAddModelCache<TInstData>(key: string, factory: (key: string) => ModelRenderCache): ModelRenderCache;
  2633. private _modelCache;
  2634. DisposeModelRenderCache(modelRenderCache: ModelRenderCache): boolean;
  2635. }
  2636. abstract class Canvas2D extends Group2D {
  2637. /**
  2638. * In this strategy only the direct children groups of the Canvas will be cached, their whole content (whatever the sub groups they have) into a single bitmap.
  2639. * This strategy doesn't allow primitives added directly as children of the Canvas.
  2640. * You typically want to use this strategy of a screenSpace fullscreen canvas: you don't want a bitmap cache taking the whole screen resolution but still want the main contents (say UI in the topLeft and rightBottom for instance) to be efficiently cached.
  2641. */
  2642. static CACHESTRATEGY_TOPLEVELGROUPS: number;
  2643. /**
  2644. * In this strategy each group will have its own cache bitmap (except if a given group explicitly defines the DONTCACHEOVERRIDE or CACHEINPARENTGROUP behaviors).
  2645. * This strategy is typically used if the canvas has some groups that are frequently animated. Unchanged ones will have a steady cache and the others will be refreshed when they change, reducing the redraw operation count to their content only.
  2646. * When using this strategy, group instances can rely on the DONTCACHEOVERRIDE or CACHEINPARENTGROUP behaviors to minimize the amount of cached bitmaps.
  2647. * Note that in this mode the Canvas itself is not cached, it only contains the sprites of its direct children group to render, there's no point to cache the whole canvas, sprites will be rendered pretty efficiently, the memory cost would be too great for the value of it.
  2648. */
  2649. static CACHESTRATEGY_ALLGROUPS: number;
  2650. /**
  2651. * In this strategy the whole canvas is cached into a single bitmap containing every primitives it owns, at the exception of the ones that are owned by a group having the DONTCACHEOVERRIDE behavior (these primitives will be directly drawn to the viewport at each render for screenSpace Canvas or be part of the Canvas cache bitmap for worldSpace Canvas).
  2652. */
  2653. static CACHESTRATEGY_CANVAS: number;
  2654. /**
  2655. * This strategy is used to recompose/redraw the canvas entirely at each viewport render.
  2656. * Use this strategy if memory is a concern above rendering performances and/or if the canvas is frequently animated (hence reducing the benefits of caching).
  2657. * Note that you can't use this strategy for WorldSpace Canvas, they need at least a top level group caching.
  2658. */
  2659. static CACHESTRATEGY_DONTCACHE: number;
  2660. constructor(scene: Scene, settings?: {
  2661. id?: string;
  2662. children?: Array<Prim2DBase>;
  2663. size?: Size;
  2664. isScreenSpace?: boolean;
  2665. cachingStrategy?: number;
  2666. enableInteraction?: boolean;
  2667. origin?: Vector2;
  2668. isVisible?: boolean;
  2669. backgroundRoundRadius?: number;
  2670. backgroundFill?: IBrush2D | string;
  2671. backgroundBorder?: IBrush2D | string;
  2672. backgroundBorderThickNess?: number;
  2673. });
  2674. drawCallsOpaqueCounter: PerfCounter;
  2675. drawCallsAlphaTestCounter: PerfCounter;
  2676. drawCallsTransparentCounter: PerfCounter;
  2677. groupRenderCounter: PerfCounter;
  2678. updateTransparentDataCounter: PerfCounter;
  2679. cachedGroupRenderCounter: PerfCounter;
  2680. updateCachedStateCounter: PerfCounter;
  2681. updateLayoutCounter: PerfCounter;
  2682. updatePositioningCounter: PerfCounter;
  2683. updateLocalTransformCounter: PerfCounter;
  2684. updateGlobalTransformCounter: PerfCounter;
  2685. boundingInfoRecomputeCounter: PerfCounter;
  2686. protected _canvasPreInit(settings: any): void;
  2687. static _zMinDelta: number;
  2688. private _setupInteraction(enable);
  2689. /**
  2690. * If you set your own WorldSpaceNode to display the Canvas2D you have to provide your own implementation of this method which computes the local position in the Canvas based on the given 3D World one.
  2691. * Beware that you have to take under consideration the origin in your calculations! Good luck!
  2692. */
  2693. worldSpaceToNodeLocal: (worldPos: Vector3) => Vector2;
  2694. /**
  2695. * If you use a custom WorldSpaceCanvasNode you have to override this property to update the UV of your object to reflect the changes due to a resizing of the cached bitmap
  2696. */
  2697. worldSpaceCacheChanged: () => void;
  2698. /**
  2699. * Internal method, you should use the Prim2DBase version instead
  2700. */
  2701. _setPointerCapture(pointerId: number, primitive: Prim2DBase): boolean;
  2702. /**
  2703. * Internal method, you should use the Prim2DBase version instead
  2704. */
  2705. _releasePointerCapture(pointerId: number, primitive: Prim2DBase): boolean;
  2706. /**
  2707. * Determine if the given pointer is captured or not
  2708. * @param pointerId the Id of the pointer
  2709. * @return true if it's captured, false otherwise
  2710. */
  2711. isPointerCaptured(pointerId: number): boolean;
  2712. private getCapturedPrimitive(pointerId);
  2713. private static _interInfo;
  2714. private _handlePointerEventForInteraction(eventData, localPosition, eventState);
  2715. private _updatePointerInfo(eventData, localPosition);
  2716. private _updateIntersectionList(mouseLocalPos, isCapture);
  2717. private _updateOverStatus();
  2718. private _updatePrimPointerPos(prim);
  2719. private _notifDebugMode;
  2720. private _debugExecObserver(prim, mask);
  2721. private _bubbleNotifyPrimPointerObserver(prim, mask, eventData);
  2722. private _triggerActionManager(prim, ppi, mask, eventData);
  2723. _notifParents(prim: Prim2DBase, mask: number): void;
  2724. /**
  2725. * Don't forget to call the dispose method when you're done with the Canvas instance.
  2726. * But don't worry, if you dispose its scene, the canvas will be automatically disposed too.
  2727. */
  2728. dispose(): boolean;
  2729. /**
  2730. * Accessor to the Scene that owns the Canvas
  2731. * @returns The instance of the Scene object
  2732. */
  2733. scene: Scene;
  2734. /**
  2735. * Accessor to the Engine that drives the Scene used by this Canvas
  2736. * @returns The instance of the Engine object
  2737. */
  2738. engine: Engine;
  2739. /**
  2740. * Accessor of the Caching Strategy used by this Canvas.
  2741. * See Canvas2D.CACHESTRATEGY_xxxx static members for more information
  2742. * @returns the value corresponding to the used strategy.
  2743. */
  2744. cachingStrategy: number;
  2745. /**
  2746. * Return true if the Canvas is a Screen Space one, false if it's a World Space one.
  2747. * @returns {}
  2748. */
  2749. isScreenSpace: boolean;
  2750. /**
  2751. * Only valid for World Space Canvas, returns the scene node that displays the canvas
  2752. */
  2753. worldSpaceCanvasNode: Node;
  2754. /**
  2755. * Check if the WebGL Instanced Array extension is supported or not
  2756. */
  2757. supportInstancedArray: boolean;
  2758. /**
  2759. * Property that defines the fill object used to draw the background of the Canvas.
  2760. * Note that Canvas with a Caching Strategy of
  2761. * @returns If the background is not set, null will be returned, otherwise a valid fill object is returned.
  2762. */
  2763. backgroundFill: IBrush2D;
  2764. /**
  2765. * Property that defines the border object used to draw the background of the Canvas.
  2766. * @returns If the background is not set, null will be returned, otherwise a valid border object is returned.
  2767. */
  2768. backgroundBorder: IBrush2D;
  2769. /**
  2770. * Property that defines the thickness of the border object used to draw the background of the Canvas.
  2771. * @returns If the background is not set, null will be returned, otherwise a valid number matching the thickness is returned.
  2772. */
  2773. backgroundBorderThickness: number;
  2774. /**
  2775. * You can set the roundRadius of the background
  2776. * @returns The current roundRadius
  2777. */
  2778. backgroundRoundRadius: number;
  2779. /**
  2780. * Enable/Disable interaction for this Canvas
  2781. * When enabled the Prim2DBase.pointerEventObservable property will notified when appropriate events occur
  2782. */
  2783. interactionEnabled: boolean;
  2784. /**
  2785. * Access the babylon.js' engine bound data, do not invoke this method, it's for internal purpose only
  2786. * @returns {}
  2787. */
  2788. _engineData: Canvas2DEngineBoundData;
  2789. createCanvasProfileInfoCanvas(): Canvas2D;
  2790. private checkBackgroundAvailability();
  2791. private _initPerfMetrics();
  2792. private _fetchPerfMetrics();
  2793. private _updateProfileCanvas();
  2794. _addDrawCallCount(count: number, renderMode: number): void;
  2795. _addGroupRenderCount(count: number): void;
  2796. _addUpdateTransparentDataCount(count: number): void;
  2797. addCachedGroupRenderCounter(count: number): void;
  2798. addUpdateCachedStateCounter(count: number): void;
  2799. addUpdateLayoutCounter(count: number): void;
  2800. addUpdatePositioningCounter(count: number): void;
  2801. addupdateLocalTransformCounter(count: number): void;
  2802. addUpdateGlobalTransformCounter(count: number): void;
  2803. private __engineData;
  2804. private _interactionEnabled;
  2805. private _primPointerInfo;
  2806. private _updateRenderId;
  2807. private _intersectionRenderId;
  2808. private _hoverStatusRenderId;
  2809. private _pickStartingPosition;
  2810. private _pickedDownPrim;
  2811. private _pickStartingTime;
  2812. private _previousIntersectionList;
  2813. private _actualIntersectionList;
  2814. private _previousOverPrimitive;
  2815. private _actualOverPrimitive;
  2816. private _capturedPointers;
  2817. private _scenePrePointerObserver;
  2818. private _scenePointerObserver;
  2819. protected _worldSpaceNode: Node;
  2820. private _mapCounter;
  2821. private _background;
  2822. private _scene;
  2823. private _engine;
  2824. private _fitRenderingDevice;
  2825. private _isScreenSpace;
  2826. private _cachedCanvasGroup;
  2827. private _cachingStrategy;
  2828. private _hierarchyLevelMaxSiblingCount;
  2829. private _groupCacheMaps;
  2830. private _beforeRenderObserver;
  2831. private _afterRenderObserver;
  2832. private _supprtInstancedArray;
  2833. private _trackedGroups;
  2834. protected _maxAdaptiveWorldSpaceCanvasSize: number;
  2835. _renderingSize: Size;
  2836. private _drawCallsOpaqueCounter;
  2837. private _drawCallsAlphaTestCounter;
  2838. private _drawCallsTransparentCounter;
  2839. private _groupRenderCounter;
  2840. private _updateTransparentDataCounter;
  2841. private _cachedGroupRenderCounter;
  2842. private _updateCachedStateCounter;
  2843. private _updateLayoutCounter;
  2844. private _updatePositioningCounter;
  2845. private _updateGlobalTransformCounter;
  2846. private _updateLocalTransformCounter;
  2847. private _boundingInfoRecomputeCounter;
  2848. private _profileInfoText;
  2849. protected onPrimBecomesDirty(): void;
  2850. private static _v;
  2851. private static _m;
  2852. private static _mI;
  2853. private _updateTrackedNodes();
  2854. /**
  2855. * Call this method change you want to have layout related data computed and up to date (layout area, primitive area, local/global transformation matrices)
  2856. */
  2857. updateCanvasLayout(forceRecompute: boolean): void;
  2858. private _updateAdaptiveSizeWorldCanvas();
  2859. private _updateCanvasState(forceRecompute);
  2860. /**
  2861. * Method that renders the Canvas, you should not invoke
  2862. */
  2863. private _render();
  2864. /**
  2865. * Internal method that allocate a cache for the given group.
  2866. * Caching is made using a collection of MapTexture where many groups have their bitmap cache stored inside.
  2867. * @param group The group to allocate the cache of.
  2868. * @return custom type with the PackedRect instance giving information about the cache location into the texture and also the MapTexture instance that stores the cache.
  2869. */
  2870. _allocateGroupCache(group: Group2D, parent: Group2D, minSize?: Size, useMipMap?: boolean, anisotropicLevel?: number): {
  2871. node: PackedRect;
  2872. texture: MapTexture;
  2873. sprite: Sprite2D;
  2874. };
  2875. /**
  2876. * Define the default size used for both the width and height of a MapTexture to allocate.
  2877. * Note that some MapTexture might be bigger than this size if the first node to allocate is bigger in width or height
  2878. */
  2879. private static _groupTextureCacheSize;
  2880. /**
  2881. * Internal method used to register a Scene Node to track position for the given group
  2882. * Do not invoke this method, for internal purpose only.
  2883. * @param group the group to track its associated Scene Node
  2884. */
  2885. _registerTrackedNode(group: Group2D): void;
  2886. /**
  2887. * Internal method used to unregister a tracked Scene Node
  2888. * Do not invoke this method, it's for internal purpose only.
  2889. * @param group the group to unregister its tracked Scene Node from.
  2890. */
  2891. _unregisterTrackedNode(group: Group2D): void;
  2892. /**
  2893. * Get a Solid Color Brush instance matching the given color.
  2894. * @param color The color to retrieve
  2895. * @return A shared instance of the SolidColorBrush2D class that use the given color
  2896. */
  2897. static GetSolidColorBrush(color: Color4): IBrush2D;
  2898. /**
  2899. * Get a Solid Color Brush instance matching the given color expressed as a CSS formatted hexadecimal value.
  2900. * @param color The color to retrieve
  2901. * @return A shared instance of the SolidColorBrush2D class that uses the given color
  2902. */
  2903. static GetSolidColorBrushFromHex(hexValue: string): IBrush2D;
  2904. /**
  2905. * Get a Gradient Color Brush
  2906. * @param color1 starting color
  2907. * @param color2 engine color
  2908. * @param translation translation vector to apply. default is [0;0]
  2909. * @param rotation rotation in radian to apply to the brush, initial direction is top to bottom. rotation is counter clockwise. default is 0.
  2910. * @param scale scaling factor to apply. default is 1.
  2911. */
  2912. static GetGradientColorBrush(color1: Color4, color2: Color4, translation?: Vector2, rotation?: number, scale?: number): IBrush2D;
  2913. /**
  2914. * Create a solid or gradient brush from a string value.
  2915. * @param brushString should be either
  2916. * - "solid: #RRGGBBAA" or "#RRGGBBAA"
  2917. * - "gradient: #FF808080, #FFFFFFF[, [10:20], 180, 1]" for color1, color2, translation, rotation (degree), scale. The last three are optionals, but if specified must be is this order. "gradient:" can be omitted.
  2918. */
  2919. static GetBrushFromString(brushString: string): IBrush2D;
  2920. private static _solidColorBrushes;
  2921. private static _gradientColorBrushes;
  2922. }
  2923. class WorldSpaceCanvas2D extends Canvas2D {
  2924. /**
  2925. * Create a new 2D WorldSpace Rendering Canvas, it is a 2D rectangle that has a size (width/height) and a world transformation information to place it in the world space.
  2926. * This kind of canvas can't have its Primitives directly drawn in the Viewport, they need to be cached in a bitmap at some point, as a consequence the DONT_CACHE strategy is unavailable. For now only CACHESTRATEGY_CANVAS is supported, but the remaining strategies will be soon.
  2927. * @param scene the Scene that owns the Canvas
  2928. * @param size the dimension of the Canvas in World Space
  2929. * @param settings a combination of settings, possible ones are
  2930. * - children: an array of direct children primitives
  2931. * - id: a text identifier, for information purpose only, default is null.
  2932. * - worldPosition the position of the Canvas in World Space, default is [0,0,0]
  2933. * - worldRotation the rotation of the Canvas in World Space, default is Quaternion.Identity()
  2934. * - sideOrientation: Unexpected behavior occur if the value is different from Mesh.DEFAULTSIDE right now, so please use this one, which is the default.
  2935. * - cachingStrategy Must be CACHESTRATEGY_CANVAS for now, which is the default.
  2936. * - enableInteraction: if true the pointer events will be listened and rerouted to the appropriate primitives of the Canvas2D through the Prim2DBase.onPointerEventObservable observable property. Default is false (the opposite of ScreenSpace).
  2937. * - isVisible: true if the canvas must be visible, false for hidden. Default is true.
  2938. * - backgroundRoundRadius: the round radius of the background, either backgroundFill or backgroundBorder must be specified.
  2939. * - backgroundFill: the brush to use to create a background fill for the canvas. can be a string value (see Canvas2D.GetBrushFromString) or a IBrush2D instance.
  2940. * - backgroundBorder: the brush to use to create a background border for the canvas. can be a string value (see Canvas2D.GetBrushFromString) or a IBrush2D instance.
  2941. * - backgroundBorderThickness: if a backgroundBorder is specified, its thickness can be set using this property
  2942. * - customWorldSpaceNode: if specified the Canvas will be rendered in this given Node. But it's the responsibility of the caller to set the "worldSpaceToNodeLocal" property to compute the hit of the mouse ray into the node (in world coordinate system) as well as rendering the cached bitmap in the node itself. The properties cachedRect and cachedTexture of Group2D will give you what you need to do that.
  2943. * - maxAdaptiveCanvasSize: set the max size (width and height) of the bitmap that will contain the cached version of the WorldSpace Canvas. Default is 1024 or less if it's not supported. In any case the value you give will be clipped by the maximum that WebGL supports on the running device. You can set any size, more than 1024 if you want, but testing proved it's a good max value for non "retina" like screens.
  2944. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  2945. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  2946. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  2947. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  2948. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  2949. */
  2950. constructor(scene: Scene, size: Size, settings?: {
  2951. children?: Array<Prim2DBase>;
  2952. id?: string;
  2953. worldPosition?: Vector3;
  2954. worldRotation?: Quaternion;
  2955. sideOrientation?: number;
  2956. cachingStrategy?: number;
  2957. enableInteraction?: boolean;
  2958. isVisible?: boolean;
  2959. backgroundRoundRadius?: number;
  2960. backgroundFill?: IBrush2D | string;
  2961. backgroundBorder?: IBrush2D | string;
  2962. backgroundBorderThickNess?: number;
  2963. customWorldSpaceNode?: Node;
  2964. maxAdaptiveCanvasSize?: number;
  2965. paddingTop?: number | string;
  2966. paddingLeft?: number | string;
  2967. paddingRight?: number | string;
  2968. paddingBottom?: number | string;
  2969. padding?: string;
  2970. });
  2971. }
  2972. class ScreenSpaceCanvas2D extends Canvas2D {
  2973. /**
  2974. * Create a new 2D ScreenSpace Rendering Canvas, it is a 2D rectangle that has a size (width/height) and a position relative to the bottom/left corner of the screen.
  2975. * ScreenSpace Canvas will be drawn in the Viewport as a 2D Layer lying to the top of the 3D Scene. Typically used for traditional UI.
  2976. * All caching strategies will be available.
  2977. * PLEASE NOTE: the origin of a Screen Space Canvas is set to [0;0] (bottom/left) which is different than the default origin of a Primitive which is centered [0.5;0.5]
  2978. * @param scene the Scene that owns the Canvas
  2979. * @param settings a combination of settings, possible ones are
  2980. * - children: an array of direct children primitives
  2981. * - id: a text identifier, for information purpose only
  2982. * - x: the position along the x axis (horizontal), relative to the left edge of the viewport. you can alternatively use the position setting.
  2983. * - y: the position along the y axis (vertically), relative to the bottom edge of the viewport. you can alternatively use the position setting.
  2984. * - position: the position of the canvas, relative from the bottom/left of the scene's viewport. Alternatively you can set the x and y properties directly. Default value is [0, 0]
  2985. * - width: the width of the Canvas. you can alternatively use the size setting.
  2986. * - height: the height of the Canvas. you can alternatively use the size setting.
  2987. * - size: the Size of the canvas. Alternatively the width and height properties can be set. If null two behaviors depend on the cachingStrategy: if it's CACHESTRATEGY_CACHECANVAS then it will always auto-fit the rendering device, in all the other modes it will fit the content of the Canvas
  2988. * - cachingStrategy: either CACHESTRATEGY_TOPLEVELGROUPS, CACHESTRATEGY_ALLGROUPS, CACHESTRATEGY_CANVAS, CACHESTRATEGY_DONTCACHE. Please refer to their respective documentation for more information. Default is Canvas2D.CACHESTRATEGY_DONTCACHE
  2989. * - enableInteraction: if true the pointer events will be listened and rerouted to the appropriate primitives of the Canvas2D through the Prim2DBase.onPointerEventObservable observable property. Default is true.
  2990. * - isVisible: true if the canvas must be visible, false for hidden. Default is true.
  2991. * - backgroundRoundRadius: the round radius of the background, either backgroundFill or backgroundBorder must be specified.
  2992. * - backgroundFill: the brush to use to create a background fill for the canvas. can be a string value (see BABYLON.Canvas2D.GetBrushFromString) or a IBrush2D instance.
  2993. * - backgroundBorder: the brush to use to create a background border for the canvas. can be a string value (see BABYLON.Canvas2D.GetBrushFromString) or a IBrush2D instance.
  2994. * - backgroundBorderThickness: if a backgroundBorder is specified, its thickness can be set using this property
  2995. * - customWorldSpaceNode: if specified the Canvas will be rendered in this given Node. But it's the responsibility of the caller to set the "worldSpaceToNodeLocal" property to compute the hit of the mouse ray into the node (in world coordinate system) as well as rendering the cached bitmap in the node itself. The properties cachedRect and cachedTexture of Group2D will give you what you need to do that.
  2996. * - paddingTop: top padding, can be a number (will be pixels) or a string (see BABYLON.PrimitiveThickness.fromString)
  2997. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see BABYLON.PrimitiveThickness.fromString)
  2998. * - paddingRight: right padding, can be a number (will be pixels) or a string (see BABYLON.PrimitiveThickness.fromString)
  2999. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see BABYLON.PrimitiveThickness.fromString)
  3000. * - padding: top, left, right and bottom padding formatted as a single string (see BABYLON.PrimitiveThickness.fromString)
  3001. */
  3002. constructor(scene: Scene, settings?: {
  3003. children?: Array<Prim2DBase>;
  3004. id?: string;
  3005. x?: number;
  3006. y?: number;
  3007. position?: Vector2;
  3008. origin?: Vector2;
  3009. width?: number;
  3010. height?: number;
  3011. size?: Size;
  3012. cachingStrategy?: number;
  3013. enableInteraction?: boolean;
  3014. isVisible?: boolean;
  3015. backgroundRoundRadius?: number;
  3016. backgroundFill?: IBrush2D | string;
  3017. backgroundBorder?: IBrush2D | string;
  3018. backgroundBorderThickNess?: number;
  3019. paddingTop?: number | string;
  3020. paddingLeft?: number | string;
  3021. paddingRight?: number | string;
  3022. paddingBottom?: number | string;
  3023. padding?: string;
  3024. });
  3025. }
  3026. }
  3027. declare module BABYLON {
  3028. class LayoutEngineBase implements ILockable {
  3029. constructor();
  3030. updateLayout(prim: Prim2DBase): void;
  3031. isChildPositionAllowed: boolean;
  3032. isLocked(): boolean;
  3033. lock(): boolean;
  3034. layoutDirtyOnPropertyChangedMask: any;
  3035. private _isLocked;
  3036. }
  3037. class CanvasLayoutEngine extends LayoutEngineBase {
  3038. static Singleton: CanvasLayoutEngine;
  3039. updateLayout(prim: Prim2DBase): void;
  3040. private _doUpdate(prim);
  3041. isChildPositionAllowed: boolean;
  3042. }
  3043. class StackPanelLayoutEngine extends LayoutEngineBase {
  3044. constructor();
  3045. static Horizontal: StackPanelLayoutEngine;
  3046. static Vertical: StackPanelLayoutEngine;
  3047. private static _horizontal;
  3048. private static _vertical;
  3049. isHorizontal: boolean;
  3050. private _isHorizontal;
  3051. updateLayout(prim: Prim2DBase): void;
  3052. isChildPositionAllowed: boolean;
  3053. }
  3054. }
  3055. declare module BABYLON {
  3056. class Ellipse2DRenderCache extends ModelRenderCache {
  3057. effectsReady: boolean;
  3058. fillVB: WebGLBuffer;
  3059. fillIB: WebGLBuffer;
  3060. fillIndicesCount: number;
  3061. instancingFillAttributes: InstancingAttributeInfo[];
  3062. effectFillInstanced: Effect;
  3063. effectFill: Effect;
  3064. borderVB: WebGLBuffer;
  3065. borderIB: WebGLBuffer;
  3066. borderIndicesCount: number;
  3067. instancingBorderAttributes: InstancingAttributeInfo[];
  3068. effectBorderInstanced: Effect;
  3069. effectBorder: Effect;
  3070. constructor(engine: Engine, modelKey: string);
  3071. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  3072. dispose(): boolean;
  3073. }
  3074. class Ellipse2DInstanceData extends Shape2DInstanceData {
  3075. constructor(partId: number);
  3076. properties: Vector3;
  3077. }
  3078. class Ellipse2D extends Shape2D {
  3079. static acutalSizeProperty: Prim2DPropInfo;
  3080. static subdivisionsProperty: Prim2DPropInfo;
  3081. actualSize: Size;
  3082. subdivisions: number;
  3083. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  3084. protected updateLevelBoundingInfo(): void;
  3085. /**
  3086. * Create an Ellipse 2D Shape primitive
  3087. * @param settings a combination of settings, possible ones are
  3088. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  3089. * - children: an array of direct children
  3090. * - id: a text identifier, for information purpose
  3091. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  3092. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  3093. * - scale: the initial scale of the primitive. default is 1
  3094. * - origin: define the normalized origin point location, default [0.5;0.5]
  3095. * - size: the size of the group. Alternatively the width and height properties can be set. Default will be [10;10].
  3096. * - subdivision: the number of subdivision to create the ellipse perimeter, default is 64.
  3097. * - fill: the brush used to draw the fill content of the ellipse, you can set null to draw nothing (but you will have to set a border brush), default is a SolidColorBrush of plain white. can also be a string value (see Canvas2D.GetBrushFromString)
  3098. * - border: the brush used to draw the border of the ellipse, you can set null to draw nothing (but you will have to set a fill brush), default is null. can be a string value (see Canvas2D.GetBrushFromString)
  3099. * - borderThickness: the thickness of the drawn border, default is 1.
  3100. * - isVisible: true if the group must be visible, false for hidden. Default is true.
  3101. * - childrenFlatZOrder: if true all the children (direct and indirect) will share the same Z-Order. Use this when there's a lot of children which don't overlap. The drawing order IS NOT GUARANTED!
  3102. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3103. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3104. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3105. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3106. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  3107. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  3108. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  3109. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  3110. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3111. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3112. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3113. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3114. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  3115. */
  3116. constructor(settings?: {
  3117. parent?: Prim2DBase;
  3118. children?: Array<Prim2DBase>;
  3119. id?: string;
  3120. position?: Vector2;
  3121. x?: number;
  3122. y?: number;
  3123. rotation?: number;
  3124. scale?: number;
  3125. origin?: Vector2;
  3126. size?: Size;
  3127. width?: number;
  3128. height?: number;
  3129. subdivisions?: number;
  3130. fill?: IBrush2D | string;
  3131. border?: IBrush2D | string;
  3132. borderThickness?: number;
  3133. isVisible?: boolean;
  3134. childrenFlatZOrder?: boolean;
  3135. marginTop?: number | string;
  3136. marginLeft?: number | string;
  3137. marginRight?: number | string;
  3138. marginBottom?: number | string;
  3139. margin?: number | string;
  3140. marginHAlignment?: number;
  3141. marginVAlignment?: number;
  3142. marginAlignment?: string;
  3143. paddingTop?: number | string;
  3144. paddingLeft?: number | string;
  3145. paddingRight?: number | string;
  3146. paddingBottom?: number | string;
  3147. padding?: string;
  3148. });
  3149. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  3150. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Ellipse2DRenderCache;
  3151. protected createInstanceDataParts(): InstanceDataBase[];
  3152. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  3153. private _subdivisions;
  3154. }
  3155. }
  3156. declare module BABYLON {
  3157. class Group2D extends Prim2DBase {
  3158. static GROUP2D_PROPCOUNT: number;
  3159. static sizeProperty: Prim2DPropInfo;
  3160. static actualSizeProperty: Prim2DPropInfo;
  3161. /**
  3162. * Default behavior, the group will use the caching strategy defined at the Canvas Level
  3163. */
  3164. static GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY: number;
  3165. /**
  3166. * When used, this group's content won't be cached, no matter which strategy used.
  3167. * If the group is part of a WorldSpace Canvas, its content will be drawn in the Canvas cache bitmap.
  3168. */
  3169. static GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE: number;
  3170. /**
  3171. * When used, the group's content will be cached in the nearest cached parent group/canvas
  3172. */
  3173. static GROUPCACHEBEHAVIOR_CACHEINPARENTGROUP: number;
  3174. /**
  3175. * Create an Logical or Renderable Group.
  3176. * @param settings a combination of settings, possible ones are
  3177. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  3178. * - children: an array of direct children
  3179. * - id a text identifier, for information purpose
  3180. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  3181. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  3182. * - scale: the initial scale of the primitive. default is 1
  3183. * - origin: define the normalized origin point location, default [0.5;0.5]
  3184. * - size: the size of the group. Alternatively the width and height properties can be set. If null the size will be computed from its content, default is null.
  3185. * - cacheBehavior: Define how the group should behave regarding the Canvas's cache strategy, default is Group2D.GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY
  3186. * - layoutEngine: either an instance of a layout engine based class (StackPanel.Vertical, StackPanel.Horizontal) or a string ('canvas' for Canvas layout, 'StackPanel' or 'HorizontalStackPanel' for horizontal Stack Panel layout, 'VerticalStackPanel' for vertical Stack Panel layout).
  3187. * - isVisible: true if the group must be visible, false for hidden. Default is true.
  3188. * - childrenFlatZOrder: if true all the children (direct and indirect) will share the same Z-Order. Use this when there's a lot of children which don't overlap. The drawing order IS NOT GUARANTED!
  3189. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3190. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3191. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3192. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3193. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  3194. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  3195. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  3196. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  3197. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3198. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3199. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3200. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3201. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  3202. */
  3203. constructor(settings?: {
  3204. parent?: Prim2DBase;
  3205. children?: Array<Prim2DBase>;
  3206. id?: string;
  3207. position?: Vector2;
  3208. x?: number;
  3209. y?: number;
  3210. trackNode?: Node;
  3211. origin?: Vector2;
  3212. size?: Size;
  3213. width?: number;
  3214. height?: number;
  3215. cacheBehavior?: number;
  3216. layoutEngine?: LayoutEngineBase | string;
  3217. isVisible?: boolean;
  3218. childrenFlatZOrder?: boolean;
  3219. marginTop?: number | string;
  3220. marginLeft?: number | string;
  3221. marginRight?: number | string;
  3222. marginBottom?: number | string;
  3223. margin?: number | string;
  3224. marginHAlignment?: number;
  3225. marginVAlignment?: number;
  3226. marginAlignment?: string;
  3227. paddingTop?: number | string;
  3228. paddingLeft?: number | string;
  3229. paddingRight?: number | string;
  3230. paddingBottom?: number | string;
  3231. padding?: string;
  3232. });
  3233. static _createCachedCanvasGroup(owner: Canvas2D): Group2D;
  3234. protected applyCachedTexture(vertexData: VertexData, material: StandardMaterial): void;
  3235. /**
  3236. * Allow you to access the information regarding the cached rectangle of the Group2D into the MapTexture.
  3237. * If the `noWorldSpaceNode` options was used at the creation of a WorldSpaceCanvas, the rendering of the canvas must be made by the caller, so typically you want to bind the cacheTexture property to some material/mesh and you MUST use the Group2D.cachedUVs property to get the UV coordinates to use for your quad that will display the Canvas and NOT the PackedRect.UVs property which are incorrect because the allocated surface may be bigger (due to over-provisioning or shrinking without deallocating) than what the Group is actually using.
  3238. */
  3239. cachedRect: PackedRect;
  3240. /**
  3241. * The UVs into the MapTexture that map the cached group
  3242. */
  3243. cachedUVs: Vector2[];
  3244. cachedUVsChanged: Observable<Vector2[]>;
  3245. /**
  3246. * Access the texture that maintains a cached version of the Group2D.
  3247. * This is useful only if you're not using a WorldSpaceNode for your WorldSpace Canvas and therefore need to perform the rendering yourself.
  3248. */
  3249. cacheTexture: MapTexture;
  3250. /**
  3251. * Call this method to remove this Group and its children from the Canvas
  3252. */
  3253. dispose(): boolean;
  3254. /**
  3255. * @returns Returns true if the Group render content, false if it's a logical group only
  3256. */
  3257. isRenderableGroup: boolean;
  3258. /**
  3259. * @returns only meaningful for isRenderableGroup, will be true if the content of the Group is cached into a texture, false if it's rendered every time
  3260. */
  3261. isCachedGroup: boolean;
  3262. /**
  3263. * Get/Set the size of the group. If null the size of the group will be determine from its content.
  3264. * BEWARE: if the Group is a RenderableGroup and its content is cache the texture will be resized each time the group is getting bigger. For performance reason the opposite won't be true: the texture won't shrink if the group does.
  3265. */
  3266. size: Size;
  3267. viewportSize: ISize;
  3268. actualSize: Size;
  3269. /**
  3270. * Get/set the Cache Behavior, used in case the Canvas Cache Strategy is set to CACHESTRATEGY_ALLGROUPS. Can be either GROUPCACHEBEHAVIOR_CACHEINPARENTGROUP, GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE or GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY. See their documentation for more information.
  3271. * It is critical to understand than you HAVE TO play with this behavior in order to achieve a good performance/memory ratio. Caching all groups would certainly be the worst strategy of all.
  3272. */
  3273. cacheBehavior: number;
  3274. _addPrimToDirtyList(prim: Prim2DBase): void;
  3275. _renderCachedCanvas(): void;
  3276. /**
  3277. * Get/set the Scene's Node that should be tracked, the group's position will follow the projected position of the Node.
  3278. */
  3279. trackedNode: Node;
  3280. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  3281. protected updateLevelBoundingInfo(): void;
  3282. protected _prepareGroupRender(context: PrepareRender2DContext): void;
  3283. protected _groupRender(): void;
  3284. private _updateTransparentData();
  3285. private _renderTransparentData();
  3286. private _prepareContext(engine, context, gii);
  3287. protected _setRenderingScale(scale: number): void;
  3288. private static _s;
  3289. private _bindCacheTarget();
  3290. private _unbindCacheTarget();
  3291. protected handleGroupChanged(prop: Prim2DPropInfo): void;
  3292. private detectGroupStates();
  3293. private _trackedNode;
  3294. protected _isRenderableGroup: boolean;
  3295. protected _isCachedGroup: boolean;
  3296. private _cacheGroupDirty;
  3297. private _cacheBehavior;
  3298. private _viewportPosition;
  3299. private _viewportSize;
  3300. _renderableData: RenderableGroupData;
  3301. }
  3302. class RenderableGroupData {
  3303. constructor();
  3304. dispose(): void;
  3305. addNewTransparentPrimitiveInfo(prim: RenderablePrim2D, gii: GroupInstanceInfo): TransparentPrimitiveInfo;
  3306. removeTransparentPrimitiveInfo(tpi: TransparentPrimitiveInfo): void;
  3307. transparentPrimitiveZChanged(tpi: TransparentPrimitiveInfo): void;
  3308. updateSmallestZChangedPrim(tpi: TransparentPrimitiveInfo): void;
  3309. _primDirtyList: Array<Prim2DBase>;
  3310. _childrenRenderableGroups: Array<Group2D>;
  3311. _renderGroupInstancesInfo: StringDictionary<GroupInstanceInfo>;
  3312. _cacheNode: PackedRect;
  3313. _cacheTexture: MapTexture;
  3314. _cacheRenderSprite: Sprite2D;
  3315. _cacheNodeUVs: Vector2[];
  3316. _cacheNodeUVsChangedObservable: Observable<Vector2[]>;
  3317. _cacheSize: Size;
  3318. _useMipMap: boolean;
  3319. _anisotropicLevel: number;
  3320. _transparentListChanged: boolean;
  3321. _transparentPrimitives: Array<TransparentPrimitiveInfo>;
  3322. _transparentSegments: Array<TransparentSegment>;
  3323. _firstChangedPrim: TransparentPrimitiveInfo;
  3324. _renderingScale: number;
  3325. }
  3326. class TransparentPrimitiveInfo {
  3327. _primitive: RenderablePrim2D;
  3328. _groupInstanceInfo: GroupInstanceInfo;
  3329. _transparentSegment: TransparentSegment;
  3330. }
  3331. }
  3332. declare module BABYLON {
  3333. class Lines2DRenderCache extends ModelRenderCache {
  3334. effectsReady: boolean;
  3335. fillVB: WebGLBuffer;
  3336. fillIB: WebGLBuffer;
  3337. fillIndicesCount: number;
  3338. instancingFillAttributes: InstancingAttributeInfo[];
  3339. effectFill: Effect;
  3340. effectFillInstanced: Effect;
  3341. borderVB: WebGLBuffer;
  3342. borderIB: WebGLBuffer;
  3343. borderIndicesCount: number;
  3344. instancingBorderAttributes: InstancingAttributeInfo[];
  3345. effectBorder: Effect;
  3346. effectBorderInstanced: Effect;
  3347. constructor(engine: Engine, modelKey: string);
  3348. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  3349. dispose(): boolean;
  3350. }
  3351. class Lines2DInstanceData extends Shape2DInstanceData {
  3352. constructor(partId: number);
  3353. boundingMin: Vector2;
  3354. boundingMax: Vector2;
  3355. }
  3356. class Lines2D extends Shape2D {
  3357. /**
  3358. * No Cap to apply on the extremity
  3359. */
  3360. static NoCap: number;
  3361. /**
  3362. * A round cap, will use the line thickness as diameter
  3363. */
  3364. static RoundCap: number;
  3365. /**
  3366. * Creates a triangle at the extremity.
  3367. */
  3368. static TriangleCap: number;
  3369. /**
  3370. * Creates a Square anchor at the extremity, the square size is twice the thickness of the line
  3371. */
  3372. static SquareAnchorCap: number;
  3373. /**
  3374. * Creates a round anchor at the extremity, the diameter is twice the thickness of the line
  3375. */
  3376. static RoundAnchorCap: number;
  3377. /**
  3378. * Creates a diamond anchor at the extremity.
  3379. */
  3380. static DiamondAnchorCap: number;
  3381. /**
  3382. * Creates an arrow anchor at the extremity. the arrow base size is twice the thickness of the line
  3383. */
  3384. static ArrowCap: number;
  3385. static pointsProperty: Prim2DPropInfo;
  3386. static fillThicknessProperty: Prim2DPropInfo;
  3387. static closedProperty: Prim2DPropInfo;
  3388. static startCapProperty: Prim2DPropInfo;
  3389. static endCapProperty: Prim2DPropInfo;
  3390. points: Vector2[];
  3391. fillThickness: number;
  3392. closed: boolean;
  3393. startCap: number;
  3394. endCap: number;
  3395. private static _prevA;
  3396. private static _prevB;
  3397. private static _curA;
  3398. private static _curB;
  3399. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  3400. protected boundingMin: Vector2;
  3401. protected boundingMax: Vector2;
  3402. protected getUsedShaderCategories(dataPart: InstanceDataBase): string[];
  3403. protected updateLevelBoundingInfo(): void;
  3404. /**
  3405. * Create an 2D Lines Shape primitive. The defined lines may be opened or closed (see below)
  3406. * @param points an array that describe the points to use to draw the line, must contain at least two entries.
  3407. * @param settings a combination of settings, possible ones are
  3408. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  3409. * - children: an array of direct children
  3410. * - id a text identifier, for information purpose
  3411. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  3412. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  3413. * - scale: the initial scale of the primitive. default is 1
  3414. * - origin: define the normalized origin point location, default [0.5;0.5]
  3415. * - fillThickness: the thickness of the fill part of the line, can be null to draw nothing (but a border brush must be given), default is 1.
  3416. * - closed: if false the lines are said to be opened, the first point and the latest DON'T connect. if true the lines are said to be closed, the first and last point will be connected by a line. For instance you can define the 4 points of a rectangle, if you set closed to true a 4 edges rectangle will be drawn. If you set false, only three edges will be drawn, the edge formed by the first and last point won't exist. Default is false.
  3417. * - startCap: Draw a cap of the given type at the start of the first line, you can't define a Cap if the Lines2D is closed. Default is Lines2D.NoCap.
  3418. * - endCap: Draw a cap of the given type at the end of the last line, you can't define a Cap if the Lines2D is closed. Default is Lines2D.NoCap.
  3419. * - fill: the brush used to draw the fill content of the lines, you can set null to draw nothing (but you will have to set a border brush), default is a SolidColorBrush of plain white. can be a string value (see Canvas2D.GetBrushFromString)
  3420. * - border: the brush used to draw the border of the lines, you can set null to draw nothing (but you will have to set a fill brush), default is null. can be a string value (see Canvas2D.GetBrushFromString)
  3421. * - borderThickness: the thickness of the drawn border, default is 1.
  3422. * - isVisible: true if the primitive must be visible, false for hidden. Default is true.
  3423. * - childrenFlatZOrder: if true all the children (direct and indirect) will share the same Z-Order. Use this when there's a lot of children which don't overlap. The drawing order IS NOT GUARANTED!
  3424. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3425. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3426. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3427. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3428. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  3429. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  3430. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  3431. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  3432. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3433. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3434. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3435. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  3436. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  3437. */
  3438. constructor(points: Vector2[], settings?: {
  3439. parent?: Prim2DBase;
  3440. children?: Array<Prim2DBase>;
  3441. id?: string;
  3442. position?: Vector2;
  3443. x?: number;
  3444. y?: number;
  3445. rotation?: number;
  3446. scale?: number;
  3447. origin?: Vector2;
  3448. fillThickness?: number;
  3449. closed?: boolean;
  3450. startCap?: number;
  3451. endCap?: number;
  3452. fill?: IBrush2D | string;
  3453. border?: IBrush2D | string;
  3454. borderThickness?: number;
  3455. isVisible?: boolean;
  3456. childrenFlatZOrder?: boolean;
  3457. marginTop?: number | string;
  3458. marginLeft?: number | string;
  3459. marginRight?: number | string;
  3460. marginBottom?: number | string;
  3461. margin?: number | string;
  3462. marginHAlignment?: number;
  3463. marginVAlignment?: number;
  3464. marginAlignment?: string;
  3465. paddingTop?: number | string;
  3466. paddingLeft?: number | string;
  3467. paddingRight?: number | string;
  3468. paddingBottom?: number | string;
  3469. padding?: string;
  3470. });
  3471. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  3472. private _perp(v, res);
  3473. private _direction(a, b, res);
  3474. private static _miterTps;
  3475. private _computeMiter(tangent, miter, a, b);
  3476. private _intersect(x1, y1, x2, y2, x3, y3, x4, y4);
  3477. private _updateMinMax(array, offset);
  3478. private static _startDir;
  3479. private static _endDir;
  3480. private _store(array, contour, index, max, p, n, halfThickness, borderThickness, detectFlip?);
  3481. private _getCapSize(type, border?);
  3482. private static _tpsV;
  3483. private _storeVertex(vb, baseOffset, index, basePos, rotation, vertex, contour);
  3484. private _storeIndex(ib, baseOffset, index, vertexIndex);
  3485. private _buildCap(vb, vbi, ib, ibi, pos, thickness, borderThickness, type, capDir, contour);
  3486. private _buildLine(vb, contour, ht, bt?);
  3487. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Lines2DRenderCache;
  3488. private _computeLines2D();
  3489. size: Size;
  3490. protected createInstanceDataParts(): InstanceDataBase[];
  3491. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  3492. private static _noCap;
  3493. private static _roundCap;
  3494. private static _triangleCap;
  3495. private static _squareAnchorCap;
  3496. private static _roundAnchorCap;
  3497. private static _diamondAnchorCap;
  3498. private static _arrowCap;
  3499. private static _roundCapSubDiv;
  3500. private _fillVB;
  3501. private _fillIB;
  3502. private _borderVB;
  3503. private _borderIB;
  3504. private _boundingMin;
  3505. private _boundingMax;
  3506. private _contour;
  3507. private _startCapContour;
  3508. private _startCapTriIndices;
  3509. private _endCapContour;
  3510. private _endCapTriIndices;
  3511. private _closed;
  3512. private _startCap;
  3513. private _endCap;
  3514. private _fillThickness;
  3515. private _points;
  3516. }
  3517. }
  3518. declare module BABYLON {
  3519. const enum ShaderDataType {
  3520. Vector2 = 0,
  3521. Vector3 = 1,
  3522. Vector4 = 2,
  3523. Matrix = 3,
  3524. float = 4,
  3525. Color3 = 5,
  3526. Color4 = 6,
  3527. Size = 7,
  3528. }
  3529. class GroupInstanceInfo {
  3530. constructor(owner: Group2D, mrc: ModelRenderCache, partCount: number);
  3531. dispose(): boolean;
  3532. private _isDisposed;
  3533. owner: Group2D;
  3534. modelRenderCache: ModelRenderCache;
  3535. partIndexFromId: StringDictionary<number>;
  3536. hasOpaqueData: boolean;
  3537. hasAlphaTestData: boolean;
  3538. hasTransparentData: boolean;
  3539. opaqueDirty: boolean;
  3540. opaqueData: GroupInfoPartData[];
  3541. alphaTestDirty: boolean;
  3542. alphaTestData: GroupInfoPartData[];
  3543. transparentOrderDirty: boolean;
  3544. transparentDirty: boolean;
  3545. transparentData: TransparentGroupInfoPartData[];
  3546. sortTransparentData(): void;
  3547. usedShaderCategories: string[];
  3548. strides: number[];
  3549. private _partCount;
  3550. private _strides;
  3551. private _usedShaderCategories;
  3552. private _opaqueData;
  3553. private _alphaTestData;
  3554. private _transparentData;
  3555. }
  3556. class TransparentSegment {
  3557. groupInsanceInfo: GroupInstanceInfo;
  3558. startZ: number;
  3559. endZ: number;
  3560. startDataIndex: number;
  3561. endDataIndex: number;
  3562. }
  3563. class GroupInfoPartData {
  3564. _partData: DynamicFloatArray;
  3565. _partBuffer: WebGLBuffer;
  3566. _partBufferSize: number;
  3567. constructor(stride: number);
  3568. dispose(engine: Engine): boolean;
  3569. private _isDisposed;
  3570. }
  3571. class TransparentGroupInfoPartData extends GroupInfoPartData {
  3572. constructor(stride: number, zoff: number);
  3573. }
  3574. class ModelRenderCache {
  3575. constructor(engine: Engine, modelKey: string);
  3576. dispose(): boolean;
  3577. isDisposed: boolean;
  3578. addRef(): number;
  3579. modelKey: string;
  3580. /**
  3581. * Render the model instances
  3582. * @param instanceInfo
  3583. * @param context
  3584. * @return must return true is the rendering succeed, false if the rendering couldn't be done (asset's not yet ready, like Effect)
  3585. */
  3586. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  3587. addInstanceDataParts(data: InstanceDataBase[]): string;
  3588. removeInstanceData(key: string): void;
  3589. protected getPartIndexFromId(partId: number): number;
  3590. protected loadInstancingAttributes(partId: number, effect: Effect): InstancingAttributeInfo[];
  3591. private static v2;
  3592. private static v3;
  3593. private static v4;
  3594. protected setupUniforms(effect: Effect, partIndex: number, data: DynamicFloatArray, elementCount: number): void;
  3595. protected _engine: Engine;
  3596. private _modelKey;
  3597. _instancesData: StringDictionary<InstanceDataBase[]>;
  3598. private _nextKey;
  3599. private _refCounter;
  3600. _partData: ModelRenderCachePartData[];
  3601. _partsClassInfo: ClassTreeInfo<InstanceClassInfo, InstancePropInfo>[];
  3602. }
  3603. class ModelRenderCachePartData {
  3604. _partId: number;
  3605. _zBiasOffset: number;
  3606. _partDataStride: number;
  3607. _partUsedCategories: string[];
  3608. _partJoinedUsedCategories: string;
  3609. }
  3610. }
  3611. declare module BABYLON {
  3612. class PrepareRender2DContext {
  3613. constructor();
  3614. /**
  3615. * True if the primitive must be refreshed no matter what
  3616. * This mode is needed because sometimes the primitive doesn't change by itself, but external changes make a refresh of its InstanceData necessary
  3617. */
  3618. forceRefreshPrimitive: boolean;
  3619. }
  3620. class Render2DContext {
  3621. constructor(renderMode: number);
  3622. /**
  3623. * Define which render Mode should be used to render the primitive: one of Render2DContext.RenderModeXxxx property
  3624. */
  3625. renderMode: number;
  3626. /**
  3627. * If true hardware instancing is supported and must be used for the rendering. The groupInfoPartData._partBuffer must be used.
  3628. * If false rendering on a per primitive basis must be made. The following properties must be used
  3629. * - groupInfoPartData._partData: contains the primitive instances data to render
  3630. * - partDataStartIndex: the index into instanceArrayData of the first instance to render.
  3631. * - partDataCount: the number of primitive to render
  3632. */
  3633. useInstancing: boolean;
  3634. /**
  3635. * Contains the data related to the primitives instances to render
  3636. */
  3637. groupInfoPartData: GroupInfoPartData[];
  3638. /**
  3639. * The index into groupInfoPartData._partData of the first primitive to render. This is an index, not an offset: it represent the nth primitive which is the first to render.
  3640. */
  3641. partDataStartIndex: number;
  3642. /**
  3643. * The exclusive end index, you have to render the primitive instances until you reach this one, but don't render this one!
  3644. */
  3645. partDataEndIndex: number;
  3646. /**
  3647. * The set of primitives to render is opaque.
  3648. * This is the first rendering pass. All Opaque primitives are rendered. Depth Compare and Write are both enabled.
  3649. */
  3650. static RenderModeOpaque: number;
  3651. /**
  3652. * The set of primitives to render is using Alpha Test (aka masking).
  3653. * Alpha Blend is enabled, the AlphaMode must be manually set, the render occurs after the RenderModeOpaque and is depth independent (i.e. primitives are not sorted by depth). Depth Compare and Write are both enabled.
  3654. */
  3655. static RenderModeAlphaTest: number;
  3656. /**
  3657. * The set of primitives to render is transparent.
  3658. * Alpha Blend is enabled, the AlphaMode must be manually set, the render occurs after the RenderModeAlphaTest and is depth dependent (i.e. primitives are stored by depth and rendered back to front). Depth Compare is on, but Depth write is Off.
  3659. */
  3660. static RenderModeTransparent: number;
  3661. private static _renderModeOpaque;
  3662. private static _renderModeAlphaTest;
  3663. private static _renderModeTransparent;
  3664. private _renderMode;
  3665. }
  3666. /**
  3667. * This class store information for the pointerEventObservable Observable.
  3668. * The Observable is divided into many sub events (using the Mask feature of the Observable pattern): PointerOver, PointerEnter, PointerDown, PointerMouseWheel, PointerMove, PointerUp, PointerDown, PointerLeave, PointerGotCapture and PointerLostCapture.
  3669. */
  3670. class PrimitivePointerInfo {
  3671. private static _pointerOver;
  3672. private static _pointerEnter;
  3673. private static _pointerDown;
  3674. private static _pointerMouseWheel;
  3675. private static _pointerMove;
  3676. private static _pointerUp;
  3677. private static _pointerOut;
  3678. private static _pointerLeave;
  3679. private static _pointerGotCapture;
  3680. private static _pointerLostCapture;
  3681. private static _mouseWheelPrecision;
  3682. /**
  3683. * This event type is raised when a pointing device is moved into the hit test boundaries of a primitive.
  3684. * Bubbles: yes
  3685. */
  3686. static PointerOver: number;
  3687. /**
  3688. * This event type is raised when a pointing device is moved into the hit test boundaries of a primitive or one of its descendants.
  3689. * Bubbles: no
  3690. */
  3691. static PointerEnter: number;
  3692. /**
  3693. * This event type is raised when a pointer enters the active button state (non-zero value in the buttons property). For mouse it's when the device transitions from no buttons depressed to at least one button depressed. For touch/pen this is when a physical contact is made.
  3694. * Bubbles: yes
  3695. */
  3696. static PointerDown: number;
  3697. /**
  3698. * This event type is raised when the pointer is a mouse and it's wheel is rolling
  3699. * Bubbles: yes
  3700. */
  3701. static PointerMouseWheel: number;
  3702. /**
  3703. * This event type is raised when a pointer change coordinates or when a pointer changes button state, pressure, tilt, or contact geometry and the circumstances produce no other pointers events.
  3704. * Bubbles: yes
  3705. */
  3706. static PointerMove: number;
  3707. /**
  3708. * This event type is raised when the pointer leaves the active buttons states (zero value in the buttons property). For mouse, this is when the device transitions from at least one button depressed to no buttons depressed. For touch/pen, this is when physical contact is removed.
  3709. * Bubbles: yes
  3710. */
  3711. static PointerUp: number;
  3712. /**
  3713. * This event type is raised when a pointing device is moved out of the hit test the boundaries of a primitive.
  3714. * Bubbles: yes
  3715. */
  3716. static PointerOut: number;
  3717. /**
  3718. * This event type is raised when a pointing device is moved out of the hit test boundaries of a primitive and all its descendants.
  3719. * Bubbles: no
  3720. */
  3721. static PointerLeave: number;
  3722. /**
  3723. * This event type is raised when a primitive receives the pointer capture. This event is fired at the element that is receiving pointer capture. Subsequent events for that pointer will be fired at this element.
  3724. * Bubbles: yes
  3725. */
  3726. static PointerGotCapture: number;
  3727. /**
  3728. * This event type is raised after pointer capture is released for a pointer.
  3729. * Bubbles: yes
  3730. */
  3731. static PointerLostCapture: number;
  3732. static MouseWheelPrecision: number;
  3733. /**
  3734. * Event Type, one of the static PointerXXXX property defined above (PrimitivePointerInfo.PointerOver to PrimitivePointerInfo.PointerLostCapture)
  3735. */
  3736. eventType: number;
  3737. /**
  3738. * Position of the pointer relative to the bottom/left of the Canvas
  3739. */
  3740. canvasPointerPos: Vector2;
  3741. /**
  3742. * Position of the pointer relative to the bottom/left of the primitive that registered the Observer
  3743. */
  3744. primitivePointerPos: Vector2;
  3745. /**
  3746. * The primitive where the event was initiated first (in case of bubbling)
  3747. */
  3748. relatedTarget: Prim2DBase;
  3749. /**
  3750. * Position of the pointer relative to the bottom/left of the relatedTarget
  3751. */
  3752. relatedTargetPointerPos: Vector2;
  3753. /**
  3754. * An observable can set this property to true to stop bubbling on the upper levels
  3755. */
  3756. cancelBubble: boolean;
  3757. /**
  3758. * True if the Control keyboard key is down
  3759. */
  3760. ctrlKey: boolean;
  3761. /**
  3762. * true if the Shift keyboard key is down
  3763. */
  3764. shiftKey: boolean;
  3765. /**
  3766. * true if the Alt keyboard key is down
  3767. */
  3768. altKey: boolean;
  3769. /**
  3770. * true if the Meta keyboard key is down
  3771. */
  3772. metaKey: boolean;
  3773. /**
  3774. * For button, buttons, refer to https://www.w3.org/TR/pointerevents/#button-states
  3775. */
  3776. button: number;
  3777. /**
  3778. * For button, buttons, refer to https://www.w3.org/TR/pointerevents/#button-states
  3779. */
  3780. buttons: number;
  3781. /**
  3782. * The amount of mouse wheel rolled
  3783. */
  3784. mouseWheelDelta: number;
  3785. /**
  3786. * Id of the Pointer involved in the event
  3787. */
  3788. pointerId: number;
  3789. width: number;
  3790. height: number;
  3791. presssure: number;
  3792. tilt: Vector2;
  3793. /**
  3794. * true if the involved pointer is captured for a particular primitive, false otherwise.
  3795. */
  3796. isCaptured: boolean;
  3797. constructor();
  3798. updateRelatedTarget(prim: Prim2DBase, primPointerPos: Vector2): void;
  3799. static getEventTypeName(mask: number): string;
  3800. }
  3801. /**
  3802. * Defines the horizontal and vertical alignment information for a Primitive.
  3803. */
  3804. class PrimitiveAlignment {
  3805. constructor(changeCallback: () => void);
  3806. /**
  3807. * Alignment is made relative to the left edge of the Primitive. Valid for horizontal alignment only.
  3808. */
  3809. static AlignLeft: number;
  3810. /**
  3811. * Alignment is made relative to the top edge of the Primitive. Valid for vertical alignment only.
  3812. */
  3813. static AlignTop: number;
  3814. /**
  3815. * Alignment is made relative to the right edge of the Primitive. Valid for horizontal alignment only.
  3816. */
  3817. static AlignRight: number;
  3818. /**
  3819. * Alignment is made relative to the bottom edge of the Primitive. Valid for vertical alignment only.
  3820. */
  3821. static AlignBottom: number;
  3822. /**
  3823. * Alignment is made to center the content from equal distance to the opposite edges of the Primitive
  3824. */
  3825. static AlignCenter: number;
  3826. /**
  3827. * The content is stretched toward the opposite edges of the Primitive
  3828. */
  3829. static AlignStretch: number;
  3830. private static _AlignLeft;
  3831. private static _AlignTop;
  3832. private static _AlignRight;
  3833. private static _AlignBottom;
  3834. private static _AlignCenter;
  3835. private static _AlignStretch;
  3836. /**
  3837. * Get/set the horizontal alignment. Use one of the AlignXXX static properties of this class
  3838. */
  3839. horizontal: number;
  3840. /**
  3841. * Get/set the vertical alignment. Use one of the AlignXXX static properties of this class
  3842. */
  3843. vertical: number;
  3844. private _changedCallback;
  3845. private _horizontal;
  3846. private _vertical;
  3847. /**
  3848. * Set the horizontal alignment from a string value.
  3849. * @param text can be either: 'left','right','center','stretch'
  3850. */
  3851. setHorizontal(text: string): void;
  3852. /**
  3853. * Set the vertical alignment from a string value.
  3854. * @param text can be either: 'top','bottom','center','stretch'
  3855. */
  3856. setVertical(text: string): void;
  3857. /**
  3858. * Set the horizontal and or vertical alignments from a string value.
  3859. * @param text can be: [<h:|horizontal:><left|right|center|stretch>], [<v:|vertical:><top|bottom|center|stretch>]
  3860. */
  3861. fromString(value: string): void;
  3862. }
  3863. /**
  3864. * Stores information about a Primitive that was intersected
  3865. */
  3866. class PrimitiveIntersectedInfo {
  3867. prim: Prim2DBase;
  3868. intersectionLocation: Vector2;
  3869. constructor(prim: Prim2DBase, intersectionLocation: Vector2);
  3870. }
  3871. /**
  3872. * Define a thickness toward every edges of a Primitive to allow margin and padding.
  3873. * The thickness can be expressed as pixels, percentages, inherit the value of the parent primitive or be auto.
  3874. */
  3875. class PrimitiveThickness {
  3876. constructor(parentAccess: () => PrimitiveThickness, changedCallback: () => void);
  3877. /**
  3878. * Set the thickness from a string value
  3879. * @param thickness format is "top: <value>, left:<value>, right:<value>, bottom:<value>" or "<value>" (same for all edges) each are optional, auto will be set if it's omitted.
  3880. * Values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3881. */
  3882. fromString(thickness: string): void;
  3883. /**
  3884. * Set the thickness from multiple string
  3885. * Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3886. * @param top the top thickness to set
  3887. * @param left the left thickness to set
  3888. * @param right the right thickness to set
  3889. * @param bottom the bottom thickness to set
  3890. */
  3891. fromStrings(top: string, left: string, right: string, bottom: string): PrimitiveThickness;
  3892. /**
  3893. * Set the thickness from pixel values
  3894. * @param top the top thickness in pixels to set
  3895. * @param left the left thickness in pixels to set
  3896. * @param right the right thickness in pixels to set
  3897. * @param bottom the bottom thickness in pixels to set
  3898. */
  3899. fromPixels(top: number, left: number, right: number, bottom: number): PrimitiveThickness;
  3900. /**
  3901. * Apply the same pixel value to all edges
  3902. * @param margin the value to set, in pixels.
  3903. */
  3904. fromUniformPixels(margin: number): PrimitiveThickness;
  3905. /**
  3906. * Set all edges in auto
  3907. */
  3908. auto(): PrimitiveThickness;
  3909. private _clear();
  3910. private _extractString(value, emitChanged);
  3911. private _setStringValue(value, index, emitChanged);
  3912. private _setPixels(value, index, emitChanged);
  3913. private _setPercentage(value, index, emitChanged);
  3914. private _getStringValue(index);
  3915. private _isType(index, type);
  3916. private _getType(index, processInherit);
  3917. private _setType(index, type);
  3918. setTop(value: number | string): void;
  3919. setLeft(value: number | string): void;
  3920. setRight(value: number | string): void;
  3921. setBottom(value: number | string): void;
  3922. /**
  3923. * Get/set the top thickness. Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3924. */
  3925. top: string;
  3926. /**
  3927. * Get/set the left thickness. Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3928. */
  3929. left: string;
  3930. /**
  3931. * Get/set the right thickness. Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3932. */
  3933. right: string;
  3934. /**
  3935. * Get/set the bottom thickness. Possible values are: 'auto', 'inherit', 'XX%' for percentage, 'XXpx' or 'XX' for pixels.
  3936. */
  3937. bottom: string;
  3938. /**
  3939. * Get/set the top thickness in pixel.
  3940. */
  3941. topPixels: number;
  3942. /**
  3943. * Get/set the left thickness in pixel.
  3944. */
  3945. leftPixels: number;
  3946. /**
  3947. * Get/set the right thickness in pixel.
  3948. */
  3949. rightPixels: number;
  3950. /**
  3951. * Get/set the bottom thickness in pixel.
  3952. */
  3953. bottomPixels: number;
  3954. /**
  3955. * Get/set the top thickness in percentage.
  3956. * The get will return a valid value only if the edge type is percentage.
  3957. * The Set will change the edge mode if needed
  3958. */
  3959. topPercentage: number;
  3960. /**
  3961. * Get/set the left thickness in percentage.
  3962. * The get will return a valid value only if the edge mode is percentage.
  3963. * The Set will change the edge mode if needed
  3964. */
  3965. leftPercentage: number;
  3966. /**
  3967. * Get/set the right thickness in percentage.
  3968. * The get will return a valid value only if the edge mode is percentage.
  3969. * The Set will change the edge mode if needed
  3970. */
  3971. rightPercentage: number;
  3972. /**
  3973. * Get/set the bottom thickness in percentage.
  3974. * The get will return a valid value only if the edge mode is percentage.
  3975. * The Set will change the edge mode if needed
  3976. */
  3977. bottomPercentage: number;
  3978. /**
  3979. * Get/set the top mode. The setter shouldn't be used, other setters with value should be preferred
  3980. */
  3981. topMode: number;
  3982. /**
  3983. * Get/set the left mode. The setter shouldn't be used, other setters with value should be preferred
  3984. */
  3985. leftMode: number;
  3986. /**
  3987. * Get/set the right mode. The setter shouldn't be used, other setters with value should be preferred
  3988. */
  3989. rightMode: number;
  3990. /**
  3991. * Get/set the bottom mode. The setter shouldn't be used, other setters with value should be preferred
  3992. */
  3993. bottomMode: number;
  3994. private _parentAccess;
  3995. private _changedCallback;
  3996. private _pixels;
  3997. private _percentages;
  3998. private _flags;
  3999. static Auto: number;
  4000. static Inherit: number;
  4001. static Percentage: number;
  4002. static Pixel: number;
  4003. private _computePixels(index, sourceArea, emitChanged);
  4004. /**
  4005. * Compute the positioning/size of an area considering the thickness of this object and a given alignment
  4006. * @param sourceArea the source area
  4007. * @param contentSize the content size to position/resize
  4008. * @param alignment the alignment setting
  4009. * @param dstOffset the position of the content
  4010. * @param dstArea the new size of the content
  4011. */
  4012. computeWithAlignment(sourceArea: Size, contentSize: Size, alignment: PrimitiveAlignment, dstOffset: Vector2, dstArea: Size): void;
  4013. /**
  4014. * Compute an area and its position considering this thickness properties based on a given source area
  4015. * @param sourceArea the source area
  4016. * @param dstOffset the position of the resulting area
  4017. * @param dstArea the size of the resulting area
  4018. */
  4019. compute(sourceArea: Size, dstOffset: Vector2, dstArea: Size): void;
  4020. /**
  4021. * Compute an area considering this thickness properties based on a given source area
  4022. * @param sourceArea the source area
  4023. * @param result the resulting area
  4024. */
  4025. computeArea(sourceArea: Size, result: Size): void;
  4026. enlarge(sourceArea: Size, dstOffset: Vector2, enlargedArea: Size): void;
  4027. }
  4028. /**
  4029. * Main class used for the Primitive Intersection API
  4030. */
  4031. class IntersectInfo2D {
  4032. constructor();
  4033. /**
  4034. * Set the pick position, relative to the primitive where the intersection test is made
  4035. */
  4036. pickPosition: Vector2;
  4037. /**
  4038. * If true the intersection will stop at the first hit, if false all primitives will be tested and the intersectedPrimitives array will be filled accordingly (false default)
  4039. */
  4040. findFirstOnly: boolean;
  4041. /**
  4042. * If true the intersection test will also be made on hidden primitive (false default)
  4043. */
  4044. intersectHidden: boolean;
  4045. _globalPickPosition: Vector2;
  4046. _localPickPosition: Vector2;
  4047. /**
  4048. * The topmost intersected primitive
  4049. */
  4050. topMostIntersectedPrimitive: PrimitiveIntersectedInfo;
  4051. /**
  4052. * The array containing all intersected primitive, in no particular order.
  4053. */
  4054. intersectedPrimitives: Array<PrimitiveIntersectedInfo>;
  4055. /**
  4056. * true if at least one primitive intersected during the test
  4057. */
  4058. isIntersected: boolean;
  4059. isPrimIntersected(prim: Prim2DBase): Vector2;
  4060. _exit(firstLevel: boolean): void;
  4061. }
  4062. class Prim2DBase extends SmartPropertyPrim {
  4063. static PRIM2DBASE_PROPCOUNT: number;
  4064. private static _bigInt;
  4065. constructor(settings: {
  4066. parent?: Prim2DBase;
  4067. id?: string;
  4068. children?: Array<Prim2DBase>;
  4069. position?: Vector2;
  4070. x?: number;
  4071. y?: number;
  4072. rotation?: number;
  4073. scale?: number;
  4074. origin?: Vector2;
  4075. layoutEngine?: LayoutEngineBase | string;
  4076. isVisible?: boolean;
  4077. childrenFlatZOrder?: boolean;
  4078. marginTop?: number | string;
  4079. marginLeft?: number | string;
  4080. marginRight?: number | string;
  4081. marginBottom?: number | string;
  4082. margin?: number | string;
  4083. marginHAlignment?: number;
  4084. marginVAlignment?: number;
  4085. marginAlignment?: string;
  4086. paddingTop?: number | string;
  4087. paddingLeft?: number | string;
  4088. paddingRight?: number | string;
  4089. paddingBottom?: number | string;
  4090. padding?: string;
  4091. });
  4092. actionManager: ActionManager;
  4093. /**
  4094. * From 'this' primitive, traverse up (from parent to parent) until the given predicate is true
  4095. * @param predicate the predicate to test on each parent
  4096. * @return the first primitive where the predicate was successful
  4097. */
  4098. traverseUp(predicate: (p: Prim2DBase) => boolean): Prim2DBase;
  4099. /**
  4100. * Retrieve the owner Canvas2D
  4101. */
  4102. owner: Canvas2D;
  4103. /**
  4104. * Get the parent primitive (can be the Canvas, only the Canvas has no parent)
  4105. */
  4106. parent: Prim2DBase;
  4107. /**
  4108. * The array of direct children primitives
  4109. */
  4110. children: Prim2DBase[];
  4111. /**
  4112. * The identifier of this primitive, may not be unique, it's for information purpose only
  4113. */
  4114. id: string;
  4115. /**
  4116. * Metadata of the position property
  4117. */
  4118. static positionProperty: Prim2DPropInfo;
  4119. /**
  4120. * Metadata of the actualPosition property
  4121. */
  4122. static actualPositionProperty: Prim2DPropInfo;
  4123. /**
  4124. * Metadata of the size property
  4125. */
  4126. static sizeProperty: Prim2DPropInfo;
  4127. /**
  4128. * Metadata of the rotation property
  4129. */
  4130. static rotationProperty: Prim2DPropInfo;
  4131. /**
  4132. * Metadata of the scale property
  4133. */
  4134. static scaleProperty: Prim2DPropInfo;
  4135. /**
  4136. * Metadata of the origin property
  4137. */
  4138. static originProperty: Prim2DPropInfo;
  4139. /**
  4140. * Metadata of the levelVisible property
  4141. */
  4142. static levelVisibleProperty: Prim2DPropInfo;
  4143. /**
  4144. * Metadata of the isVisible property
  4145. */
  4146. static isVisibleProperty: Prim2DPropInfo;
  4147. /**
  4148. * Metadata of the zOrder property
  4149. */
  4150. static zOrderProperty: Prim2DPropInfo;
  4151. /**
  4152. * Metadata of the margin property
  4153. */
  4154. static marginProperty: Prim2DPropInfo;
  4155. /**
  4156. * Metadata of the margin property
  4157. */
  4158. static paddingProperty: Prim2DPropInfo;
  4159. /**
  4160. * Metadata of the hAlignment property
  4161. */
  4162. static marginAlignmentProperty: Prim2DPropInfo;
  4163. /**
  4164. * DO NOT INVOKE for internal purpose only
  4165. */
  4166. actualPosition: Vector2;
  4167. private static _nullPosition;
  4168. /**
  4169. * Shortcut to actualPosition.x
  4170. */
  4171. actualX: number;
  4172. /**
  4173. * Shortcut to actualPosition.y
  4174. */
  4175. actualY: number;
  4176. /**
  4177. * Position of the primitive, relative to its parent.
  4178. * BEWARE: if you change only position.x or y it won't trigger a property change and you won't have the expected behavior.
  4179. * Use this property to set a new Vector2 object, otherwise to change only the x/y use Prim2DBase.x or y properties.
  4180. * Setting this property may have no effect is specific alignment are in effect.
  4181. */
  4182. position: Vector2;
  4183. /**
  4184. * Direct access to the position.x value of the primitive
  4185. * Use this property when you only want to change one component of the position property
  4186. */
  4187. x: number;
  4188. /**
  4189. * Direct access to the position.y value of the primitive
  4190. * Use this property when you only want to change one component of the position property
  4191. */
  4192. y: number;
  4193. private static boundinbBoxReentrency;
  4194. protected static nullSize: Size;
  4195. /**
  4196. * Size of the primitive or its bounding area
  4197. * BEWARE: if you change only size.width or height it won't trigger a property change and you won't have the expected behavior.
  4198. * Use this property to set a new Size object, otherwise to change only the width/height use Prim2DBase.width or height properties.
  4199. */
  4200. size: Size;
  4201. /**
  4202. * Direct access to the size.width value of the primitive
  4203. * Use this property when you only want to change one component of the size property
  4204. */
  4205. width: number;
  4206. /**
  4207. * Direct access to the size.height value of the primitive
  4208. * Use this property when you only want to change one component of the size property
  4209. */
  4210. height: number;
  4211. rotation: number;
  4212. scale: number;
  4213. /**
  4214. * Return the size of the primitive as it's being rendered into the target.
  4215. * This value may be different of the size property when layout/alignment is used or specific primitive types can implement a custom logic through this property.
  4216. * BEWARE: don't use the setter, it's for internal purpose only
  4217. * Note to implementers: you have to override this property and declare if necessary a @xxxxInstanceLevel decorator
  4218. */
  4219. actualSize: Size;
  4220. actualZOffset: number;
  4221. /**
  4222. * Get or set the minimal size the Layout Engine should respect when computing the primitive's actualSize.
  4223. * The Primitive's size won't be less than specified.
  4224. * The default value depends of the Primitive type
  4225. */
  4226. minSize: Size;
  4227. /**
  4228. * Get or set the maximal size the Layout Engine should respect when computing the primitive's actualSize.
  4229. * The Primitive's size won't be more than specified.
  4230. * The default value depends of the Primitive type
  4231. */
  4232. maxSize: Size;
  4233. /**
  4234. * The origin defines the normalized coordinate of the center of the primitive, from the bottom/left corner.
  4235. * The origin is used only to compute transformation of the primitive, it has no meaning in the primitive local frame of reference
  4236. * For instance:
  4237. * 0,0 means the center is bottom/left. Which is the default for Canvas2D instances
  4238. * 0.5,0.5 means the center is at the center of the primitive, which is default of all types of Primitives
  4239. * 0,1 means the center is top/left
  4240. * @returns The normalized center.
  4241. */
  4242. origin: Vector2;
  4243. levelVisible: boolean;
  4244. isVisible: boolean;
  4245. zOrder: number;
  4246. isManualZOrder: boolean;
  4247. margin: PrimitiveThickness;
  4248. private _hasMargin;
  4249. padding: PrimitiveThickness;
  4250. private _hasPadding;
  4251. marginAlignment: PrimitiveAlignment;
  4252. /**
  4253. * Get/set the layout engine to use for this primitive.
  4254. * The default layout engine is the CanvasLayoutEngine.
  4255. */
  4256. layoutEngine: LayoutEngineBase;
  4257. /**
  4258. * Get/set the layout are of this primitive.
  4259. * The Layout area is the zone allocated by the Layout Engine for this particular primitive. Margins/Alignment will be computed based on this area.
  4260. * The setter should only be called by a Layout Engine class.
  4261. */
  4262. layoutArea: Size;
  4263. /**
  4264. * Get/set the layout area position (relative to the parent primitive).
  4265. * The setter should only be called by a Layout Engine class.
  4266. */
  4267. layoutAreaPos: Vector2;
  4268. /**
  4269. * Define if the Primitive can be subject to intersection test or not (default is true)
  4270. */
  4271. isPickable: boolean;
  4272. /**
  4273. * Return the depth level of the Primitive into the Canvas' Graph. A Canvas will be 0, its direct children 1, and so on.
  4274. */
  4275. hierarchyDepth: number;
  4276. /**
  4277. * Retrieve the Group that is responsible to render this primitive
  4278. */
  4279. renderGroup: Group2D;
  4280. /**
  4281. * Get the global transformation matrix of the primitive
  4282. */
  4283. globalTransform: Matrix;
  4284. /**
  4285. * return the global position of the primitive, relative to its canvas
  4286. */
  4287. getGlobalPosition(): Vector2;
  4288. /**
  4289. * return the global position of the primitive, relative to its canvas
  4290. * @param v the valid Vector2 object where the global position will be stored
  4291. */
  4292. getGlobalPositionByRef(v: Vector2): void;
  4293. /**
  4294. * Get invert of the global transformation matrix of the primitive
  4295. */
  4296. invGlobalTransform: Matrix;
  4297. /**
  4298. * Get the local transformation of the primitive
  4299. */
  4300. localTransform: Matrix;
  4301. private static _bMax;
  4302. /**
  4303. * Get the boundingInfo associated to the primitive and its children.
  4304. * The value is supposed to be always up to date
  4305. */
  4306. boundingInfo: BoundingInfo2D;
  4307. /**
  4308. * Determine if the size is automatically computed or fixed because manually specified.
  4309. * Use the actualSize property to get the final/real size of the primitive
  4310. * @returns true if the size is automatically computed, false if it were manually specified.
  4311. */
  4312. isSizeAuto: boolean;
  4313. /**
  4314. * Return true if this prim has an auto size which is set by the children's global bounding box
  4315. */
  4316. isSizedByContent: boolean;
  4317. /**
  4318. * Determine if the position is automatically computed or fixed because manually specified.
  4319. * Use the actualPosition property to get the final/real position of the primitive
  4320. * @returns true if the position is automatically computed, false if it were manually specified.
  4321. */
  4322. isPositionAuto: boolean;
  4323. /**
  4324. * Interaction with the primitive can be create using this Observable. See the PrimitivePointerInfo class for more information
  4325. */
  4326. pointerEventObservable: Observable<PrimitivePointerInfo>;
  4327. zActualOrderChangedObservable: Observable<number>;
  4328. findById(id: string): Prim2DBase;
  4329. protected onZOrderChanged(): void;
  4330. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  4331. /**
  4332. * Capture all the Events of the given PointerId for this primitive.
  4333. * Don't forget to call releasePointerEventsCapture when done.
  4334. * @param pointerId the Id of the pointer to capture the events from.
  4335. */
  4336. setPointerEventCapture(pointerId: number): boolean;
  4337. /**
  4338. * Release a captured pointer made with setPointerEventCapture.
  4339. * @param pointerId the Id of the pointer to release the capture from.
  4340. */
  4341. releasePointerEventsCapture(pointerId: number): boolean;
  4342. /**
  4343. * Make an intersection test with the primitive, all inputs/outputs are stored in the IntersectInfo2D class, see its documentation for more information.
  4344. * @param intersectInfo contains the settings of the intersection to perform, to setup before calling this method as well as the result, available after a call to this method.
  4345. */
  4346. intersect(intersectInfo: IntersectInfo2D): boolean;
  4347. moveChild(child: Prim2DBase, previous: Prim2DBase): boolean;
  4348. private addChild(child);
  4349. /**
  4350. * Dispose the primitive, remove it from its parent.
  4351. */
  4352. dispose(): boolean;
  4353. protected onPrimBecomesDirty(): void;
  4354. _needPrepare(): boolean;
  4355. _prepareRender(context: PrepareRender2DContext): void;
  4356. _prepareRenderPre(context: PrepareRender2DContext): void;
  4357. _prepareRenderPost(context: PrepareRender2DContext): void;
  4358. protected _canvasPreInit(settings: any): void;
  4359. protected static _isCanvasInit: boolean;
  4360. protected static CheckParent(parent: Prim2DBase): void;
  4361. protected updateCachedStatesOf(list: Prim2DBase[], recurse: boolean): void;
  4362. private _parentLayoutDirty();
  4363. protected _setLayoutDirty(): void;
  4364. private _checkPositionChange();
  4365. protected _positioningDirty(): void;
  4366. private _changeLayoutEngine(engine);
  4367. private static _t0;
  4368. private static _t1;
  4369. private static _t2;
  4370. private static _v0;
  4371. private _updateLocalTransform();
  4372. private static _transMtx;
  4373. protected updateCachedStates(recurse: boolean): void;
  4374. private static _icPos;
  4375. private static _icArea;
  4376. private static _size;
  4377. private _updatePositioning();
  4378. /**
  4379. * Get the content are of this primitive, this area is computed using the padding property and also possibly the primitive type itself.
  4380. * Children of this primitive will be positioned relative to the bottom/left corner of this area.
  4381. */
  4382. contentArea: Size;
  4383. _patchHierarchy(owner: Canvas2D): void;
  4384. private static _zOrderChangedNotifList;
  4385. private static _zRebuildReentrency;
  4386. private _updateZOrder();
  4387. private static _totalCount;
  4388. private _updatePrimitiveLinearPosition(prevLinPos);
  4389. private _updatePrimitiveZOrder(startPos, startZ, deltaZ);
  4390. private _updatePrimitiveFlatZOrder(newZ);
  4391. private _setZOrder(newZ, directEmit);
  4392. /**
  4393. * This method is used to alter the contentArea of the Primitive before margin is applied.
  4394. * In most of the case you won't need to override this method, but it can prove some usefulness, check the Rectangle2D class for a concrete application.
  4395. * @param primSize the current size of the primitive
  4396. * @param initialContentPosition the position of the initial content area to compute, a valid object is passed, you have to set its properties. PLEASE ROUND the values, we're talking about pixels and fraction of them is not a good thing!
  4397. * @param initialContentArea the size of the initial content area to compute, a valid object is passed, you have to set its properties. PLEASE ROUND the values, we're talking about pixels and fraction of them is not a good thing!
  4398. */
  4399. protected _getInitialContentAreaToRef(primSize: Size, initialContentPosition: Vector2, initialContentArea: Size): void;
  4400. /**
  4401. * This method is used to calculate the new size of the primitive based on the content which must stay the same
  4402. * Check the Rectangle2D implementation for a concrete application.
  4403. * @param primSize the current size of the primitive
  4404. * @param newPrimSize the new size of the primitive. PLEASE ROUND THE values, we're talking about pixels and fraction of them are not our friends!
  4405. */
  4406. protected _getActualSizeFromContentToRef(primSize: Size, newPrimSize: Size): void;
  4407. private _owner;
  4408. private _parent;
  4409. private _actionManager;
  4410. protected _children: Array<Prim2DBase>;
  4411. private _renderGroup;
  4412. protected _hierarchyDepth: number;
  4413. protected _zOrder: number;
  4414. private _manualZOrder;
  4415. protected _zMax: number;
  4416. private _firstZDirtyIndex;
  4417. private _primLinearPosition;
  4418. private _margin;
  4419. private _padding;
  4420. private _marginAlignment;
  4421. _pointerEventObservable: Observable<PrimitivePointerInfo>;
  4422. private _actualZOrderChangedObservable;
  4423. private _id;
  4424. private _position;
  4425. private _actualPosition;
  4426. protected _size: Size;
  4427. protected _actualSize: Size;
  4428. _boundingSize: Size;
  4429. protected _minSize: Size;
  4430. protected _maxSize: Size;
  4431. protected _desiredSize: Size;
  4432. private _layoutEngine;
  4433. private _marginOffset;
  4434. private _paddingOffset;
  4435. private _parentPaddingOffset;
  4436. private _parentContentArea;
  4437. private _lastAutoSizeArea;
  4438. private _layoutAreaPos;
  4439. private _layoutArea;
  4440. private _contentArea;
  4441. private _rotation;
  4442. private _scale;
  4443. private _origin;
  4444. protected _parentTransformStep: number;
  4445. protected _globalTransformStep: number;
  4446. protected _globalTransformProcessStep: number;
  4447. protected _localTransform: Matrix;
  4448. protected _globalTransform: Matrix;
  4449. protected _invGlobalTransform: Matrix;
  4450. }
  4451. }
  4452. declare module BABYLON {
  4453. class Rectangle2DRenderCache extends ModelRenderCache {
  4454. effectsReady: boolean;
  4455. fillVB: WebGLBuffer;
  4456. fillIB: WebGLBuffer;
  4457. fillIndicesCount: number;
  4458. instancingFillAttributes: InstancingAttributeInfo[];
  4459. effectFill: Effect;
  4460. effectFillInstanced: Effect;
  4461. borderVB: WebGLBuffer;
  4462. borderIB: WebGLBuffer;
  4463. borderIndicesCount: number;
  4464. instancingBorderAttributes: InstancingAttributeInfo[];
  4465. effectBorder: Effect;
  4466. effectBorderInstanced: Effect;
  4467. constructor(engine: Engine, modelKey: string);
  4468. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  4469. dispose(): boolean;
  4470. }
  4471. class Rectangle2DInstanceData extends Shape2DInstanceData {
  4472. constructor(partId: number);
  4473. properties: Vector3;
  4474. }
  4475. class Rectangle2D extends Shape2D {
  4476. static actualSizeProperty: Prim2DPropInfo;
  4477. static notRoundedProperty: Prim2DPropInfo;
  4478. static roundRadiusProperty: Prim2DPropInfo;
  4479. actualSize: Size;
  4480. notRounded: boolean;
  4481. roundRadius: number;
  4482. private static _i0;
  4483. private static _i1;
  4484. private static _i2;
  4485. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  4486. protected updateLevelBoundingInfo(): void;
  4487. /**
  4488. * Create an Rectangle 2D Shape primitive. May be a sharp rectangle (with sharp corners), or a rounded one.
  4489. * @param settings a combination of settings, possible ones are
  4490. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  4491. * - children: an array of direct children
  4492. * - id a text identifier, for information purpose
  4493. * - position: the X & Y positions relative to its parent. Alternatively the x and y settings can be set. Default is [0;0]
  4494. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  4495. * - scale: the initial scale of the primitive. default is 1
  4496. * - origin: define the normalized origin point location, default [0.5;0.5]
  4497. * - size: the size of the group. Alternatively the width and height settings can be set. Default will be [10;10].
  4498. * - roundRadius: if the rectangle has rounded corner, set their radius, default is 0 (to get a sharp edges rectangle).
  4499. * - fill: the brush used to draw the fill content of the rectangle, you can set null to draw nothing (but you will have to set a border brush), default is a SolidColorBrush of plain white. can also be a string value (see Canvas2D.GetBrushFromString)
  4500. * - border: the brush used to draw the border of the rectangle, you can set null to draw nothing (but you will have to set a fill brush), default is null. can also be a string value (see Canvas2D.GetBrushFromString)
  4501. * - borderThickness: the thickness of the drawn border, default is 1.
  4502. * - isVisible: true if the primitive must be visible, false for hidden. Default is true.
  4503. * - childrenFlatZOrder: if true all the children (direct and indirect) will share the same Z-Order. Use this when there's a lot of children which don't overlap. The drawing order IS NOT GUARANTED!
  4504. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4505. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4506. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4507. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4508. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  4509. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  4510. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  4511. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  4512. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4513. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4514. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4515. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4516. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  4517. */
  4518. constructor(settings?: {
  4519. parent?: Prim2DBase;
  4520. children?: Array<Prim2DBase>;
  4521. id?: string;
  4522. position?: Vector2;
  4523. x?: number;
  4524. y?: number;
  4525. rotation?: number;
  4526. scale?: number;
  4527. origin?: Vector2;
  4528. size?: Size;
  4529. width?: number;
  4530. height?: number;
  4531. roundRadius?: number;
  4532. fill?: IBrush2D | string;
  4533. border?: IBrush2D | string;
  4534. borderThickness?: number;
  4535. isVisible?: boolean;
  4536. childrenFlatZOrder?: boolean;
  4537. marginTop?: number | string;
  4538. marginLeft?: number | string;
  4539. marginRight?: number | string;
  4540. marginBottom?: number | string;
  4541. margin?: number | string;
  4542. marginHAlignment?: number;
  4543. marginVAlignment?: number;
  4544. marginAlignment?: string;
  4545. paddingTop?: number | string;
  4546. paddingLeft?: number | string;
  4547. paddingRight?: number | string;
  4548. paddingBottom?: number | string;
  4549. padding?: string;
  4550. });
  4551. static roundSubdivisions: number;
  4552. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  4553. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Rectangle2DRenderCache;
  4554. protected _getInitialContentAreaToRef(primSize: Size, initialContentPosition: Vector2, initialContentArea: Size): void;
  4555. protected _getActualSizeFromContentToRef(primSize: Size, newPrimSize: Size): void;
  4556. protected createInstanceDataParts(): InstanceDataBase[];
  4557. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  4558. private _notRounded;
  4559. private _roundRadius;
  4560. }
  4561. }
  4562. declare module BABYLON {
  4563. class InstanceClassInfo {
  4564. constructor(base: InstanceClassInfo);
  4565. mapProperty(propInfo: InstancePropInfo, push: boolean): void;
  4566. getInstancingAttributeInfos(effect: Effect, categories: string[]): InstancingAttributeInfo[];
  4567. getShaderAttributes(categories: string[]): string[];
  4568. private _getBaseOffset(categories);
  4569. static _CurCategories: string;
  4570. private _baseInfo;
  4571. private _nextOffset;
  4572. private _attributes;
  4573. }
  4574. class InstancePropInfo {
  4575. attributeName: string;
  4576. category: string;
  4577. size: number;
  4578. shaderOffset: number;
  4579. instanceOffset: StringDictionary<number>;
  4580. dataType: ShaderDataType;
  4581. delimitedCategory: string;
  4582. constructor();
  4583. setSize(val: any): void;
  4584. writeData(array: Float32Array, offset: number, val: any): void;
  4585. }
  4586. function instanceData<T>(category?: string, shaderAttributeName?: string): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4587. class InstanceDataBase {
  4588. constructor(partId: number, dataElementCount: number);
  4589. id: number;
  4590. isVisible: boolean;
  4591. zBias: Vector2;
  4592. transformX: Vector4;
  4593. transformY: Vector4;
  4594. getClassTreeInfo(): ClassTreeInfo<InstanceClassInfo, InstancePropInfo>;
  4595. allocElements(): void;
  4596. freeElements(): void;
  4597. dataElementCount: number;
  4598. curElement: number;
  4599. dataElements: DynamicFloatArrayElementInfo[];
  4600. dataBuffer: DynamicFloatArray;
  4601. typeInfo: ClassTreeInfo<InstanceClassInfo, InstancePropInfo>;
  4602. private _dataElementCount;
  4603. }
  4604. abstract class RenderablePrim2D extends Prim2DBase {
  4605. static RENDERABLEPRIM2D_PROPCOUNT: number;
  4606. static isAlphaTestProperty: Prim2DPropInfo;
  4607. static isTransparentProperty: Prim2DPropInfo;
  4608. isAlphaTest: boolean;
  4609. isTransparent: boolean;
  4610. constructor(settings?: {
  4611. parent?: Prim2DBase;
  4612. id?: string;
  4613. origin?: Vector2;
  4614. isVisible?: boolean;
  4615. });
  4616. /**
  4617. * Dispose the primitive and its resources, remove it from its parent
  4618. */
  4619. dispose(): boolean;
  4620. _prepareRenderPre(context: PrepareRender2DContext): void;
  4621. private _createModelRenderCache();
  4622. private _createModelDataParts();
  4623. private _setupModelRenderCache(parts);
  4624. protected onZOrderChanged(): void;
  4625. private _updateInstanceDataParts(gii);
  4626. _getFirstIndexInDataBuffer(): number;
  4627. _getLastIndexInDataBuffer(): number;
  4628. _getNextPrimZOrder(): number;
  4629. _getPrevPrimZOrder(): number;
  4630. /**
  4631. * Transform a given point using the Primitive's origin setting.
  4632. * This method requires the Primitive's actualSize to be accurate
  4633. * @param p the point to transform
  4634. * @param originOffset an offset applied on the current origin before performing the transformation. Depending on which frame of reference your data is expressed you may have to apply a offset. (if you data is expressed from the bottom/left, no offset is required. If it's expressed from the center the a [-0.5;-0.5] offset has to be applied.
  4635. * @param res an allocated Vector2 that will receive the transformed content
  4636. */
  4637. protected transformPointWithOriginByRef(p: Vector2, originOffset: Vector2, res: Vector2): void;
  4638. protected transformPointWithOriginToRef(p: Vector2, originOffset: Vector2, res: Vector2): Vector2;
  4639. /**
  4640. * Get the info for a given effect based on the dataPart metadata
  4641. * @param dataPartId partId in part list to get the info
  4642. * @param vertexBufferAttributes vertex buffer attributes to manually add
  4643. * @param useInstanced specified if Instanced Array should be used, if null the engine caps will be used (so true if WebGL supports it, false otherwise), but you have the possibility to override the engine capability. However, if you manually set true but the engine does not support Instanced Array, this method will return null
  4644. */
  4645. protected getDataPartEffectInfo(dataPartId: number, vertexBufferAttributes: string[], useInstanced?: boolean): {
  4646. attributes: string[];
  4647. uniforms: string[];
  4648. defines: string;
  4649. };
  4650. protected modelRenderCache: ModelRenderCache;
  4651. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  4652. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): void;
  4653. protected createInstanceDataParts(): InstanceDataBase[];
  4654. protected getUsedShaderCategories(dataPart: InstanceDataBase): string[];
  4655. protected beforeRefreshForLayoutConstruction(part: InstanceDataBase): any;
  4656. protected afterRefreshForLayoutConstruction(part: InstanceDataBase, obj: any): void;
  4657. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  4658. /**
  4659. * Update the instanceDataBase level properties of a part
  4660. * @param part the part to update
  4661. * @param positionOffset to use in multi part per primitive (e.g. the Text2D has N parts for N letter to display), this give the offset to apply (e.g. the position of the letter from the bottom/left corner of the text).
  4662. */
  4663. protected updateInstanceDataPart(part: InstanceDataBase, positionOffset?: Vector2): void;
  4664. private _modelRenderCache;
  4665. private _modelRenderInstanceID;
  4666. private _transparentPrimitiveInfo;
  4667. protected _instanceDataParts: InstanceDataBase[];
  4668. protected _isAlphaTest: boolean;
  4669. protected _isTransparent: boolean;
  4670. }
  4671. }
  4672. declare module BABYLON {
  4673. abstract class Shape2D extends RenderablePrim2D {
  4674. static SHAPE2D_BORDERPARTID: number;
  4675. static SHAPE2D_FILLPARTID: number;
  4676. static SHAPE2D_CATEGORY_BORDER: string;
  4677. static SHAPE2D_CATEGORY_BORDERSOLID: string;
  4678. static SHAPE2D_CATEGORY_BORDERGRADIENT: string;
  4679. static SHAPE2D_CATEGORY_FILLSOLID: string;
  4680. static SHAPE2D_CATEGORY_FILLGRADIENT: string;
  4681. static SHAPE2D_PROPCOUNT: number;
  4682. static borderProperty: Prim2DPropInfo;
  4683. static fillProperty: Prim2DPropInfo;
  4684. static borderThicknessProperty: Prim2DPropInfo;
  4685. border: IBrush2D;
  4686. /**
  4687. * Get/set the brush to render the Fill part of the Primitive
  4688. */
  4689. fill: IBrush2D;
  4690. borderThickness: number;
  4691. constructor(settings?: {
  4692. fill?: IBrush2D | string;
  4693. border?: IBrush2D | string;
  4694. borderThickness?: number;
  4695. });
  4696. protected getUsedShaderCategories(dataPart: InstanceDataBase): string[];
  4697. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  4698. private _updateTransparencyStatus();
  4699. private _border;
  4700. private _borderThickness;
  4701. private _fill;
  4702. }
  4703. class Shape2DInstanceData extends InstanceDataBase {
  4704. fillSolidColor: Color4;
  4705. fillGradientColor1: Color4;
  4706. fillGradientColor2: Color4;
  4707. fillGradientTY: Vector4;
  4708. borderThickness: number;
  4709. borderSolidColor: Color4;
  4710. borderGradientColor1: Color4;
  4711. borderGradientColor2: Color4;
  4712. borderGradientTY: Vector4;
  4713. }
  4714. }
  4715. declare module BABYLON {
  4716. class Prim2DClassInfo {
  4717. }
  4718. class Prim2DPropInfo {
  4719. static PROPKIND_MODEL: number;
  4720. static PROPKIND_INSTANCE: number;
  4721. static PROPKIND_DYNAMIC: number;
  4722. id: number;
  4723. flagId: number;
  4724. kind: number;
  4725. name: string;
  4726. dirtyBoundingInfo: boolean;
  4727. dirtyParentBoundingInfo: boolean;
  4728. typeLevelCompare: boolean;
  4729. }
  4730. /**
  4731. * Custom type of the propertyChanged observable
  4732. */
  4733. class PropertyChangedInfo {
  4734. /**
  4735. * Previous value of the property
  4736. */
  4737. oldValue: any;
  4738. /**
  4739. * New value of the property
  4740. */
  4741. newValue: any;
  4742. /**
  4743. * Name of the property that changed its value
  4744. */
  4745. propertyName: string;
  4746. }
  4747. /**
  4748. * Property Changed interface
  4749. */
  4750. interface IPropertyChanged {
  4751. /**
  4752. * PropertyChanged observable
  4753. */
  4754. propertyChanged: Observable<PropertyChangedInfo>;
  4755. }
  4756. class ClassTreeInfo<TClass, TProp> {
  4757. constructor(baseClass: ClassTreeInfo<TClass, TProp>, type: Object, classContentFactory: (base: TClass) => TClass);
  4758. classContent: TClass;
  4759. type: Object;
  4760. levelContent: StringDictionary<TProp>;
  4761. fullContent: StringDictionary<TProp>;
  4762. getLevelOf(type: Object): ClassTreeInfo<TClass, TProp>;
  4763. getOrAddType(baseType: Object, type: Object): ClassTreeInfo<TClass, TProp>;
  4764. static get<TClass, TProp>(type: Object): ClassTreeInfo<TClass, TProp>;
  4765. static getOrRegister<TClass, TProp>(type: Object, classContentFactory: (base: TClass) => TClass): ClassTreeInfo<TClass, TProp>;
  4766. private _type;
  4767. private _classContent;
  4768. private _baseClass;
  4769. private _subClasses;
  4770. private _levelContent;
  4771. private _fullContent;
  4772. private _classContentFactory;
  4773. }
  4774. abstract class SmartPropertyPrim implements IPropertyChanged {
  4775. constructor();
  4776. /**
  4777. * An observable that is triggered when a property (using of the XXXXLevelProperty decorator) has its value changing.
  4778. * You can add an observer that will be triggered only for a given set of Properties using the Mask feature of the Observable and the corresponding Prim2DPropInfo.flagid value (e.g. Prim2DBase.positionProperty.flagid|Prim2DBase.rotationProperty.flagid to be notified only about position or rotation change)
  4779. */
  4780. propertyChanged: Observable<PropertyChangedInfo>;
  4781. /**
  4782. * Check if the object is disposed or not.
  4783. * @returns true if the object is dispose, false otherwise.
  4784. */
  4785. isDisposed: boolean;
  4786. /**
  4787. * Disposable pattern, this method must be overloaded by derived types in order to clean up hardware related resources.
  4788. * @returns false if the object is already dispose, true otherwise. Your implementation must call super.dispose() and check for a false return and return immediately if it's the case.
  4789. */
  4790. dispose(): boolean;
  4791. /**
  4792. * Animation array, more info: http://doc.babylonjs.com/tutorials/Animations
  4793. */
  4794. animations: Animation[];
  4795. /**
  4796. * Returns as a new array populated with the Animatable used by the primitive. Must be overloaded by derived primitives.
  4797. * Look at Sprite2D for more information
  4798. */
  4799. getAnimatables(): IAnimatable[];
  4800. /**
  4801. * Property giving the Model Key associated to the property.
  4802. * This value is constructed from the type of the primitive and all the name/value of its properties declared with the modelLevelProperty decorator
  4803. * @returns the model key string.
  4804. */
  4805. modelKey: string;
  4806. /**
  4807. * States if the Primitive is dirty and should be rendered again next time.
  4808. * @returns true is dirty, false otherwise
  4809. */
  4810. isDirty: boolean;
  4811. /**
  4812. * Access the dictionary of properties metadata. Only properties decorated with XXXXLevelProperty are concerned
  4813. * @returns the dictionary, the key is the property name as declared in Javascript, the value is the metadata object
  4814. */
  4815. private propDic;
  4816. private static _createPropInfo(target, propName, propId, dirtyBoundingInfo, dirtyParentBoundingBox, typeLevelCompare, kind);
  4817. private static _checkUnchanged(curValue, newValue);
  4818. private static propChangedInfo;
  4819. markAsDirty(propertyName: string): void;
  4820. protected _boundingBoxDirty(): void;
  4821. private _handlePropChanged<T>(curValue, newValue, propName, propInfo, typeLevelCompare);
  4822. protected onPrimitivePropertyDirty(propFlagId: number): void;
  4823. protected handleGroupChanged(prop: Prim2DPropInfo): void;
  4824. /**
  4825. * Check if a given set of properties are dirty or not.
  4826. * @param flags a ORed combination of Prim2DPropInfo.flagId values
  4827. * @return true if at least one property is dirty, false if none of them are.
  4828. */
  4829. checkPropertiesDirty(flags: number): boolean;
  4830. /**
  4831. * Clear a given set of properties.
  4832. * @param flags a ORed combination of Prim2DPropInfo.flagId values
  4833. * @return the new set of property still marked as dirty
  4834. */
  4835. protected clearPropertiesDirty(flags: number): number;
  4836. _resetPropertiesDirty(): void;
  4837. /**
  4838. * Retrieve the boundingInfo for this Primitive, computed based on the primitive itself and NOT its children
  4839. */
  4840. levelBoundingInfo: BoundingInfo2D;
  4841. /**
  4842. * This method must be overridden by a given Primitive implementation to compute its boundingInfo
  4843. */
  4844. protected updateLevelBoundingInfo(): void;
  4845. /**
  4846. * Property method called when the Primitive becomes dirty
  4847. */
  4848. protected onPrimBecomesDirty(): void;
  4849. static _hookProperty<T>(propId: number, piStore: (pi: Prim2DPropInfo) => void, typeLevelCompare: boolean, dirtyBoundingInfo: boolean, dirtyParentBoundingBox: boolean, kind: number): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4850. /**
  4851. * Add an externally attached data from its key.
  4852. * This method call will fail and return false, if such key already exists.
  4853. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  4854. * @param key the unique key that identifies the data
  4855. * @param data the data object to associate to the key for this Engine instance
  4856. * @return true if no such key were already present and the data was added successfully, false otherwise
  4857. */
  4858. addExternalData<T>(key: string, data: T): boolean;
  4859. /**
  4860. * Get an externally attached data from its key
  4861. * @param key the unique key that identifies the data
  4862. * @return the associated data, if present (can be null), or undefined if not present
  4863. */
  4864. getExternalData<T>(key: string): T;
  4865. /**
  4866. * Get an externally attached data from its key, create it using a factory if it's not already present
  4867. * @param key the unique key that identifies the data
  4868. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  4869. * @return the associated data, can be null if the factory returned null.
  4870. */
  4871. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  4872. /**
  4873. * Remove an externally attached data from the Engine instance
  4874. * @param key the unique key that identifies the data
  4875. * @return true if the data was successfully removed, false if it doesn't exist
  4876. */
  4877. removeExternalData(key: any): boolean;
  4878. /**
  4879. * Check if a given flag is set
  4880. * @param flag the flag value
  4881. * @return true if set, false otherwise
  4882. */
  4883. _isFlagSet(flag: number): boolean;
  4884. /**
  4885. * Check if all given flags are set
  4886. * @param flags the flags ORed
  4887. * @return true if all the flags are set, false otherwise
  4888. */
  4889. _areAllFlagsSet(flags: number): boolean;
  4890. /**
  4891. * Check if at least one flag of the given flags is set
  4892. * @param flags the flags ORed
  4893. * @return true if at least one flag is set, false otherwise
  4894. */
  4895. _areSomeFlagsSet(flags: number): boolean;
  4896. /**
  4897. * Clear the given flags
  4898. * @param flags the flags to clear
  4899. */
  4900. _clearFlags(flags: number): void;
  4901. /**
  4902. * Set the given flags to true state
  4903. * @param flags the flags ORed to set
  4904. * @return the flags state before this call
  4905. */
  4906. _setFlags(flags: number): number;
  4907. /**
  4908. * Change the state of the given flags
  4909. * @param flags the flags ORed to change
  4910. * @param state true to set them, false to clear them
  4911. */
  4912. _changeFlags(flags: number, state: boolean): void;
  4913. static flagIsDisposed: number;
  4914. static flagLevelBoundingInfoDirty: number;
  4915. static flagModelDirty: number;
  4916. static flagLayoutDirty: number;
  4917. static flagLevelVisible: number;
  4918. static flagBoundingInfoDirty: number;
  4919. static flagIsPickable: number;
  4920. static flagIsVisible: number;
  4921. static flagVisibilityChanged: number;
  4922. static flagPositioningDirty: number;
  4923. static flagTrackedGroup: number;
  4924. static flagWorldCacheChanged: number;
  4925. static flagChildrenFlatZOrder: number;
  4926. static flagZOrderDirty: number;
  4927. private _flags;
  4928. private _externalData;
  4929. private _modelKey;
  4930. private _propInfo;
  4931. protected _levelBoundingInfo: BoundingInfo2D;
  4932. protected _boundingInfo: BoundingInfo2D;
  4933. protected _instanceDirtyFlags: number;
  4934. }
  4935. function modelLevelProperty<T>(propId: number, piStore: (pi: Prim2DPropInfo) => void, typeLevelCompare?: boolean, dirtyBoundingInfo?: boolean, dirtyParentBoundingBox?: boolean): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4936. function instanceLevelProperty<T>(propId: number, piStore: (pi: Prim2DPropInfo) => void, typeLevelCompare?: boolean, dirtyBoundingInfo?: boolean, dirtyParentBoundingBox?: boolean): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4937. function dynamicLevelProperty<T>(propId: number, piStore: (pi: Prim2DPropInfo) => void, typeLevelCompare?: boolean, dirtyBoundingInfo?: boolean, dirtyParentBoundingBox?: boolean): (target: Object, propName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => void;
  4938. }
  4939. declare module BABYLON {
  4940. class Sprite2DRenderCache extends ModelRenderCache {
  4941. effectsReady: boolean;
  4942. vb: WebGLBuffer;
  4943. ib: WebGLBuffer;
  4944. instancingAttributes: InstancingAttributeInfo[];
  4945. texture: Texture;
  4946. effect: Effect;
  4947. effectInstanced: Effect;
  4948. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  4949. dispose(): boolean;
  4950. }
  4951. class Sprite2DInstanceData extends InstanceDataBase {
  4952. constructor(partId: number);
  4953. topLeftUV: Vector2;
  4954. sizeUV: Vector2;
  4955. textureSize: Vector2;
  4956. properties: Vector3;
  4957. }
  4958. class Sprite2D extends RenderablePrim2D {
  4959. static SPRITE2D_MAINPARTID: number;
  4960. static textureProperty: Prim2DPropInfo;
  4961. static actualSizeProperty: Prim2DPropInfo;
  4962. static spriteLocationProperty: Prim2DPropInfo;
  4963. static spriteFrameProperty: Prim2DPropInfo;
  4964. static invertYProperty: Prim2DPropInfo;
  4965. static alignToPixelProperty: Prim2DPropInfo;
  4966. texture: Texture;
  4967. actualSize: Size;
  4968. spriteLocation: Vector2;
  4969. spriteFrame: number;
  4970. invertY: boolean;
  4971. /**
  4972. * Get/set if the sprite rendering should be aligned to the target rendering device pixel or not
  4973. */
  4974. alignToPixel: boolean;
  4975. protected updateLevelBoundingInfo(): void;
  4976. /**
  4977. * Get the animatable array (see http://doc.babylonjs.com/tutorials/Animations)
  4978. */
  4979. getAnimatables(): IAnimatable[];
  4980. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  4981. /**
  4982. * Create an 2D Sprite primitive
  4983. * @param texture the texture that stores the sprite to render
  4984. * @param settings a combination of settings, possible ones are
  4985. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  4986. * - children: an array of direct children
  4987. * - id a text identifier, for information purpose
  4988. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  4989. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  4990. * - scale: the initial scale of the primitive. default is 1
  4991. * - origin: define the normalized origin point location, default [0.5;0.5]
  4992. * - spriteSize: the size of the sprite (in pixels), if null the size of the given texture will be used, default is null.
  4993. * - spriteLocation: the location (in pixels) in the texture of the top/left corner of the Sprite to display, default is null (0,0)
  4994. * - invertY: if true the texture Y will be inverted, default is false.
  4995. * - alignToPixel: if true the sprite's texels will be aligned to the rendering viewport pixels, ensuring the best rendering quality but slow animations won't be done as smooth as if you set false. If false a texel could lies between two pixels, being blended by the texture sampling mode you choose, the rendering result won't be as good, but very slow animation will be overall better looking. Default is true: content will be aligned.
  4996. * - isVisible: true if the sprite must be visible, false for hidden. Default is true.
  4997. * - childrenFlatZOrder: if true all the children (direct and indirect) will share the same Z-Order. Use this when there's a lot of children which don't overlap. The drawing order IS NOT GUARANTED!
  4998. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  4999. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5000. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5001. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5002. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  5003. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  5004. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  5005. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  5006. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5007. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5008. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5009. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5010. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  5011. */
  5012. constructor(texture: Texture, settings?: {
  5013. parent?: Prim2DBase;
  5014. children?: Array<Prim2DBase>;
  5015. id?: string;
  5016. position?: Vector2;
  5017. x?: number;
  5018. y?: number;
  5019. rotation?: number;
  5020. scale?: number;
  5021. origin?: Vector2;
  5022. spriteSize?: Size;
  5023. spriteLocation?: Vector2;
  5024. invertY?: boolean;
  5025. alignToPixel?: boolean;
  5026. isVisible?: boolean;
  5027. childrenFlatZOrder?: boolean;
  5028. marginTop?: number | string;
  5029. marginLeft?: number | string;
  5030. marginRight?: number | string;
  5031. marginBottom?: number | string;
  5032. margin?: number | string;
  5033. marginHAlignment?: number;
  5034. marginVAlignment?: number;
  5035. marginAlignment?: string;
  5036. paddingTop?: number | string;
  5037. paddingLeft?: number | string;
  5038. paddingRight?: number | string;
  5039. paddingBottom?: number | string;
  5040. padding?: string;
  5041. });
  5042. static _createCachedCanvasSprite(owner: Canvas2D, texture: MapTexture, size: Size, pos: Vector2): Sprite2D;
  5043. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  5044. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Sprite2DRenderCache;
  5045. protected createInstanceDataParts(): InstanceDataBase[];
  5046. private static _prop;
  5047. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  5048. private _texture;
  5049. private _location;
  5050. private _spriteFrame;
  5051. private _invertY;
  5052. private _alignToPixel;
  5053. }
  5054. }
  5055. declare module BABYLON {
  5056. class Text2DRenderCache extends ModelRenderCache {
  5057. effectsReady: boolean;
  5058. vb: WebGLBuffer;
  5059. ib: WebGLBuffer;
  5060. instancingAttributes: InstancingAttributeInfo[];
  5061. fontTexture: FontTexture;
  5062. effect: Effect;
  5063. effectInstanced: Effect;
  5064. render(instanceInfo: GroupInstanceInfo, context: Render2DContext): boolean;
  5065. dispose(): boolean;
  5066. }
  5067. class Text2DInstanceData extends InstanceDataBase {
  5068. constructor(partId: number, dataElementCount: number);
  5069. topLeftUV: Vector2;
  5070. sizeUV: Vector2;
  5071. textureSize: Vector2;
  5072. color: Color4;
  5073. superSampleFactor: number;
  5074. }
  5075. class Text2D extends RenderablePrim2D {
  5076. static TEXT2D_MAINPARTID: number;
  5077. static fontProperty: Prim2DPropInfo;
  5078. static defaultFontColorProperty: Prim2DPropInfo;
  5079. static textProperty: Prim2DPropInfo;
  5080. static sizeProperty: Prim2DPropInfo;
  5081. fontName: string;
  5082. defaultFontColor: Color4;
  5083. text: string;
  5084. size: Size;
  5085. /**
  5086. * Get the actual size of the Text2D primitive
  5087. */
  5088. actualSize: Size;
  5089. /**
  5090. * Get the area that bounds the text associated to the primitive
  5091. */
  5092. textSize: Size;
  5093. protected fontTexture: FontTexture;
  5094. /**
  5095. * Dispose the primitive, remove it from its parent
  5096. */
  5097. dispose(): boolean;
  5098. protected updateLevelBoundingInfo(): void;
  5099. /**
  5100. * Create a Text primitive
  5101. * @param text the text to display
  5102. * @param settings a combination of settings, possible ones are
  5103. * - parent: the parent primitive/canvas, must be specified if the primitive is not constructed as a child of another one (i.e. as part of the children array setting)
  5104. * - children: an array of direct children
  5105. * - id a text identifier, for information purpose
  5106. * - position: the X & Y positions relative to its parent. Alternatively the x and y properties can be set. Default is [0;0]
  5107. * - rotation: the initial rotation (in radian) of the primitive. default is 0
  5108. * - scale: the initial scale of the primitive. default is 1
  5109. * - origin: define the normalized origin point location, default [0.5;0.5]
  5110. * - fontName: the name/size/style of the font to use, following the CSS notation. Default is "12pt Arial".
  5111. * - fontSuperSample: if true the text will be rendered with a superSampled font (the font is twice the given size). Use this settings if the text lies in world space or if it's scaled in.
  5112. * - defaultColor: the color by default to apply on each letter of the text to display, default is plain white.
  5113. * - areaSize: the size of the area in which to display the text, default is auto-fit from text content.
  5114. * - tabulationSize: number of space character to insert when a tabulation is encountered, default is 4
  5115. * - isVisible: true if the text must be visible, false for hidden. Default is true.
  5116. * - childrenFlatZOrder: if true all the children (direct and indirect) will share the same Z-Order. Use this when there's a lot of children which don't overlap. The drawing order IS NOT GUARANTED!
  5117. * - marginTop: top margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5118. * - marginLeft: left margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5119. * - marginRight: right margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5120. * - marginBottom: bottom margin, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5121. * - margin: top, left, right and bottom margin formatted as a single string (see PrimitiveThickness.fromString)
  5122. * - marginHAlignment: one value of the PrimitiveAlignment type's static properties
  5123. * - marginVAlignment: one value of the PrimitiveAlignment type's static properties
  5124. * - marginAlignment: a string defining the alignment, see PrimitiveAlignment.fromString
  5125. * - paddingTop: top padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5126. * - paddingLeft: left padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5127. * - paddingRight: right padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5128. * - paddingBottom: bottom padding, can be a number (will be pixels) or a string (see PrimitiveThickness.fromString)
  5129. * - padding: top, left, right and bottom padding formatted as a single string (see PrimitiveThickness.fromString)
  5130. */
  5131. constructor(text: string, settings?: {
  5132. parent?: Prim2DBase;
  5133. children?: Array<Prim2DBase>;
  5134. id?: string;
  5135. position?: Vector2;
  5136. x?: number;
  5137. y?: number;
  5138. rotation?: number;
  5139. scale?: number;
  5140. origin?: Vector2;
  5141. fontName?: string;
  5142. fontSuperSample?: boolean;
  5143. defaultFontColor?: Color4;
  5144. size?: Size;
  5145. tabulationSize?: number;
  5146. isVisible?: boolean;
  5147. childrenFlatZOrder?: boolean;
  5148. marginTop?: number | string;
  5149. marginLeft?: number | string;
  5150. marginRight?: number | string;
  5151. marginBottom?: number | string;
  5152. margin?: number | string;
  5153. marginHAlignment?: number;
  5154. marginVAlignment?: number;
  5155. marginAlignment?: string;
  5156. paddingTop?: number | string;
  5157. paddingLeft?: number | string;
  5158. paddingRight?: number | string;
  5159. paddingBottom?: number | string;
  5160. padding?: string;
  5161. });
  5162. protected levelIntersect(intersectInfo: IntersectInfo2D): boolean;
  5163. protected createModelRenderCache(modelKey: string): ModelRenderCache;
  5164. protected setupModelRenderCache(modelRenderCache: ModelRenderCache): Text2DRenderCache;
  5165. protected createInstanceDataParts(): InstanceDataBase[];
  5166. protected beforeRefreshForLayoutConstruction(part: InstanceDataBase): any;
  5167. protected afterRefreshForLayoutConstruction(part: InstanceDataBase, obj: any): void;
  5168. protected refreshInstanceDataPart(part: InstanceDataBase): boolean;
  5169. private _updateCharCount();
  5170. private _fontTexture;
  5171. private _tabulationSize;
  5172. private _charCount;
  5173. private _fontName;
  5174. private _fontSuperSample;
  5175. private _defaultFontColor;
  5176. private _text;
  5177. private _textSize;
  5178. }
  5179. }
  5180. declare module BABYLON {
  5181. /**
  5182. * This is the class that is used to display a World Space Canvas into a 3D scene
  5183. */
  5184. class WorldSpaceCanvas2DNode extends Mesh {
  5185. constructor(name: string, scene: Scene, canvas: Canvas2D);
  5186. dispose(): void;
  5187. private _canvas;
  5188. }
  5189. }
  5190. declare module BABYLON {
  5191. class Collider {
  5192. radius: Vector3;
  5193. retry: number;
  5194. velocity: Vector3;
  5195. basePoint: Vector3;
  5196. epsilon: number;
  5197. collisionFound: boolean;
  5198. velocityWorldLength: number;
  5199. basePointWorld: Vector3;
  5200. velocityWorld: Vector3;
  5201. normalizedVelocity: Vector3;
  5202. initialVelocity: Vector3;
  5203. initialPosition: Vector3;
  5204. nearestDistance: number;
  5205. intersectionPoint: Vector3;
  5206. collidedMesh: AbstractMesh;
  5207. private _collisionPoint;
  5208. private _planeIntersectionPoint;
  5209. private _tempVector;
  5210. private _tempVector2;
  5211. private _tempVector3;
  5212. private _tempVector4;
  5213. private _edge;
  5214. private _baseToVertex;
  5215. private _destinationPoint;
  5216. private _slidePlaneNormal;
  5217. private _displacementVector;
  5218. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5219. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5220. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5221. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5222. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: number[] | Int32Array, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5223. _getResponse(pos: Vector3, vel: Vector3): void;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. var CollisionWorker: string;
  5228. interface ICollisionCoordinator {
  5229. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  5230. init(scene: Scene): void;
  5231. destroy(): void;
  5232. onMeshAdded(mesh: AbstractMesh): any;
  5233. onMeshUpdated(mesh: AbstractMesh): any;
  5234. onMeshRemoved(mesh: AbstractMesh): any;
  5235. onGeometryAdded(geometry: Geometry): any;
  5236. onGeometryUpdated(geometry: Geometry): any;
  5237. onGeometryDeleted(geometry: Geometry): any;
  5238. }
  5239. interface SerializedMesh {
  5240. id: string;
  5241. name: string;
  5242. uniqueId: number;
  5243. geometryId: string;
  5244. sphereCenter: Array<number>;
  5245. sphereRadius: number;
  5246. boxMinimum: Array<number>;
  5247. boxMaximum: Array<number>;
  5248. worldMatrixFromCache: any;
  5249. subMeshes: Array<SerializedSubMesh>;
  5250. checkCollisions: boolean;
  5251. }
  5252. interface SerializedSubMesh {
  5253. position: number;
  5254. verticesStart: number;
  5255. verticesCount: number;
  5256. indexStart: number;
  5257. indexCount: number;
  5258. hasMaterial: boolean;
  5259. sphereCenter: Array<number>;
  5260. sphereRadius: number;
  5261. boxMinimum: Array<number>;
  5262. boxMaximum: Array<number>;
  5263. }
  5264. interface SerializedGeometry {
  5265. id: string;
  5266. positions: Float32Array;
  5267. indices: Int32Array;
  5268. normals: Float32Array;
  5269. }
  5270. interface BabylonMessage {
  5271. taskType: WorkerTaskType;
  5272. payload: InitPayload | CollidePayload | UpdatePayload;
  5273. }
  5274. interface SerializedColliderToWorker {
  5275. position: Array<number>;
  5276. velocity: Array<number>;
  5277. radius: Array<number>;
  5278. }
  5279. enum WorkerTaskType {
  5280. INIT = 0,
  5281. UPDATE = 1,
  5282. COLLIDE = 2,
  5283. }
  5284. interface WorkerReply {
  5285. error: WorkerReplyType;
  5286. taskType: WorkerTaskType;
  5287. payload?: any;
  5288. }
  5289. interface CollisionReplyPayload {
  5290. newPosition: Array<number>;
  5291. collisionId: number;
  5292. collidedMeshUniqueId: number;
  5293. }
  5294. interface InitPayload {
  5295. }
  5296. interface CollidePayload {
  5297. collisionId: number;
  5298. collider: SerializedColliderToWorker;
  5299. maximumRetry: number;
  5300. excludedMeshUniqueId?: number;
  5301. }
  5302. interface UpdatePayload {
  5303. updatedMeshes: {
  5304. [n: number]: SerializedMesh;
  5305. };
  5306. updatedGeometries: {
  5307. [s: string]: SerializedGeometry;
  5308. };
  5309. removedMeshes: Array<number>;
  5310. removedGeometries: Array<string>;
  5311. }
  5312. enum WorkerReplyType {
  5313. SUCCESS = 0,
  5314. UNKNOWN_ERROR = 1,
  5315. }
  5316. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5317. private _scene;
  5318. private _scaledPosition;
  5319. private _scaledVelocity;
  5320. private _collisionsCallbackArray;
  5321. private _init;
  5322. private _runningUpdated;
  5323. private _runningCollisionTask;
  5324. private _worker;
  5325. private _addUpdateMeshesList;
  5326. private _addUpdateGeometriesList;
  5327. private _toRemoveMeshesArray;
  5328. private _toRemoveGeometryArray;
  5329. constructor();
  5330. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5331. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5332. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  5333. init(scene: Scene): void;
  5334. destroy(): void;
  5335. onMeshAdded(mesh: AbstractMesh): void;
  5336. onMeshUpdated: (mesh: AbstractMesh) => void;
  5337. onMeshRemoved(mesh: AbstractMesh): void;
  5338. onGeometryAdded(geometry: Geometry): void;
  5339. onGeometryUpdated: (geometry: Geometry) => void;
  5340. onGeometryDeleted(geometry: Geometry): void;
  5341. private _afterRender;
  5342. private _onMessageFromWorker;
  5343. }
  5344. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5345. private _scene;
  5346. private _scaledPosition;
  5347. private _scaledVelocity;
  5348. private _finalPosition;
  5349. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void;
  5350. init(scene: Scene): void;
  5351. destroy(): void;
  5352. onMeshAdded(mesh: AbstractMesh): void;
  5353. onMeshUpdated(mesh: AbstractMesh): void;
  5354. onMeshRemoved(mesh: AbstractMesh): void;
  5355. onGeometryAdded(geometry: Geometry): void;
  5356. onGeometryUpdated(geometry: Geometry): void;
  5357. onGeometryDeleted(geometry: Geometry): void;
  5358. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5359. }
  5360. }
  5361. declare module BABYLON {
  5362. var WorkerIncluded: boolean;
  5363. class CollisionCache {
  5364. private _meshes;
  5365. private _geometries;
  5366. getMeshes(): {
  5367. [n: number]: SerializedMesh;
  5368. };
  5369. getGeometries(): {
  5370. [s: number]: SerializedGeometry;
  5371. };
  5372. getMesh(id: any): SerializedMesh;
  5373. addMesh(mesh: SerializedMesh): void;
  5374. removeMesh(uniqueId: number): void;
  5375. getGeometry(id: string): SerializedGeometry;
  5376. addGeometry(geometry: SerializedGeometry): void;
  5377. removeGeometry(id: string): void;
  5378. }
  5379. class CollideWorker {
  5380. collider: Collider;
  5381. private _collisionCache;
  5382. private finalPosition;
  5383. private collisionsScalingMatrix;
  5384. private collisionTranformationMatrix;
  5385. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5386. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId?: number): void;
  5387. private checkCollision(mesh);
  5388. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5389. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5390. private checkSubmeshCollision(subMesh);
  5391. }
  5392. interface ICollisionDetector {
  5393. onInit(payload: InitPayload): void;
  5394. onUpdate(payload: UpdatePayload): void;
  5395. onCollision(payload: CollidePayload): void;
  5396. }
  5397. class CollisionDetectorTransferable implements ICollisionDetector {
  5398. private _collisionCache;
  5399. onInit(payload: InitPayload): void;
  5400. onUpdate(payload: UpdatePayload): void;
  5401. onCollision(payload: CollidePayload): void;
  5402. }
  5403. }
  5404. declare module BABYLON {
  5405. class IntersectionInfo {
  5406. bu: number;
  5407. bv: number;
  5408. distance: number;
  5409. faceId: number;
  5410. subMeshId: number;
  5411. constructor(bu: number, bv: number, distance: number);
  5412. }
  5413. class PickingInfo {
  5414. hit: boolean;
  5415. distance: number;
  5416. pickedPoint: Vector3;
  5417. pickedMesh: AbstractMesh;
  5418. bu: number;
  5419. bv: number;
  5420. faceId: number;
  5421. subMeshId: number;
  5422. pickedSprite: Sprite;
  5423. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Vector3;
  5424. getTextureCoordinates(): Vector2;
  5425. }
  5426. }
  5427. declare module BABYLON {
  5428. class BoundingBox implements ICullable {
  5429. minimum: Vector3;
  5430. maximum: Vector3;
  5431. vectors: Vector3[];
  5432. center: Vector3;
  5433. extendSize: Vector3;
  5434. directions: Vector3[];
  5435. vectorsWorld: Vector3[];
  5436. minimumWorld: Vector3;
  5437. maximumWorld: Vector3;
  5438. private _worldMatrix;
  5439. constructor(minimum: Vector3, maximum: Vector3);
  5440. getWorldMatrix(): Matrix;
  5441. setWorldMatrix(matrix: Matrix): BoundingBox;
  5442. _update(world: Matrix): void;
  5443. isInFrustum(frustumPlanes: Plane[]): boolean;
  5444. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5445. intersectsPoint(point: Vector3): boolean;
  5446. intersectsSphere(sphere: BoundingSphere): boolean;
  5447. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5448. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5449. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5450. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5451. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5452. }
  5453. }
  5454. declare module BABYLON {
  5455. interface ICullable {
  5456. isInFrustum(frustumPlanes: Plane[]): boolean;
  5457. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5458. }
  5459. class BoundingInfo implements ICullable {
  5460. minimum: Vector3;
  5461. maximum: Vector3;
  5462. boundingBox: BoundingBox;
  5463. boundingSphere: BoundingSphere;
  5464. private _isLocked;
  5465. constructor(minimum: Vector3, maximum: Vector3);
  5466. isLocked: boolean;
  5467. update(world: Matrix): void;
  5468. isInFrustum(frustumPlanes: Plane[]): boolean;
  5469. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5470. _checkCollision(collider: Collider): boolean;
  5471. intersectsPoint(point: Vector3): boolean;
  5472. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5473. }
  5474. }
  5475. declare module BABYLON {
  5476. class BoundingSphere {
  5477. minimum: Vector3;
  5478. maximum: Vector3;
  5479. center: Vector3;
  5480. radius: number;
  5481. centerWorld: Vector3;
  5482. radiusWorld: number;
  5483. private _tempRadiusVector;
  5484. constructor(minimum: Vector3, maximum: Vector3);
  5485. _update(world: Matrix): void;
  5486. isInFrustum(frustumPlanes: Plane[]): boolean;
  5487. intersectsPoint(point: Vector3): boolean;
  5488. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5489. }
  5490. }
  5491. declare module BABYLON {
  5492. class Ray {
  5493. origin: Vector3;
  5494. direction: Vector3;
  5495. length: number;
  5496. private _edge1;
  5497. private _edge2;
  5498. private _pvec;
  5499. private _tvec;
  5500. private _qvec;
  5501. constructor(origin: Vector3, direction: Vector3, length?: number);
  5502. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5503. intersectsBox(box: BoundingBox): boolean;
  5504. intersectsSphere(sphere: BoundingSphere): boolean;
  5505. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo;
  5506. intersectsPlane(plane: Plane): number;
  5507. private static smallnum;
  5508. private static rayl;
  5509. /**
  5510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5511. * @param sega the first point of the segment to test the intersection against
  5512. * @param segb the second point of the segment to test the intersection against
  5513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5515. */
  5516. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5517. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5518. /**
  5519. * 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
  5520. * transformed to the given world matrix.
  5521. * @param origin The origin point
  5522. * @param end The end point
  5523. * @param world a matrix to transform the ray to. Default is the identity matrix.
  5524. */
  5525. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  5526. static Transform(ray: Ray, matrix: Matrix): Ray;
  5527. }
  5528. }
  5529. declare module BABYLON {
  5530. class DebugLayer {
  5531. private _scene;
  5532. private _camera;
  5533. private _transformationMatrix;
  5534. private _enabled;
  5535. private _labelsEnabled;
  5536. private _displayStatistics;
  5537. private _displayTree;
  5538. private _displayLogs;
  5539. private _globalDiv;
  5540. private _statsDiv;
  5541. private _statsSubsetDiv;
  5542. private _optionsDiv;
  5543. private _optionsSubsetDiv;
  5544. private _logDiv;
  5545. private _logSubsetDiv;
  5546. private _treeDiv;
  5547. private _treeSubsetDiv;
  5548. private _drawingCanvas;
  5549. private _drawingContext;
  5550. private _rootElement;
  5551. private _skeletonViewers;
  5552. _syncPositions: () => void;
  5553. private _syncData;
  5554. private _syncUI;
  5555. private _onCanvasClick;
  5556. private _clickPosition;
  5557. private _ratio;
  5558. private _identityMatrix;
  5559. private _showUI;
  5560. private _needToRefreshMeshesTree;
  5561. shouldDisplayLabel: (node: Node) => boolean;
  5562. shouldDisplayAxis: (mesh: Mesh) => boolean;
  5563. axisRatio: number;
  5564. accentColor: string;
  5565. customStatsFunction: () => string;
  5566. constructor(scene: Scene);
  5567. private _refreshMeshesTreeContent();
  5568. private _renderSingleAxis(zero, unit, unitText, label, color);
  5569. private _renderAxis(projectedPosition, mesh, globalViewport);
  5570. private _renderLabel(text, projectedPosition, labelOffset, onClick, getFillStyle);
  5571. private _isClickInsideRect(x, y, width, height);
  5572. isVisible(): boolean;
  5573. hide(): void;
  5574. private _clearSkeletonViewers();
  5575. show(showUI?: boolean, camera?: Camera, rootElement?: HTMLElement): void;
  5576. private _clearLabels();
  5577. private _generateheader(root, text);
  5578. private _generateTexBox(root, title, color);
  5579. private _generateAdvancedCheckBox(root, leftTitle, rightTitle, initialState, task, tag?);
  5580. private _generateCheckBox(root, title, initialState, task, tag?);
  5581. private _generateButton(root, title, task, tag?);
  5582. private _generateRadio(root, title, name, initialState, task, tag?);
  5583. private _generateDOMelements();
  5584. private _displayStats();
  5585. }
  5586. }
  5587. declare module BABYLON.Debug {
  5588. /**
  5589. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  5590. */
  5591. class SkeletonViewer {
  5592. skeleton: Skeleton;
  5593. mesh: AbstractMesh;
  5594. autoUpdateBonesMatrices: boolean;
  5595. renderingGroupId: number;
  5596. color: Color3;
  5597. private _scene;
  5598. private _debugLines;
  5599. private _debugMesh;
  5600. private _isEnabled;
  5601. private _renderFunction;
  5602. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  5603. isEnabled: boolean;
  5604. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  5605. private _getLinesForBonesWithLength(bones, meshMat);
  5606. private _getLinesForBonesNoLength(bones, meshMat);
  5607. update(): void;
  5608. private _updateBoneMatrix(bone);
  5609. dispose(): void;
  5610. }
  5611. }
  5612. declare module BABYLON {
  5613. class Layer {
  5614. name: string;
  5615. texture: Texture;
  5616. isBackground: boolean;
  5617. color: Color4;
  5618. scale: Vector2;
  5619. offset: Vector2;
  5620. alphaBlendingMode: number;
  5621. alphaTest: boolean;
  5622. private _scene;
  5623. private _vertexBuffers;
  5624. private _indexBuffer;
  5625. private _effect;
  5626. private _alphaTestEffect;
  5627. /**
  5628. * An event triggered when the layer is disposed.
  5629. * @type {BABYLON.Observable}
  5630. */
  5631. onDisposeObservable: Observable<Layer>;
  5632. private _onDisposeObserver;
  5633. onDispose: () => void;
  5634. /**
  5635. * An event triggered before rendering the scene
  5636. * @type {BABYLON.Observable}
  5637. */
  5638. onBeforeRenderObservable: Observable<Layer>;
  5639. private _onBeforeRenderObserver;
  5640. onBeforeRender: () => void;
  5641. /**
  5642. * An event triggered after rendering the scene
  5643. * @type {BABYLON.Observable}
  5644. */
  5645. onAfterRenderObservable: Observable<Layer>;
  5646. private _onAfterRenderObserver;
  5647. onAfterRender: () => void;
  5648. constructor(name: string, imgUrl: string, scene: Scene, isBackground?: boolean, color?: Color4);
  5649. render(): void;
  5650. dispose(): void;
  5651. }
  5652. }
  5653. declare module BABYLON {
  5654. class DirectionalLight extends Light implements IShadowLight {
  5655. position: Vector3;
  5656. direction: Vector3;
  5657. private _transformedDirection;
  5658. transformedPosition: Vector3;
  5659. private _worldMatrix;
  5660. shadowOrthoScale: number;
  5661. autoUpdateExtends: boolean;
  5662. private _orthoLeft;
  5663. private _orthoRight;
  5664. private _orthoTop;
  5665. private _orthoBottom;
  5666. constructor(name: string, direction: Vector3, scene: Scene);
  5667. getAbsolutePosition(): Vector3;
  5668. setDirectionToTarget(target: Vector3): Vector3;
  5669. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5670. supportsVSM(): boolean;
  5671. needRefreshPerFrame(): boolean;
  5672. needCube(): boolean;
  5673. getShadowDirection(faceIndex?: number): Vector3;
  5674. computeTransformedPosition(): boolean;
  5675. transferToEffect(effect: Effect, directionUniformName: string): void;
  5676. _getWorldMatrix(): Matrix;
  5677. getTypeID(): number;
  5678. }
  5679. }
  5680. declare module BABYLON {
  5681. class HemisphericLight extends Light {
  5682. groundColor: Color3;
  5683. direction: Vector3;
  5684. private _worldMatrix;
  5685. constructor(name: string, direction: Vector3, scene: Scene);
  5686. setDirectionToTarget(target: Vector3): Vector3;
  5687. getShadowGenerator(): ShadowGenerator;
  5688. transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void;
  5689. _getWorldMatrix(): Matrix;
  5690. getTypeID(): number;
  5691. }
  5692. }
  5693. declare module BABYLON {
  5694. interface IShadowLight {
  5695. id: string;
  5696. position: Vector3;
  5697. transformedPosition: Vector3;
  5698. name: string;
  5699. computeTransformedPosition(): boolean;
  5700. getScene(): Scene;
  5701. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5702. supportsVSM(): boolean;
  5703. needRefreshPerFrame(): boolean;
  5704. needCube(): boolean;
  5705. getShadowDirection(faceIndex?: number): Vector3;
  5706. _shadowGenerator: ShadowGenerator;
  5707. }
  5708. class Light extends Node {
  5709. diffuse: Color3;
  5710. specular: Color3;
  5711. intensity: number;
  5712. range: number;
  5713. includeOnlyWithLayerMask: number;
  5714. includedOnlyMeshes: AbstractMesh[];
  5715. excludedMeshes: AbstractMesh[];
  5716. excludeWithLayerMask: number;
  5717. radius: number;
  5718. _shadowGenerator: ShadowGenerator;
  5719. private _parentedWorldMatrix;
  5720. _excludedMeshesIds: string[];
  5721. _includedOnlyMeshesIds: string[];
  5722. constructor(name: string, scene: Scene);
  5723. /**
  5724. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5725. */
  5726. toString(fullDetails?: boolean): string;
  5727. getShadowGenerator(): ShadowGenerator;
  5728. getAbsolutePosition(): Vector3;
  5729. transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void;
  5730. _getWorldMatrix(): Matrix;
  5731. canAffectMesh(mesh: AbstractMesh): boolean;
  5732. getWorldMatrix(): Matrix;
  5733. dispose(): void;
  5734. getTypeID(): number;
  5735. clone(name: string): Light;
  5736. serialize(): any;
  5737. static GetConstructorFromName(type: number, name: string, scene: Scene): () => Light;
  5738. static Parse(parsedLight: any, scene: Scene): Light;
  5739. }
  5740. }
  5741. declare module BABYLON {
  5742. class PointLight extends Light implements IShadowLight {
  5743. private _worldMatrix;
  5744. transformedPosition: Vector3;
  5745. position: Vector3;
  5746. constructor(name: string, position: Vector3, scene: Scene);
  5747. getAbsolutePosition(): Vector3;
  5748. computeTransformedPosition(): boolean;
  5749. transferToEffect(effect: Effect, positionUniformName: string): void;
  5750. needCube(): boolean;
  5751. supportsVSM(): boolean;
  5752. needRefreshPerFrame(): boolean;
  5753. getShadowDirection(faceIndex?: number): Vector3;
  5754. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5755. _getWorldMatrix(): Matrix;
  5756. getTypeID(): number;
  5757. }
  5758. }
  5759. declare module BABYLON {
  5760. class SpotLight extends Light implements IShadowLight {
  5761. position: Vector3;
  5762. direction: Vector3;
  5763. angle: number;
  5764. exponent: number;
  5765. transformedPosition: Vector3;
  5766. private _transformedDirection;
  5767. private _worldMatrix;
  5768. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  5769. getAbsolutePosition(): Vector3;
  5770. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5771. needCube(): boolean;
  5772. supportsVSM(): boolean;
  5773. needRefreshPerFrame(): boolean;
  5774. getShadowDirection(faceIndex?: number): Vector3;
  5775. setDirectionToTarget(target: Vector3): Vector3;
  5776. computeTransformedPosition(): boolean;
  5777. transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void;
  5778. _getWorldMatrix(): Matrix;
  5779. getTypeID(): number;
  5780. }
  5781. }
  5782. declare module BABYLON {
  5783. class LensFlare {
  5784. size: number;
  5785. position: number;
  5786. color: Color3;
  5787. texture: Texture;
  5788. private _system;
  5789. constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem);
  5790. dispose: () => void;
  5791. }
  5792. }
  5793. declare module BABYLON {
  5794. class LensFlareSystem {
  5795. name: string;
  5796. lensFlares: LensFlare[];
  5797. borderLimit: number;
  5798. meshesSelectionPredicate: (mesh: Mesh) => boolean;
  5799. layerMask: number;
  5800. id: string;
  5801. private _scene;
  5802. private _emitter;
  5803. private _vertexBuffers;
  5804. private _indexBuffer;
  5805. private _effect;
  5806. private _positionX;
  5807. private _positionY;
  5808. private _isEnabled;
  5809. constructor(name: string, emitter: any, scene: Scene);
  5810. isEnabled: boolean;
  5811. getScene(): Scene;
  5812. getEmitter(): any;
  5813. setEmitter(newEmitter: any): void;
  5814. getEmitterPosition(): Vector3;
  5815. computeEffectivePosition(globalViewport: Viewport): boolean;
  5816. _isVisible(): boolean;
  5817. render(): boolean;
  5818. dispose(): void;
  5819. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  5820. serialize(): any;
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. interface ISceneLoaderPlugin {
  5825. extensions: string;
  5826. importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
  5827. load: (scene: Scene, data: string, rootUrl: string) => boolean;
  5828. }
  5829. interface ISceneLoaderPluginAsync {
  5830. extensions: string;
  5831. importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void;
  5832. loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean;
  5833. }
  5834. class SceneLoader {
  5835. private static _ForceFullSceneLoadingForIncremental;
  5836. private static _ShowLoadingScreen;
  5837. static NO_LOGGING: number;
  5838. static MINIMAL_LOGGING: number;
  5839. static SUMMARY_LOGGING: number;
  5840. static DETAILED_LOGGING: number;
  5841. private static _loggingLevel;
  5842. static ForceFullSceneLoadingForIncremental: boolean;
  5843. static ShowLoadingScreen: boolean;
  5844. static loggingLevel: number;
  5845. private static _registeredPlugins;
  5846. private static _getPluginForFilename(sceneFilename);
  5847. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  5848. static RegisterPlugin(plugin: ISceneLoaderPlugin): void;
  5849. static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, message: string, exception?: any) => void): void;
  5850. /**
  5851. * Load a scene
  5852. * @param rootUrl a string that defines the root url for scene and resources
  5853. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  5854. * @param engine is the instance of BABYLON.Engine to use to create the scene
  5855. */
  5856. static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  5857. /**
  5858. * Append a scene
  5859. * @param rootUrl a string that defines the root url for scene and resources
  5860. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  5861. * @param scene is the instance of BABYLON.Scene to append to
  5862. */
  5863. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  5869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  5870. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  5871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  5872. */
  5873. class ColorCurves {
  5874. private _dirty;
  5875. private _tempColor;
  5876. private _globalCurve;
  5877. private _highlightsCurve;
  5878. private _midtonesCurve;
  5879. private _shadowsCurve;
  5880. private _positiveCurve;
  5881. private _negativeCurve;
  5882. private _globalHue;
  5883. private _globalDensity;
  5884. private _globalSaturation;
  5885. private _globalExposure;
  5886. /**
  5887. * Gets the global Hue value.
  5888. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5889. */
  5890. /**
  5891. * Sets the global Hue value.
  5892. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5893. */
  5894. GlobalHue: number;
  5895. /**
  5896. * Gets the global Density value.
  5897. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5898. * Values less than zero provide a filter of opposite hue.
  5899. */
  5900. /**
  5901. * Sets the global Density value.
  5902. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5903. * Values less than zero provide a filter of opposite hue.
  5904. */
  5905. GlobalDensity: number;
  5906. /**
  5907. * Gets the global Saturation value.
  5908. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5909. */
  5910. /**
  5911. * Sets the global Saturation value.
  5912. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5913. */
  5914. GlobalSaturation: number;
  5915. private _highlightsHue;
  5916. private _highlightsDensity;
  5917. private _highlightsSaturation;
  5918. private _highlightsExposure;
  5919. /**
  5920. * Gets the highlights Hue value.
  5921. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5922. */
  5923. /**
  5924. * Sets the highlights Hue value.
  5925. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5926. */
  5927. HighlightsHue: number;
  5928. /**
  5929. * Gets the highlights Density value.
  5930. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5931. * Values less than zero provide a filter of opposite hue.
  5932. */
  5933. /**
  5934. * Sets the highlights Density value.
  5935. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5936. * Values less than zero provide a filter of opposite hue.
  5937. */
  5938. HighlightsDensity: number;
  5939. /**
  5940. * Gets the highlights Saturation value.
  5941. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5942. */
  5943. /**
  5944. * Sets the highlights Saturation value.
  5945. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5946. */
  5947. HighlightsSaturation: number;
  5948. /**
  5949. * Gets the highlights Exposure value.
  5950. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5951. */
  5952. /**
  5953. * Sets the highlights Exposure value.
  5954. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5955. */
  5956. HighlightsExposure: number;
  5957. private _midtonesHue;
  5958. private _midtonesDensity;
  5959. private _midtonesSaturation;
  5960. private _midtonesExposure;
  5961. /**
  5962. * Gets the midtones Hue value.
  5963. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5964. */
  5965. /**
  5966. * Sets the midtones Hue value.
  5967. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  5968. */
  5969. MidtonesHue: number;
  5970. /**
  5971. * Gets the midtones Density value.
  5972. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5973. * Values less than zero provide a filter of opposite hue.
  5974. */
  5975. /**
  5976. * Sets the midtones Density value.
  5977. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  5978. * Values less than zero provide a filter of opposite hue.
  5979. */
  5980. MidtonesDensity: number;
  5981. /**
  5982. * Gets the midtones Saturation value.
  5983. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5984. */
  5985. /**
  5986. * Sets the midtones Saturation value.
  5987. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  5988. */
  5989. MidtonesSaturation: number;
  5990. /**
  5991. * Gets the midtones Exposure value.
  5992. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5993. */
  5994. /**
  5995. * Sets the midtones Exposure value.
  5996. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  5997. */
  5998. MidtonesExposure: number;
  5999. private _shadowsHue;
  6000. private _shadowsDensity;
  6001. private _shadowsSaturation;
  6002. private _shadowsExposure;
  6003. /**
  6004. * Gets the shadows Hue value.
  6005. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  6006. */
  6007. /**
  6008. * Sets the shadows Hue value.
  6009. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  6010. */
  6011. ShadowsHue: number;
  6012. /**
  6013. * Gets the shadows Density value.
  6014. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  6015. * Values less than zero provide a filter of opposite hue.
  6016. */
  6017. /**
  6018. * Sets the shadows Density value.
  6019. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  6020. * Values less than zero provide a filter of opposite hue.
  6021. */
  6022. ShadowsDensity: number;
  6023. /**
  6024. * Gets the shadows Saturation value.
  6025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  6026. */
  6027. /**
  6028. * Sets the shadows Saturation value.
  6029. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  6030. */
  6031. ShadowsSaturation: number;
  6032. /**
  6033. * Gets the shadows Exposure value.
  6034. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  6035. */
  6036. /**
  6037. * Sets the shadows Exposure value.
  6038. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  6039. */
  6040. ShadowsExposure: number;
  6041. /**
  6042. * Binds the color curves to the shader.
  6043. * @param colorCurves The color curve to bind
  6044. * @param effect The effect to bind to
  6045. */
  6046. static Bind(colorCurves: ColorCurves, effect: Effect): void;
  6047. /**
  6048. * Prepare the list of uniforms associated with the ColorCurves effects.
  6049. * @param uniformsList The list of uniforms used in the effect
  6050. */
  6051. static PrepareUniforms(uniformsList: string[]): void;
  6052. /**
  6053. * Returns color grading data based on a hue, density, saturation and exposure value.
  6054. * @param filterHue The hue of the color filter.
  6055. * @param filterDensity The density of the color filter.
  6056. * @param saturation The saturation.
  6057. * @param exposure The exposure.
  6058. * @param result The result data container.
  6059. */
  6060. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  6061. /**
  6062. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  6063. * @param value The input slider value in range [-100,100].
  6064. * @returns Adjusted value.
  6065. */
  6066. private static applyColorGradingSliderNonlinear(value);
  6067. /**
  6068. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  6069. * @param hue The hue (H) input.
  6070. * @param saturation The saturation (S) input.
  6071. * @param brightness The brightness (B) input.
  6072. * @result An RGBA color represented as Vector4.
  6073. */
  6074. private static fromHSBToRef(hue, saturation, brightness, result);
  6075. /**
  6076. * Returns a value clamped between min and max
  6077. * @param value The value to clamp
  6078. * @param min The minimum of value
  6079. * @param max The maximum of value
  6080. * @returns The clamped value.
  6081. */
  6082. private static clamp(value, min, max);
  6083. /**
  6084. * Clones the current color curve instance.
  6085. * @return The cloned curves
  6086. */
  6087. clone(): ColorCurves;
  6088. /**
  6089. * Serializes the current color curve instance to a json representation.
  6090. * @return a JSON representation
  6091. */
  6092. serialize(): any;
  6093. /**
  6094. * Parses the color curve from a json representation.
  6095. * @param source the JSON source to parse
  6096. * @return The parsed curves
  6097. */
  6098. static Parse(source: any): ColorCurves;
  6099. }
  6100. }
  6101. declare module BABYLON {
  6102. class EffectFallbacks {
  6103. private _defines;
  6104. private _currentRank;
  6105. private _maxRank;
  6106. private _mesh;
  6107. private _meshRank;
  6108. addFallback(rank: number, define: string): void;
  6109. addCPUSkinningFallback(rank: number, mesh: BABYLON.AbstractMesh): void;
  6110. isMoreFallbacks: boolean;
  6111. reduce(currentDefines: string): string;
  6112. }
  6113. class Effect {
  6114. name: any;
  6115. defines: string;
  6116. onCompiled: (effect: Effect) => void;
  6117. onError: (effect: Effect, errors: string) => void;
  6118. onBind: (effect: Effect) => void;
  6119. private _engine;
  6120. private _uniformsNames;
  6121. private _samplers;
  6122. private _isReady;
  6123. private _compilationError;
  6124. private _attributesNames;
  6125. private _attributes;
  6126. private _uniforms;
  6127. _key: string;
  6128. private _indexParameters;
  6129. private _program;
  6130. private _valueCache;
  6131. 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, indexParameters?: any);
  6132. isReady(): boolean;
  6133. getProgram(): WebGLProgram;
  6134. getAttributesNames(): string[];
  6135. getAttributeLocation(index: number): number;
  6136. getAttributeLocationByName(name: string): number;
  6137. getAttributesCount(): number;
  6138. getUniformIndex(uniformName: string): number;
  6139. getUniform(uniformName: string): WebGLUniformLocation;
  6140. getSamplers(): string[];
  6141. getCompilationError(): string;
  6142. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  6143. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  6144. private _dumpShadersName();
  6145. private _processIncludes(sourceCode, callback);
  6146. private _processPrecision(source);
  6147. private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?);
  6148. isSupported: boolean;
  6149. _bindTexture(channel: string, texture: WebGLTexture): void;
  6150. setTexture(channel: string, texture: BaseTexture): void;
  6151. setTextureArray(channel: string, textures: BaseTexture[]): void;
  6152. setTextureFromPostProcess(channel: string, postProcess: PostProcess): void;
  6153. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  6154. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  6155. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  6156. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  6157. setArray(uniformName: string, array: number[]): Effect;
  6158. setArray2(uniformName: string, array: number[]): Effect;
  6159. setArray3(uniformName: string, array: number[]): Effect;
  6160. setArray4(uniformName: string, array: number[]): Effect;
  6161. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  6162. setMatrix(uniformName: string, matrix: Matrix): Effect;
  6163. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  6164. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  6165. setFloat(uniformName: string, value: number): Effect;
  6166. setBool(uniformName: string, bool: boolean): Effect;
  6167. setVector2(uniformName: string, vector2: Vector2): Effect;
  6168. setFloat2(uniformName: string, x: number, y: number): Effect;
  6169. setVector3(uniformName: string, vector3: Vector3): Effect;
  6170. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  6171. setVector4(uniformName: string, vector4: Vector4): Effect;
  6172. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  6173. setColor3(uniformName: string, color3: Color3): Effect;
  6174. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  6175. static ShadersStore: {};
  6176. static IncludesShadersStore: {};
  6177. }
  6178. }
  6179. declare module BABYLON {
  6180. class FresnelParameters {
  6181. isEnabled: boolean;
  6182. leftColor: Color3;
  6183. rightColor: Color3;
  6184. bias: number;
  6185. power: number;
  6186. clone(): FresnelParameters;
  6187. serialize(): any;
  6188. static Parse(parsedFresnelParameters: any): FresnelParameters;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. class MaterialDefines {
  6193. _keys: string[];
  6194. rebuild(): void;
  6195. isEqual(other: MaterialDefines): boolean;
  6196. cloneTo(other: MaterialDefines): void;
  6197. reset(): void;
  6198. toString(): string;
  6199. }
  6200. class Material {
  6201. name: string;
  6202. private static _TriangleFillMode;
  6203. private static _WireFrameFillMode;
  6204. private static _PointFillMode;
  6205. static TriangleFillMode: number;
  6206. static WireFrameFillMode: number;
  6207. static PointFillMode: number;
  6208. private static _ClockWiseSideOrientation;
  6209. private static _CounterClockWiseSideOrientation;
  6210. static ClockWiseSideOrientation: number;
  6211. static CounterClockWiseSideOrientation: number;
  6212. id: string;
  6213. checkReadyOnEveryCall: boolean;
  6214. checkReadyOnlyOnce: boolean;
  6215. state: string;
  6216. alpha: number;
  6217. backFaceCulling: boolean;
  6218. sideOrientation: number;
  6219. onCompiled: (effect: Effect) => void;
  6220. onError: (effect: Effect, errors: string) => void;
  6221. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  6222. /**
  6223. * An event triggered when the material is disposed.
  6224. * @type {BABYLON.Observable}
  6225. */
  6226. onDisposeObservable: Observable<Material>;
  6227. private _onDisposeObserver;
  6228. onDispose: () => void;
  6229. /**
  6230. * An event triggered when the material is compiled.
  6231. * @type {BABYLON.Observable}
  6232. */
  6233. onBindObservable: Observable<AbstractMesh>;
  6234. private _onBindObserver;
  6235. onBind: (Mesh: AbstractMesh) => void;
  6236. alphaMode: number;
  6237. disableDepthWrite: boolean;
  6238. fogEnabled: boolean;
  6239. pointSize: number;
  6240. zOffset: number;
  6241. wireframe: boolean;
  6242. pointsCloud: boolean;
  6243. fillMode: number;
  6244. _effect: Effect;
  6245. _wasPreviouslyReady: boolean;
  6246. private _scene;
  6247. private _fillMode;
  6248. private _cachedDepthWriteState;
  6249. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  6250. /**
  6251. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6252. * subclasses should override adding information pertainent to themselves
  6253. */
  6254. toString(fullDetails?: boolean): string;
  6255. isFrozen: boolean;
  6256. freeze(): void;
  6257. unfreeze(): void;
  6258. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  6259. getEffect(): Effect;
  6260. getScene(): Scene;
  6261. needAlphaBlending(): boolean;
  6262. needAlphaTesting(): boolean;
  6263. getAlphaTestTexture(): BaseTexture;
  6264. markDirty(): void;
  6265. _preBind(): void;
  6266. bind(world: Matrix, mesh?: Mesh): void;
  6267. bindOnlyWorldMatrix(world: Matrix): void;
  6268. unbind(): void;
  6269. clone(name: string): Material;
  6270. getBindedMeshes(): AbstractMesh[];
  6271. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  6272. serialize(): any;
  6273. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  6274. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  6275. }
  6276. }
  6277. declare module BABYLON {
  6278. class MaterialHelper {
  6279. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: MaterialDefines, maxSimultaneousLights?: number): boolean;
  6280. static PrepareUniformsAndSamplersList(uniformsList: string[], samplersList: string[], defines: MaterialDefines, maxSimultaneousLights?: number): void;
  6281. static HandleFallbacksForShadows(defines: MaterialDefines, fallbacks: EffectFallbacks, maxSimultaneousLights?: number): void;
  6282. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: MaterialDefines, fallbacks: EffectFallbacks): void;
  6283. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  6284. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: number, effect: Effect, depthValuesAlreadySet: boolean): boolean;
  6285. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  6286. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, maxSimultaneousLights?: number): void;
  6287. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  6288. static BindBonesParameters(mesh: AbstractMesh, effect: Effect): void;
  6289. static BindLogDepth(defines: MaterialDefines, effect: Effect, scene: Scene): void;
  6290. static BindClipPlane(effect: Effect, scene: Scene): void;
  6291. }
  6292. }
  6293. declare module BABYLON {
  6294. class MultiMaterial extends Material {
  6295. subMaterials: Material[];
  6296. constructor(name: string, scene: Scene);
  6297. getSubMaterial(index: any): Material;
  6298. isReady(mesh?: AbstractMesh): boolean;
  6299. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  6300. serialize(): any;
  6301. }
  6302. }
  6303. declare module BABYLON {
  6304. /**
  6305. * The Physically based material of BJS.
  6306. *
  6307. * This offers the main features of a standard PBR material.
  6308. * For more information, please refer to the documentation :
  6309. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  6310. */
  6311. class PBRMaterial extends BABYLON.Material {
  6312. /**
  6313. * Intensity of the direct lights e.g. the four lights available in your scene.
  6314. * This impacts both the direct diffuse and specular highlights.
  6315. */
  6316. directIntensity: number;
  6317. /**
  6318. * Intensity of the emissive part of the material.
  6319. * This helps controlling the emissive effect without modifying the emissive color.
  6320. */
  6321. emissiveIntensity: number;
  6322. /**
  6323. * Intensity of the environment e.g. how much the environment will light the object
  6324. * either through harmonics for rough material or through the refelction for shiny ones.
  6325. */
  6326. environmentIntensity: number;
  6327. /**
  6328. * This is a special control allowing the reduction of the specular highlights coming from the
  6329. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  6330. */
  6331. specularIntensity: number;
  6332. private _lightingInfos;
  6333. /**
  6334. * Debug Control allowing disabling the bump map on this material.
  6335. */
  6336. disableBumpMap: boolean;
  6337. /**
  6338. * Debug Control helping enforcing or dropping the darkness of shadows.
  6339. * 1.0 means the shadows have their normal darkness, 0.0 means the shadows are not visible.
  6340. */
  6341. overloadedShadowIntensity: number;
  6342. /**
  6343. * Debug Control helping dropping the shading effect coming from the diffuse lighting.
  6344. * 1.0 means the shade have their normal impact, 0.0 means no shading at all.
  6345. */
  6346. overloadedShadeIntensity: number;
  6347. private _overloadedShadowInfos;
  6348. /**
  6349. * The camera exposure used on this material.
  6350. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  6351. * This corresponds to a photographic exposure.
  6352. */
  6353. cameraExposure: number;
  6354. /**
  6355. * The camera contrast used on this material.
  6356. * This property is here and not in the camera to allow controlling contrast without full screen post process.
  6357. */
  6358. cameraContrast: number;
  6359. /**
  6360. * Color Grading 2D Lookup Texture.
  6361. * This allows special effects like sepia, black and white to sixties rendering style.
  6362. */
  6363. cameraColorGradingTexture: BaseTexture;
  6364. private _cameraColorGradingScaleOffset;
  6365. private _cameraColorGradingInfos;
  6366. /**
  6367. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  6368. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  6369. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  6370. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  6371. */
  6372. cameraColorCurves: ColorCurves;
  6373. private _cameraInfos;
  6374. private _microsurfaceTextureLods;
  6375. /**
  6376. * Debug Control allowing to overload the ambient color.
  6377. * This as to be use with the overloadedAmbientIntensity parameter.
  6378. */
  6379. overloadedAmbient: Color3;
  6380. /**
  6381. * Debug Control indicating how much the overloaded ambient color is used against the default one.
  6382. */
  6383. overloadedAmbientIntensity: number;
  6384. /**
  6385. * Debug Control allowing to overload the albedo color.
  6386. * This as to be use with the overloadedAlbedoIntensity parameter.
  6387. */
  6388. overloadedAlbedo: Color3;
  6389. /**
  6390. * Debug Control indicating how much the overloaded albedo color is used against the default one.
  6391. */
  6392. overloadedAlbedoIntensity: number;
  6393. /**
  6394. * Debug Control allowing to overload the reflectivity color.
  6395. * This as to be use with the overloadedReflectivityIntensity parameter.
  6396. */
  6397. overloadedReflectivity: Color3;
  6398. /**
  6399. * Debug Control indicating how much the overloaded reflectivity color is used against the default one.
  6400. */
  6401. overloadedReflectivityIntensity: number;
  6402. /**
  6403. * Debug Control allowing to overload the emissive color.
  6404. * This as to be use with the overloadedEmissiveIntensity parameter.
  6405. */
  6406. overloadedEmissive: Color3;
  6407. /**
  6408. * Debug Control indicating how much the overloaded emissive color is used against the default one.
  6409. */
  6410. overloadedEmissiveIntensity: number;
  6411. private _overloadedIntensity;
  6412. /**
  6413. * Debug Control allowing to overload the reflection color.
  6414. * This as to be use with the overloadedReflectionIntensity parameter.
  6415. */
  6416. overloadedReflection: Color3;
  6417. /**
  6418. * Debug Control indicating how much the overloaded reflection color is used against the default one.
  6419. */
  6420. overloadedReflectionIntensity: number;
  6421. /**
  6422. * Debug Control allowing to overload the microsurface.
  6423. * This as to be use with the overloadedMicroSurfaceIntensity parameter.
  6424. */
  6425. overloadedMicroSurface: number;
  6426. /**
  6427. * Debug Control indicating how much the overloaded microsurface is used against the default one.
  6428. */
  6429. overloadedMicroSurfaceIntensity: number;
  6430. private _overloadedMicroSurface;
  6431. /**
  6432. * AKA Diffuse Texture in standard nomenclature.
  6433. */
  6434. albedoTexture: BaseTexture;
  6435. /**
  6436. * AKA Occlusion Texture in other nomenclature.
  6437. */
  6438. ambientTexture: BaseTexture;
  6439. opacityTexture: BaseTexture;
  6440. reflectionTexture: BaseTexture;
  6441. emissiveTexture: BaseTexture;
  6442. /**
  6443. * AKA Specular texture in other nomenclature.
  6444. */
  6445. reflectivityTexture: BaseTexture;
  6446. bumpTexture: BaseTexture;
  6447. lightmapTexture: BaseTexture;
  6448. refractionTexture: BaseTexture;
  6449. ambientColor: Color3;
  6450. /**
  6451. * AKA Diffuse Color in other nomenclature.
  6452. */
  6453. albedoColor: Color3;
  6454. /**
  6455. * AKA Specular Color in other nomenclature.
  6456. */
  6457. reflectivityColor: Color3;
  6458. reflectionColor: Color3;
  6459. emissiveColor: Color3;
  6460. /**
  6461. * AKA Glossiness in other nomenclature.
  6462. */
  6463. microSurface: number;
  6464. /**
  6465. * source material index of refraction (IOR)' / 'destination material IOR.
  6466. */
  6467. indexOfRefraction: number;
  6468. /**
  6469. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  6470. */
  6471. invertRefractionY: boolean;
  6472. opacityFresnelParameters: FresnelParameters;
  6473. emissiveFresnelParameters: FresnelParameters;
  6474. /**
  6475. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  6476. * Materials half opaque for instance using refraction could benefit from this control.
  6477. */
  6478. linkRefractionWithTransparency: boolean;
  6479. /**
  6480. * The emissive and albedo are linked to never be more than one (Energy conservation).
  6481. */
  6482. linkEmissiveWithAlbedo: boolean;
  6483. useLightmapAsShadowmap: boolean;
  6484. /**
  6485. * In this mode, the emissive informtaion will always be added to the lighting once.
  6486. * A light for instance can be thought as emissive.
  6487. */
  6488. useEmissiveAsIllumination: boolean;
  6489. /**
  6490. * Secifies that the alpha is coming form the albedo channel alpha channel.
  6491. */
  6492. useAlphaFromAlbedoTexture: boolean;
  6493. /**
  6494. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  6495. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  6496. */
  6497. useSpecularOverAlpha: boolean;
  6498. /**
  6499. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  6500. */
  6501. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  6502. /**
  6503. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  6504. * The material will try to infer what glossiness each pixel should be.
  6505. */
  6506. useAutoMicroSurfaceFromReflectivityMap: boolean;
  6507. /**
  6508. * Allows to work with scalar in linear mode. This is definitely a matter of preferences and tools used during
  6509. * the creation of the material.
  6510. */
  6511. useScalarInLinearSpace: boolean;
  6512. /**
  6513. * BJS is using an harcoded light falloff based on a manually sets up range.
  6514. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  6515. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  6516. */
  6517. usePhysicalLightFalloff: boolean;
  6518. /**
  6519. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  6520. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  6521. */
  6522. useRadianceOverAlpha: boolean;
  6523. /**
  6524. * Allows using the bump map in parallax mode.
  6525. */
  6526. useParallax: boolean;
  6527. /**
  6528. * Allows using the bump map in parallax occlusion mode.
  6529. */
  6530. useParallaxOcclusion: boolean;
  6531. /**
  6532. * Controls the scale bias of the parallax mode.
  6533. */
  6534. parallaxScaleBias: number;
  6535. /**
  6536. * If sets to true, disables all the lights affecting the material.
  6537. */
  6538. disableLighting: boolean;
  6539. /**
  6540. * Number of Simultaneous lights allowed on the material.
  6541. */
  6542. maxSimultaneousLights: number;
  6543. /**
  6544. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  6545. */
  6546. invertNormalMapX: boolean;
  6547. /**
  6548. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  6549. */
  6550. invertNormalMapY: boolean;
  6551. private _renderTargets;
  6552. private _worldViewProjectionMatrix;
  6553. private _globalAmbientColor;
  6554. private _tempColor;
  6555. private _renderId;
  6556. private _defines;
  6557. private _cachedDefines;
  6558. private _useLogarithmicDepth;
  6559. /**
  6560. * Instantiates a new PBRMaterial instance.
  6561. *
  6562. * @param name The material name
  6563. * @param scene The scene the material will be use in.
  6564. */
  6565. constructor(name: string, scene: Scene);
  6566. useLogarithmicDepth: boolean;
  6567. needAlphaBlending(): boolean;
  6568. needAlphaTesting(): boolean;
  6569. private _shouldUseAlphaFromAlbedoTexture();
  6570. getAlphaTestTexture(): BaseTexture;
  6571. private _checkCache(scene, mesh?, useInstances?);
  6572. private convertColorToLinearSpaceToRef(color, ref);
  6573. private static convertColorToLinearSpaceToRef(color, ref, useScalarInLinear);
  6574. private static _scaledAlbedo;
  6575. private static _scaledReflectivity;
  6576. private static _scaledEmissive;
  6577. private static _scaledReflection;
  6578. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, useScalarInLinearSpace: boolean, maxSimultaneousLights: number, usePhysicalLightFalloff: boolean): void;
  6579. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  6580. unbind(): void;
  6581. bindOnlyWorldMatrix(world: Matrix): void;
  6582. private _myScene;
  6583. private _myShadowGenerator;
  6584. bind(world: Matrix, mesh?: Mesh): void;
  6585. getAnimatables(): IAnimatable[];
  6586. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  6587. clone(name: string): PBRMaterial;
  6588. serialize(): any;
  6589. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  6590. }
  6591. }
  6592. declare module BABYLON {
  6593. class ShaderMaterial extends Material {
  6594. private _shaderPath;
  6595. private _options;
  6596. private _textures;
  6597. private _textureArrays;
  6598. private _floats;
  6599. private _floatsArrays;
  6600. private _colors3;
  6601. private _colors4;
  6602. private _vectors2;
  6603. private _vectors3;
  6604. private _vectors4;
  6605. private _matrices;
  6606. private _matrices3x3;
  6607. private _matrices2x2;
  6608. private _cachedWorldViewMatrix;
  6609. private _renderId;
  6610. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  6611. needAlphaBlending(): boolean;
  6612. needAlphaTesting(): boolean;
  6613. private _checkUniform(uniformName);
  6614. setTexture(name: string, texture: Texture): ShaderMaterial;
  6615. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  6616. setFloat(name: string, value: number): ShaderMaterial;
  6617. setFloats(name: string, value: number[]): ShaderMaterial;
  6618. setColor3(name: string, value: Color3): ShaderMaterial;
  6619. setColor4(name: string, value: Color4): ShaderMaterial;
  6620. setVector2(name: string, value: Vector2): ShaderMaterial;
  6621. setVector3(name: string, value: Vector3): ShaderMaterial;
  6622. setVector4(name: string, value: Vector4): ShaderMaterial;
  6623. setMatrix(name: string, value: Matrix): ShaderMaterial;
  6624. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  6625. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  6626. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  6627. bindOnlyWorldMatrix(world: Matrix): void;
  6628. bind(world: Matrix, mesh?: Mesh): void;
  6629. clone(name: string): ShaderMaterial;
  6630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  6631. serialize(): any;
  6632. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  6633. }
  6634. }
  6635. declare module BABYLON {
  6636. class StandardMaterial extends Material {
  6637. diffuseTexture: BaseTexture;
  6638. ambientTexture: BaseTexture;
  6639. opacityTexture: BaseTexture;
  6640. reflectionTexture: BaseTexture;
  6641. emissiveTexture: BaseTexture;
  6642. specularTexture: BaseTexture;
  6643. bumpTexture: BaseTexture;
  6644. lightmapTexture: BaseTexture;
  6645. refractionTexture: BaseTexture;
  6646. ambientColor: Color3;
  6647. diffuseColor: Color3;
  6648. specularColor: Color3;
  6649. emissiveColor: Color3;
  6650. specularPower: number;
  6651. useAlphaFromDiffuseTexture: boolean;
  6652. useEmissiveAsIllumination: boolean;
  6653. linkEmissiveWithDiffuse: boolean;
  6654. useReflectionFresnelFromSpecular: boolean;
  6655. useSpecularOverAlpha: boolean;
  6656. useReflectionOverAlpha: boolean;
  6657. disableLighting: boolean;
  6658. useParallax: boolean;
  6659. useParallaxOcclusion: boolean;
  6660. parallaxScaleBias: number;
  6661. roughness: number;
  6662. indexOfRefraction: number;
  6663. invertRefractionY: boolean;
  6664. useLightmapAsShadowmap: boolean;
  6665. diffuseFresnelParameters: FresnelParameters;
  6666. opacityFresnelParameters: FresnelParameters;
  6667. reflectionFresnelParameters: FresnelParameters;
  6668. refractionFresnelParameters: FresnelParameters;
  6669. emissiveFresnelParameters: FresnelParameters;
  6670. useGlossinessFromSpecularMapAlpha: boolean;
  6671. maxSimultaneousLights: number;
  6672. /**
  6673. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  6674. */
  6675. invertNormalMapX: boolean;
  6676. /**
  6677. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  6678. */
  6679. invertNormalMapY: boolean;
  6680. private _renderTargets;
  6681. private _worldViewProjectionMatrix;
  6682. private _globalAmbientColor;
  6683. private _renderId;
  6684. private _defines;
  6685. private _cachedDefines;
  6686. private _useLogarithmicDepth;
  6687. constructor(name: string, scene: Scene);
  6688. useLogarithmicDepth: boolean;
  6689. needAlphaBlending(): boolean;
  6690. needAlphaTesting(): boolean;
  6691. private _shouldUseAlphaFromDiffuseTexture();
  6692. getAlphaTestTexture(): BaseTexture;
  6693. private _checkCache(scene, mesh?, useInstances?);
  6694. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  6695. unbind(): void;
  6696. bindOnlyWorldMatrix(world: Matrix): void;
  6697. bind(world: Matrix, mesh?: Mesh): void;
  6698. getAnimatables(): IAnimatable[];
  6699. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  6700. clone(name: string): StandardMaterial;
  6701. serialize(): any;
  6702. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  6703. static DiffuseTextureEnabled: boolean;
  6704. static AmbientTextureEnabled: boolean;
  6705. static OpacityTextureEnabled: boolean;
  6706. static ReflectionTextureEnabled: boolean;
  6707. static EmissiveTextureEnabled: boolean;
  6708. static SpecularTextureEnabled: boolean;
  6709. static BumpTextureEnabled: boolean;
  6710. static FresnelEnabled: boolean;
  6711. static LightmapTextureEnabled: boolean;
  6712. static RefractionTextureEnabled: boolean;
  6713. }
  6714. }
  6715. declare module BABYLON {
  6716. class Particle {
  6717. position: Vector3;
  6718. direction: Vector3;
  6719. color: Color4;
  6720. colorStep: Color4;
  6721. lifeTime: number;
  6722. age: number;
  6723. size: number;
  6724. angle: number;
  6725. angularSpeed: number;
  6726. copyTo(other: Particle): void;
  6727. }
  6728. }
  6729. declare module BABYLON {
  6730. class ParticleSystem implements IDisposable, IAnimatable {
  6731. name: string;
  6732. static BLENDMODE_ONEONE: number;
  6733. static BLENDMODE_STANDARD: number;
  6734. animations: Animation[];
  6735. id: string;
  6736. renderingGroupId: number;
  6737. emitter: any;
  6738. emitRate: number;
  6739. manualEmitCount: number;
  6740. updateSpeed: number;
  6741. targetStopDuration: number;
  6742. disposeOnStop: boolean;
  6743. minEmitPower: number;
  6744. maxEmitPower: number;
  6745. minLifeTime: number;
  6746. maxLifeTime: number;
  6747. minSize: number;
  6748. maxSize: number;
  6749. minAngularSpeed: number;
  6750. maxAngularSpeed: number;
  6751. particleTexture: Texture;
  6752. layerMask: number;
  6753. /**
  6754. * An event triggered when the system is disposed.
  6755. * @type {BABYLON.Observable}
  6756. */
  6757. onDisposeObservable: Observable<ParticleSystem>;
  6758. private _onDisposeObserver;
  6759. onDispose: () => void;
  6760. updateFunction: (particles: Particle[]) => void;
  6761. blendMode: number;
  6762. forceDepthWrite: boolean;
  6763. gravity: Vector3;
  6764. direction1: Vector3;
  6765. direction2: Vector3;
  6766. minEmitBox: Vector3;
  6767. maxEmitBox: Vector3;
  6768. color1: Color4;
  6769. color2: Color4;
  6770. colorDead: Color4;
  6771. textureMask: Color4;
  6772. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  6773. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  6774. private particles;
  6775. private _capacity;
  6776. private _scene;
  6777. private _stockParticles;
  6778. private _newPartsExcess;
  6779. private _vertexData;
  6780. private _vertexBuffer;
  6781. private _vertexBuffers;
  6782. private _indexBuffer;
  6783. private _effect;
  6784. private _customEffect;
  6785. private _cachedDefines;
  6786. private _scaledColorStep;
  6787. private _colorDiff;
  6788. private _scaledDirection;
  6789. private _scaledGravity;
  6790. private _currentRenderId;
  6791. private _alive;
  6792. private _started;
  6793. private _stopped;
  6794. private _actualFrame;
  6795. private _scaledUpdateSpeed;
  6796. constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect);
  6797. recycleParticle(particle: Particle): void;
  6798. getCapacity(): number;
  6799. isAlive(): boolean;
  6800. isStarted(): boolean;
  6801. start(): void;
  6802. stop(): void;
  6803. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  6804. private _update(newParticles);
  6805. private _getEffect();
  6806. animate(): void;
  6807. render(): number;
  6808. dispose(): void;
  6809. clone(name: string, newEmitter: any): ParticleSystem;
  6810. serialize(): any;
  6811. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  6812. }
  6813. }
  6814. declare module BABYLON {
  6815. class SolidParticle {
  6816. idx: number;
  6817. color: Color4;
  6818. position: Vector3;
  6819. rotation: Vector3;
  6820. rotationQuaternion: Quaternion;
  6821. scaling: Vector3;
  6822. uvs: Vector4;
  6823. velocity: Vector3;
  6824. alive: boolean;
  6825. isVisible: boolean;
  6826. _pos: number;
  6827. _model: ModelShape;
  6828. shapeId: number;
  6829. idxInShape: number;
  6830. constructor(particleIndex: number, positionIndex: number, model: ModelShape, shapeId: number, idxInShape: number);
  6831. scale: Vector3;
  6832. quaternion: Quaternion;
  6833. }
  6834. class ModelShape {
  6835. shapeID: number;
  6836. _shape: Vector3[];
  6837. _shapeUV: number[];
  6838. _positionFunction: (particle: SolidParticle, i: number, s: number) => void;
  6839. _vertexFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void;
  6840. constructor(id: number, shape: Vector3[], shapeUV: number[], posFunction: (particle: SolidParticle, i: number, s: number) => void, vtxFunction: (particle: SolidParticle, vertex: Vector3, i: number) => void);
  6841. }
  6842. }
  6843. declare module BABYLON {
  6844. /**
  6845. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  6846. */
  6847. class SolidParticleSystem implements IDisposable {
  6848. /**
  6849. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  6850. * Example : var p = SPS.particles[i];
  6851. */
  6852. particles: SolidParticle[];
  6853. /**
  6854. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  6855. */
  6856. nbParticles: number;
  6857. /**
  6858. * If the particles must ever face the camera (default false). Useful for planar particles.
  6859. */
  6860. billboard: boolean;
  6861. /**
  6862. * This a counter ofr your own usage. It's not set by any SPS functions.
  6863. */
  6864. counter: number;
  6865. /**
  6866. * The SPS name. This name is also given to the underlying mesh.
  6867. */
  6868. name: string;
  6869. /**
  6870. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  6871. */
  6872. mesh: Mesh;
  6873. /**
  6874. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  6875. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  6876. */
  6877. vars: any;
  6878. /**
  6879. * This array is populated when the SPS is set as 'pickable'.
  6880. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  6881. * Each element of this array is an object `{idx: int, faceId: int}`.
  6882. * `idx` is the picked particle index in the `SPS.particles` array
  6883. * `faceId` is the picked face index counted within this particle.
  6884. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  6885. */
  6886. pickedParticles: {
  6887. idx: number;
  6888. faceId: number;
  6889. }[];
  6890. private _scene;
  6891. private _positions;
  6892. private _indices;
  6893. private _normals;
  6894. private _colors;
  6895. private _uvs;
  6896. private _positions32;
  6897. private _normals32;
  6898. private _fixedNormal32;
  6899. private _colors32;
  6900. private _uvs32;
  6901. private _index;
  6902. private _updatable;
  6903. private _pickable;
  6904. private _isVisibilityBoxLocked;
  6905. private _alwaysVisible;
  6906. private _shapeCounter;
  6907. private _copy;
  6908. private _shape;
  6909. private _shapeUV;
  6910. private _color;
  6911. private _computeParticleColor;
  6912. private _computeParticleTexture;
  6913. private _computeParticleRotation;
  6914. private _computeParticleVertex;
  6915. private _computeBoundingBox;
  6916. private _cam_axisZ;
  6917. private _cam_axisY;
  6918. private _cam_axisX;
  6919. private _axisX;
  6920. private _axisY;
  6921. private _axisZ;
  6922. private _camera;
  6923. private _particle;
  6924. private _fakeCamPos;
  6925. private _rotMatrix;
  6926. private _invertMatrix;
  6927. private _rotated;
  6928. private _quaternion;
  6929. private _vertex;
  6930. private _normal;
  6931. private _yaw;
  6932. private _pitch;
  6933. private _roll;
  6934. private _halfroll;
  6935. private _halfpitch;
  6936. private _halfyaw;
  6937. private _sinRoll;
  6938. private _cosRoll;
  6939. private _sinPitch;
  6940. private _cosPitch;
  6941. private _sinYaw;
  6942. private _cosYaw;
  6943. private _w;
  6944. private _minimum;
  6945. private _maximum;
  6946. /**
  6947. * Creates a SPS (Solid Particle System) object.
  6948. * `name` (String) is the SPS name, this will be the underlying mesh name.
  6949. * `scene` (Scene) is the scene in which the SPS is added.
  6950. * `updatable` (default true) : if the SPS must be updatable or immutable.
  6951. * `isPickable` (default false) : if the solid particles must be pickable.
  6952. */
  6953. constructor(name: string, scene: Scene, options?: {
  6954. updatable?: boolean;
  6955. isPickable?: boolean;
  6956. });
  6957. /**
  6958. * Builds the SPS underlying mesh. Returns a standard Mesh.
  6959. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  6960. */
  6961. buildMesh(): Mesh;
  6962. /**
  6963. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  6964. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  6965. * Thus the particles generated from `digest()` have their property `position` set yet.
  6966. * `mesh` ( Mesh ) is the mesh to be digested
  6967. * `facetNb` (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  6968. * `delta` (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  6969. * `number` (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  6970. */
  6971. digest(mesh: Mesh, options?: {
  6972. facetNb?: number;
  6973. number?: number;
  6974. delta?: number;
  6975. }): SolidParticleSystem;
  6976. private _resetCopy();
  6977. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, idx, idxInShape, options);
  6978. private _posToShape(positions);
  6979. private _uvsToShapeUV(uvs);
  6980. private _addParticle(idx, idxpos, model, shapeId, idxInShape);
  6981. /**
  6982. * Adds some particles to the SPS from the model shape. Returns the shape id.
  6983. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  6984. * `mesh` is any Mesh object that will be used as a model for the solid particles.
  6985. * `nb` (positive integer) the number of particles to be created from this model
  6986. * `positionFunction` is an optional javascript function to called for each particle on SPS creation.
  6987. * `vertexFunction` is an optional javascript function to called for each vertex of each particle on SPS creation
  6988. */
  6989. addShape(mesh: Mesh, nb: number, options?: {
  6990. positionFunction?: any;
  6991. vertexFunction?: any;
  6992. }): number;
  6993. private _rebuildParticle(particle);
  6994. /**
  6995. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  6996. */
  6997. rebuildMesh(): void;
  6998. /**
  6999. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  7000. * This method calls `updateParticle()` for each particle of the SPS.
  7001. * For an animated SPS, it is usually called within the render loop.
  7002. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  7003. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  7004. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  7005. */
  7006. setParticles(start?: number, end?: number, update?: boolean): void;
  7007. private _quaternionRotationYPR();
  7008. private _quaternionToRotationMatrix();
  7009. /**
  7010. * Disposes the SPS
  7011. */
  7012. dispose(): void;
  7013. /**
  7014. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  7015. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  7016. */
  7017. refreshVisibleSize(): void;
  7018. /**
  7019. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  7020. * @param size the size (float) of the visibility box
  7021. * note : this doesn't lock the SPS mesh bounding box.
  7022. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  7023. */
  7024. setVisibilityBox(size: number): void;
  7025. /**
  7026. * Sets the SPS as always visible or not
  7027. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  7028. */
  7029. isAlwaysVisible: boolean;
  7030. /**
  7031. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  7032. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  7033. */
  7034. isVisibilityBoxLocked: boolean;
  7035. /**
  7036. * Tells to `setParticles()` to compute the particle rotations or not.
  7037. * Default value : true. The SPS is faster when it's set to false.
  7038. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  7039. */
  7040. computeParticleRotation: boolean;
  7041. /**
  7042. * Tells to `setParticles()` to compute the particle colors or not.
  7043. * Default value : true. The SPS is faster when it's set to false.
  7044. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  7045. */
  7046. computeParticleColor: boolean;
  7047. /**
  7048. * Tells to `setParticles()` to compute the particle textures or not.
  7049. * Default value : true. The SPS is faster when it's set to false.
  7050. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  7051. */
  7052. computeParticleTexture: boolean;
  7053. /**
  7054. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  7055. * Default value : false. The SPS is faster when it's set to false.
  7056. * Note : the particle custom vertex positions aren't stored values.
  7057. */
  7058. computeParticleVertex: boolean;
  7059. /**
  7060. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  7061. */
  7062. computeBoundingBox: boolean;
  7063. /**
  7064. * This function does nothing. It may be overwritten to set all the particle first values.
  7065. * The SPS doesn't call this function, you may have to call it by your own.
  7066. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  7067. */
  7068. initParticles(): void;
  7069. /**
  7070. * This function does nothing. It may be overwritten to recycle a particle.
  7071. * The SPS doesn't call this function, you may have to call it by your own.
  7072. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  7073. */
  7074. recycleParticle(particle: SolidParticle): SolidParticle;
  7075. /**
  7076. * Updates a particle : this function should be overwritten by the user.
  7077. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  7078. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  7079. * ex : just set a particle position or velocity and recycle conditions
  7080. */
  7081. updateParticle(particle: SolidParticle): SolidParticle;
  7082. /**
  7083. * Updates a vertex of a particle : it can be overwritten by the user.
  7084. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  7085. * @param particle the current particle
  7086. * @param vertex the current index of the current particle
  7087. * @param pt the index of the current vertex in the particle shape
  7088. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  7089. * ex : just set a vertex particle position
  7090. */
  7091. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  7092. /**
  7093. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  7094. * This does nothing and may be overwritten by the user.
  7095. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  7096. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  7097. * @param update the boolean update value actually passed to setParticles()
  7098. */
  7099. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  7100. /**
  7101. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  7102. * This will be passed three parameters.
  7103. * This does nothing and may be overwritten by the user.
  7104. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  7105. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  7106. * @param update the boolean update value actually passed to setParticles()
  7107. */
  7108. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  7109. }
  7110. }
  7111. declare module BABYLON {
  7112. class SIMDVector3 {
  7113. static TransformCoordinatesToRefSIMD(vector: Vector3, transformation: Matrix, result: Vector3): void;
  7114. static TransformCoordinatesFromFloatsToRefSIMD(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  7115. }
  7116. class SIMDMatrix {
  7117. multiplyToArraySIMD(other: Matrix, result: Matrix, offset?: number): void;
  7118. invertToRefSIMD(other: Matrix): Matrix;
  7119. static LookAtLHToRefSIMD(eyeRef: Vector3, targetRef: Vector3, upRef: Vector3, result: Matrix): void;
  7120. }
  7121. class SIMDHelper {
  7122. private static _isEnabled;
  7123. static IsEnabled: boolean;
  7124. static DisableSIMD(): void;
  7125. static EnableSIMD(): void;
  7126. }
  7127. }
  7128. declare module BABYLON {
  7129. const ToGammaSpace: number;
  7130. const ToLinearSpace: number;
  7131. const Epsilon: number;
  7132. class MathTools {
  7133. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  7134. static ToHex(i: number): string;
  7135. static Sign(value: number): number;
  7136. static Clamp(value: number, min?: number, max?: number): number;
  7137. }
  7138. class Color3 {
  7139. r: number;
  7140. g: number;
  7141. b: number;
  7142. constructor(r?: number, g?: number, b?: number);
  7143. toString(): string;
  7144. getClassName(): string;
  7145. getHashCode(): number;
  7146. toArray(array: number[], index?: number): Color3;
  7147. toColor4(alpha?: number): Color4;
  7148. asArray(): number[];
  7149. toLuminance(): number;
  7150. multiply(otherColor: Color3): Color3;
  7151. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  7152. equals(otherColor: Color3): boolean;
  7153. equalsFloats(r: number, g: number, b: number): boolean;
  7154. scale(scale: number): Color3;
  7155. scaleToRef(scale: number, result: Color3): Color3;
  7156. add(otherColor: Color3): Color3;
  7157. addToRef(otherColor: Color3, result: Color3): Color3;
  7158. subtract(otherColor: Color3): Color3;
  7159. subtractToRef(otherColor: Color3, result: Color3): Color3;
  7160. clone(): Color3;
  7161. copyFrom(source: Color3): Color3;
  7162. copyFromFloats(r: number, g: number, b: number): Color3;
  7163. toHexString(): string;
  7164. toLinearSpace(): Color3;
  7165. toLinearSpaceToRef(convertedColor: Color3): Color3;
  7166. toGammaSpace(): Color3;
  7167. toGammaSpaceToRef(convertedColor: Color3): Color3;
  7168. static FromHexString(hex: string): Color3;
  7169. static FromArray(array: number[], offset?: number): Color3;
  7170. static FromInts(r: number, g: number, b: number): Color3;
  7171. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  7172. static Red(): Color3;
  7173. static Green(): Color3;
  7174. static Blue(): Color3;
  7175. static Black(): Color3;
  7176. static White(): Color3;
  7177. static Purple(): Color3;
  7178. static Magenta(): Color3;
  7179. static Yellow(): Color3;
  7180. static Gray(): Color3;
  7181. }
  7182. class Color4 {
  7183. r: number;
  7184. g: number;
  7185. b: number;
  7186. a: number;
  7187. constructor(r: number, g: number, b: number, a: number);
  7188. addInPlace(right: any): Color4;
  7189. asArray(): number[];
  7190. toArray(array: number[], index?: number): Color4;
  7191. add(right: Color4): Color4;
  7192. subtract(right: Color4): Color4;
  7193. subtractToRef(right: Color4, result: Color4): Color4;
  7194. scale(scale: number): Color4;
  7195. scaleToRef(scale: number, result: Color4): Color4;
  7196. /**
  7197. * Multipy an RGBA Color4 value by another and return a new Color4 object
  7198. * @param color The Color4 (RGBA) value to multiply by
  7199. * @returns A new Color4.
  7200. */
  7201. multiply(color: Color4): Color4;
  7202. /**
  7203. * Multipy an RGBA Color4 value by another and push the result in a reference value
  7204. * @param color The Color4 (RGBA) value to multiply by
  7205. * @param result The Color4 (RGBA) to fill the result in
  7206. * @returns the result Color4.
  7207. */
  7208. multiplyToRef(color: Color4, result: Color4): Color4;
  7209. toString(): string;
  7210. getClassName(): string;
  7211. getHashCode(): number;
  7212. clone(): Color4;
  7213. copyFrom(source: Color4): Color4;
  7214. toHexString(): string;
  7215. static FromHexString(hex: string): Color4;
  7216. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  7217. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  7218. static FromArray(array: number[], offset?: number): Color4;
  7219. static FromInts(r: number, g: number, b: number, a: number): Color4;
  7220. static CheckColors4(colors: number[], count: number): number[];
  7221. }
  7222. class Vector2 {
  7223. x: number;
  7224. y: number;
  7225. constructor(x: number, y: number);
  7226. toString(): string;
  7227. getClassName(): string;
  7228. getHashCode(): number;
  7229. toArray(array: number[] | Float32Array, index?: number): Vector2;
  7230. asArray(): number[];
  7231. copyFrom(source: Vector2): Vector2;
  7232. copyFromFloats(x: number, y: number): Vector2;
  7233. add(otherVector: Vector2): Vector2;
  7234. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  7235. addVector3(otherVector: Vector3): Vector2;
  7236. subtract(otherVector: Vector2): Vector2;
  7237. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  7238. subtractInPlace(otherVector: Vector2): Vector2;
  7239. multiplyInPlace(otherVector: Vector2): Vector2;
  7240. multiply(otherVector: Vector2): Vector2;
  7241. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  7242. multiplyByFloats(x: number, y: number): Vector2;
  7243. divide(otherVector: Vector2): Vector2;
  7244. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  7245. negate(): Vector2;
  7246. scaleInPlace(scale: number): Vector2;
  7247. scale(scale: number): Vector2;
  7248. equals(otherVector: Vector2): boolean;
  7249. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  7250. length(): number;
  7251. lengthSquared(): number;
  7252. normalize(): Vector2;
  7253. clone(): Vector2;
  7254. static Zero(): Vector2;
  7255. static FromArray(array: number[] | Float32Array, offset?: number): Vector2;
  7256. static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector2): void;
  7257. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  7258. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  7259. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  7260. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  7261. static Dot(left: Vector2, right: Vector2): number;
  7262. static Normalize(vector: Vector2): Vector2;
  7263. static Minimize(left: Vector2, right: Vector2): Vector2;
  7264. static Maximize(left: Vector2, right: Vector2): Vector2;
  7265. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  7266. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  7267. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  7268. static Distance(value1: Vector2, value2: Vector2): number;
  7269. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  7270. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  7271. }
  7272. class Vector3 {
  7273. x: number;
  7274. y: number;
  7275. z: number;
  7276. constructor(x: number, y: number, z: number);
  7277. toString(): string;
  7278. getClassName(): string;
  7279. getHashCode(): number;
  7280. asArray(): number[];
  7281. toArray(array: number[] | Float32Array, index?: number): Vector3;
  7282. toQuaternion(): Quaternion;
  7283. addInPlace(otherVector: Vector3): Vector3;
  7284. add(otherVector: Vector3): Vector3;
  7285. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  7286. subtractInPlace(otherVector: Vector3): Vector3;
  7287. subtract(otherVector: Vector3): Vector3;
  7288. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  7289. subtractFromFloats(x: number, y: number, z: number): Vector3;
  7290. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  7291. negate(): Vector3;
  7292. scaleInPlace(scale: number): Vector3;
  7293. scale(scale: number): Vector3;
  7294. scaleToRef(scale: number, result: Vector3): void;
  7295. equals(otherVector: Vector3): boolean;
  7296. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  7297. equalsToFloats(x: number, y: number, z: number): boolean;
  7298. multiplyInPlace(otherVector: Vector3): Vector3;
  7299. multiply(otherVector: Vector3): Vector3;
  7300. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  7301. multiplyByFloats(x: number, y: number, z: number): Vector3;
  7302. divide(otherVector: Vector3): Vector3;
  7303. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  7304. MinimizeInPlace(other: Vector3): Vector3;
  7305. MaximizeInPlace(other: Vector3): Vector3;
  7306. length(): number;
  7307. lengthSquared(): number;
  7308. normalize(): Vector3;
  7309. clone(): Vector3;
  7310. copyFrom(source: Vector3): Vector3;
  7311. copyFromFloats(x: number, y: number, z: number): Vector3;
  7312. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number;
  7313. static FromArray(array: number[] | Float32Array, offset?: number): Vector3;
  7314. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  7315. static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector3): void;
  7316. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  7317. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  7318. static Zero(): Vector3;
  7319. static Up(): Vector3;
  7320. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  7321. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  7322. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  7323. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  7324. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  7325. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  7326. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  7327. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  7328. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  7329. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  7330. static Dot(left: Vector3, right: Vector3): number;
  7331. static Cross(left: Vector3, right: Vector3): Vector3;
  7332. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  7333. static Normalize(vector: Vector3): Vector3;
  7334. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  7335. private static _viewportMatrixCache;
  7336. private static _matrixCache;
  7337. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  7338. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  7339. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  7340. static Minimize(left: Vector3, right: Vector3): Vector3;
  7341. static Maximize(left: Vector3, right: Vector3): Vector3;
  7342. static Distance(value1: Vector3, value2: Vector3): number;
  7343. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  7344. static Center(value1: Vector3, value2: Vector3): Vector3;
  7345. /**
  7346. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  7347. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  7348. * to something in order to rotate it from its local system to the given target system.
  7349. */
  7350. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  7351. /**
  7352. * The same than RotationFromAxis but updates the passed ref Vector3 parameter.
  7353. */
  7354. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  7355. }
  7356. class Vector4 {
  7357. x: number;
  7358. y: number;
  7359. z: number;
  7360. w: number;
  7361. constructor(x: number, y: number, z: number, w: number);
  7362. toString(): string;
  7363. getClassName(): string;
  7364. getHashCode(): number;
  7365. asArray(): number[];
  7366. toArray(array: number[], index?: number): Vector4;
  7367. addInPlace(otherVector: Vector4): Vector4;
  7368. add(otherVector: Vector4): Vector4;
  7369. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  7370. subtractInPlace(otherVector: Vector4): Vector4;
  7371. subtract(otherVector: Vector4): Vector4;
  7372. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  7373. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  7374. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  7375. negate(): Vector4;
  7376. scaleInPlace(scale: number): Vector4;
  7377. scale(scale: number): Vector4;
  7378. scaleToRef(scale: number, result: Vector4): void;
  7379. equals(otherVector: Vector4): boolean;
  7380. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  7381. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  7382. multiplyInPlace(otherVector: Vector4): Vector4;
  7383. multiply(otherVector: Vector4): Vector4;
  7384. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  7385. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  7386. divide(otherVector: Vector4): Vector4;
  7387. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  7388. MinimizeInPlace(other: Vector4): Vector4;
  7389. MaximizeInPlace(other: Vector4): Vector4;
  7390. length(): number;
  7391. lengthSquared(): number;
  7392. normalize(): Vector4;
  7393. toVector3(): Vector3;
  7394. clone(): Vector4;
  7395. copyFrom(source: Vector4): Vector4;
  7396. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  7397. static FromArray(array: number[], offset?: number): Vector4;
  7398. static FromArrayToRef(array: number[], offset: number, result: Vector4): void;
  7399. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  7400. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  7401. static Zero(): Vector4;
  7402. static Normalize(vector: Vector4): Vector4;
  7403. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  7404. static Minimize(left: Vector4, right: Vector4): Vector4;
  7405. static Maximize(left: Vector4, right: Vector4): Vector4;
  7406. static Distance(value1: Vector4, value2: Vector4): number;
  7407. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  7408. static Center(value1: Vector4, value2: Vector4): Vector4;
  7409. }
  7410. interface ISize {
  7411. width: number;
  7412. height: number;
  7413. }
  7414. class Size implements ISize {
  7415. width: number;
  7416. height: number;
  7417. constructor(width: number, height: number);
  7418. toString(): string;
  7419. getClassName(): string;
  7420. getHashCode(): number;
  7421. copyFrom(src: Size): void;
  7422. copyFromFloats(width: number, height: number): void;
  7423. multiplyByFloats(w: number, h: number): Size;
  7424. clone(): Size;
  7425. equals(other: Size): boolean;
  7426. surface: number;
  7427. static Zero(): Size;
  7428. add(otherSize: Size): Size;
  7429. substract(otherSize: Size): Size;
  7430. static Lerp(start: Size, end: Size, amount: number): Size;
  7431. }
  7432. class Quaternion {
  7433. x: number;
  7434. y: number;
  7435. z: number;
  7436. w: number;
  7437. constructor(x?: number, y?: number, z?: number, w?: number);
  7438. toString(): string;
  7439. getClassName(): string;
  7440. getHashCode(): number;
  7441. asArray(): number[];
  7442. equals(otherQuaternion: Quaternion): boolean;
  7443. clone(): Quaternion;
  7444. copyFrom(other: Quaternion): Quaternion;
  7445. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  7446. add(other: Quaternion): Quaternion;
  7447. subtract(other: Quaternion): Quaternion;
  7448. scale(value: number): Quaternion;
  7449. multiply(q1: Quaternion): Quaternion;
  7450. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  7451. multiplyInPlace(q1: Quaternion): Quaternion;
  7452. conjugateToRef(ref: Quaternion): Quaternion;
  7453. conjugateInPlace(): Quaternion;
  7454. conjugate(): Quaternion;
  7455. length(): number;
  7456. normalize(): Quaternion;
  7457. toEulerAngles(order?: string): Vector3;
  7458. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  7459. toRotationMatrix(result: Matrix): Quaternion;
  7460. fromRotationMatrix(matrix: Matrix): Quaternion;
  7461. static FromRotationMatrix(matrix: Matrix): Quaternion;
  7462. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  7463. static Inverse(q: Quaternion): Quaternion;
  7464. static Identity(): Quaternion;
  7465. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  7466. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  7467. static FromArray(array: number[], offset?: number): Quaternion;
  7468. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  7469. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  7470. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  7471. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  7472. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  7473. }
  7474. class Matrix {
  7475. private static _tempQuaternion;
  7476. private static _xAxis;
  7477. private static _yAxis;
  7478. private static _zAxis;
  7479. m: Float32Array;
  7480. isIdentity(): boolean;
  7481. determinant(): number;
  7482. toArray(): Float32Array;
  7483. asArray(): Float32Array;
  7484. invert(): Matrix;
  7485. reset(): Matrix;
  7486. add(other: Matrix): Matrix;
  7487. addToRef(other: Matrix, result: Matrix): Matrix;
  7488. addToSelf(other: Matrix): Matrix;
  7489. invertToRef(other: Matrix): Matrix;
  7490. setTranslation(vector3: Vector3): Matrix;
  7491. getTranslation(): Vector3;
  7492. multiply(other: Matrix): Matrix;
  7493. copyFrom(other: Matrix): Matrix;
  7494. copyToArray(array: Float32Array, offset?: number): Matrix;
  7495. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  7496. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  7497. equals(value: Matrix): boolean;
  7498. clone(): Matrix;
  7499. getClassName(): string;
  7500. getHashCode(): number;
  7501. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  7502. static FromArray(array: number[], offset?: number): Matrix;
  7503. static FromArrayToRef(array: number[], offset: number, result: Matrix): void;
  7504. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  7505. 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;
  7506. getRow(index: number): Vector4;
  7507. setRow(index: number, row: Vector4): Matrix;
  7508. 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;
  7509. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  7510. static Identity(): Matrix;
  7511. static IdentityToRef(result: Matrix): void;
  7512. static Zero(): Matrix;
  7513. static RotationX(angle: number): Matrix;
  7514. static Invert(source: Matrix): Matrix;
  7515. static RotationXToRef(angle: number, result: Matrix): void;
  7516. static RotationY(angle: number): Matrix;
  7517. static RotationYToRef(angle: number, result: Matrix): void;
  7518. static RotationZ(angle: number): Matrix;
  7519. static RotationZToRef(angle: number, result: Matrix): void;
  7520. static RotationAxis(axis: Vector3, angle: number): Matrix;
  7521. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  7522. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  7523. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  7524. static Scaling(x: number, y: number, z: number): Matrix;
  7525. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  7526. static Translation(x: number, y: number, z: number): Matrix;
  7527. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  7528. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  7529. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  7530. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  7531. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  7532. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  7533. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  7534. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  7535. static OrthoOffCenterLHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  7536. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  7537. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  7538. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  7539. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  7540. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  7541. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  7542. static Transpose(matrix: Matrix): Matrix;
  7543. static Reflection(plane: Plane): Matrix;
  7544. static ReflectionToRef(plane: Plane, result: Matrix): void;
  7545. }
  7546. class Plane {
  7547. normal: Vector3;
  7548. d: number;
  7549. constructor(a: number, b: number, c: number, d: number);
  7550. asArray(): number[];
  7551. clone(): Plane;
  7552. getClassName(): string;
  7553. getHashCode(): number;
  7554. normalize(): Plane;
  7555. transform(transformation: Matrix): Plane;
  7556. dotCoordinate(point: any): number;
  7557. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  7558. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  7559. signedDistanceTo(point: Vector3): number;
  7560. static FromArray(array: number[]): Plane;
  7561. static FromPoints(point1: any, point2: any, point3: any): Plane;
  7562. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  7563. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  7564. }
  7565. class Viewport {
  7566. x: number;
  7567. y: number;
  7568. width: number;
  7569. height: number;
  7570. constructor(x: number, y: number, width: number, height: number);
  7571. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  7572. }
  7573. class Frustum {
  7574. static GetPlanes(transform: Matrix): Plane[];
  7575. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  7576. }
  7577. enum Space {
  7578. LOCAL = 0,
  7579. WORLD = 1,
  7580. }
  7581. class Axis {
  7582. static X: Vector3;
  7583. static Y: Vector3;
  7584. static Z: Vector3;
  7585. }
  7586. class BezierCurve {
  7587. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  7588. }
  7589. enum Orientation {
  7590. CW = 0,
  7591. CCW = 1,
  7592. }
  7593. class Angle {
  7594. private _radians;
  7595. constructor(radians: number);
  7596. degrees: () => number;
  7597. radians: () => number;
  7598. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  7599. static FromRadians(radians: number): Angle;
  7600. static FromDegrees(degrees: number): Angle;
  7601. }
  7602. class Arc2 {
  7603. startPoint: Vector2;
  7604. midPoint: Vector2;
  7605. endPoint: Vector2;
  7606. centerPoint: Vector2;
  7607. radius: number;
  7608. angle: Angle;
  7609. startAngle: Angle;
  7610. orientation: Orientation;
  7611. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  7612. }
  7613. class Path2 {
  7614. private _points;
  7615. private _length;
  7616. closed: boolean;
  7617. constructor(x: number, y: number);
  7618. addLineTo(x: number, y: number): Path2;
  7619. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  7620. close(): Path2;
  7621. length(): number;
  7622. getPoints(): Vector2[];
  7623. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  7624. static StartingAt(x: number, y: number): Path2;
  7625. }
  7626. class Path3D {
  7627. path: Vector3[];
  7628. private _curve;
  7629. private _distances;
  7630. private _tangents;
  7631. private _normals;
  7632. private _binormals;
  7633. private _raw;
  7634. /**
  7635. * new Path3D(path, normal, raw)
  7636. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  7637. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  7638. * path : an array of Vector3, the curve axis of the Path3D
  7639. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  7640. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  7641. */
  7642. constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean);
  7643. /**
  7644. * Returns the Path3D array of successive Vector3 designing its curve.
  7645. */
  7646. getCurve(): Vector3[];
  7647. /**
  7648. * Returns an array populated with tangent vectors on each Path3D curve point.
  7649. */
  7650. getTangents(): Vector3[];
  7651. /**
  7652. * Returns an array populated with normal vectors on each Path3D curve point.
  7653. */
  7654. getNormals(): Vector3[];
  7655. /**
  7656. * Returns an array populated with binormal vectors on each Path3D curve point.
  7657. */
  7658. getBinormals(): Vector3[];
  7659. /**
  7660. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  7661. */
  7662. getDistances(): number[];
  7663. /**
  7664. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  7665. * Returns the same object updated.
  7666. */
  7667. update(path: Vector3[], firstNormal?: Vector3): Path3D;
  7668. private _compute(firstNormal);
  7669. private _getFirstNonNullVector(index);
  7670. private _getLastNonNullVector(index);
  7671. private _normalVector(v0, vt, va);
  7672. }
  7673. class Curve3 {
  7674. private _points;
  7675. private _length;
  7676. /**
  7677. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  7678. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  7679. * @param v1 (Vector3) the control point
  7680. * @param v2 (Vector3) the end point of the Quadratic Bezier
  7681. * @param nbPoints (integer) the wanted number of points in the curve
  7682. */
  7683. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  7684. /**
  7685. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  7686. * @param v0 (Vector3) the origin point of the Cubic Bezier
  7687. * @param v1 (Vector3) the first control point
  7688. * @param v2 (Vector3) the second control point
  7689. * @param v3 (Vector3) the end point of the Cubic Bezier
  7690. * @param nbPoints (integer) the wanted number of points in the curve
  7691. */
  7692. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  7693. /**
  7694. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  7695. * @param p1 (Vector3) the origin point of the Hermite Spline
  7696. * @param t1 (Vector3) the tangent vector at the origin point
  7697. * @param p2 (Vector3) the end point of the Hermite Spline
  7698. * @param t2 (Vector3) the tangent vector at the end point
  7699. * @param nbPoints (integer) the wanted number of points in the curve
  7700. */
  7701. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  7702. /**
  7703. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  7704. * A Curve3 is designed from a series of successive Vector3.
  7705. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  7706. */
  7707. constructor(points: Vector3[]);
  7708. /**
  7709. * Returns the Curve3 stored array of successive Vector3
  7710. */
  7711. getPoints(): Vector3[];
  7712. /**
  7713. * Returns the computed length (float) of the curve.
  7714. */
  7715. length(): number;
  7716. /**
  7717. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  7718. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  7719. * curveA and curveB keep unchanged.
  7720. */
  7721. continue(curve: Curve3): Curve3;
  7722. private _computeLength(path);
  7723. }
  7724. class SphericalHarmonics {
  7725. L00: Vector3;
  7726. L1_1: Vector3;
  7727. L10: Vector3;
  7728. L11: Vector3;
  7729. L2_2: Vector3;
  7730. L2_1: Vector3;
  7731. L20: Vector3;
  7732. L21: Vector3;
  7733. L22: Vector3;
  7734. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  7735. scale(scale: number): void;
  7736. }
  7737. class SphericalPolynomial {
  7738. x: Vector3;
  7739. y: Vector3;
  7740. z: Vector3;
  7741. xx: Vector3;
  7742. yy: Vector3;
  7743. zz: Vector3;
  7744. xy: Vector3;
  7745. yz: Vector3;
  7746. zx: Vector3;
  7747. addAmbient(color: Color3): void;
  7748. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  7749. }
  7750. class PositionNormalVertex {
  7751. position: Vector3;
  7752. normal: Vector3;
  7753. constructor(position?: Vector3, normal?: Vector3);
  7754. clone(): PositionNormalVertex;
  7755. }
  7756. class PositionNormalTextureVertex {
  7757. position: Vector3;
  7758. normal: Vector3;
  7759. uv: Vector2;
  7760. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  7761. clone(): PositionNormalTextureVertex;
  7762. }
  7763. class Tmp {
  7764. static Color3: Color3[];
  7765. static Vector2: Vector2[];
  7766. static Vector3: Vector3[];
  7767. static Vector4: Vector4[];
  7768. static Quaternion: Quaternion[];
  7769. static Matrix: Matrix[];
  7770. }
  7771. }
  7772. declare module BABYLON {
  7773. interface PhysicsImpostorJoint {
  7774. mainImpostor: PhysicsImpostor;
  7775. connectedImpostor: PhysicsImpostor;
  7776. joint: PhysicsJoint;
  7777. }
  7778. class PhysicsEngine {
  7779. private _physicsPlugin;
  7780. gravity: Vector3;
  7781. constructor(gravity?: Vector3, _physicsPlugin?: IPhysicsEnginePlugin);
  7782. setGravity(gravity: Vector3): void;
  7783. /**
  7784. * Set the time step of the physics engine.
  7785. * default is 1/60.
  7786. * To slow it down, enter 1/600 for example.
  7787. * To speed it up, 1/30
  7788. * @param {number} newTimeStep the new timestep to apply to this world.
  7789. */
  7790. setTimeStep(newTimeStep?: number): void;
  7791. dispose(): void;
  7792. getPhysicsPluginName(): string;
  7793. /**
  7794. * @Deprecated
  7795. *
  7796. */
  7797. static NoImpostor: number;
  7798. static SphereImpostor: number;
  7799. static BoxImpostor: number;
  7800. static PlaneImpostor: number;
  7801. static MeshImpostor: number;
  7802. static CylinderImpostor: number;
  7803. static HeightmapImpostor: number;
  7804. static CapsuleImpostor: number;
  7805. static ConeImpostor: number;
  7806. static ConvexHullImpostor: number;
  7807. static Epsilon: number;
  7808. private _impostors;
  7809. private _joints;
  7810. /**
  7811. * Adding a new impostor for the impostor tracking.
  7812. * This will be done by the impostor itself.
  7813. * @param {PhysicsImpostor} impostor the impostor to add
  7814. */
  7815. addImpostor(impostor: PhysicsImpostor): void;
  7816. /**
  7817. * Remove an impostor from the engine.
  7818. * This impostor and its mesh will not longer be updated by the physics engine.
  7819. * @param {PhysicsImpostor} impostor the impostor to remove
  7820. */
  7821. removeImpostor(impostor: PhysicsImpostor): void;
  7822. /**
  7823. * Add a joint to the physics engine
  7824. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  7825. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  7826. * @param {PhysicsJoint} the joint that will connect both impostors.
  7827. */
  7828. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  7829. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  7830. /**
  7831. * Called by the scene. no need to call it.
  7832. */
  7833. _step(delta: number): void;
  7834. getPhysicsPlugin(): IPhysicsEnginePlugin;
  7835. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): PhysicsImpostor;
  7836. getImpostorWithPhysicsBody(body: any): PhysicsImpostor;
  7837. }
  7838. interface IPhysicsEnginePlugin {
  7839. world: any;
  7840. name: string;
  7841. setGravity(gravity: Vector3): any;
  7842. setTimeStep(timeStep: number): any;
  7843. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  7844. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): any;
  7845. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): any;
  7846. generatePhysicsBody(impostor: PhysicsImpostor): any;
  7847. removePhysicsBody(impostor: PhysicsImpostor): any;
  7848. generateJoint(joint: PhysicsImpostorJoint): any;
  7849. removeJoint(joint: PhysicsImpostorJoint): any;
  7850. isSupported(): boolean;
  7851. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): any;
  7852. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): any;
  7853. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): any;
  7854. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): any;
  7855. getLinearVelocity(impostor: PhysicsImpostor): Vector3;
  7856. getAngularVelocity(impostor: PhysicsImpostor): Vector3;
  7857. setBodyMass(impostor: PhysicsImpostor, mass: number): any;
  7858. sleepBody(impostor: PhysicsImpostor): any;
  7859. wakeUpBody(impostor: PhysicsImpostor): any;
  7860. updateDistanceJoint(joint: DistanceJoint, maxDistance: number, minDistance?: number): any;
  7861. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): any;
  7862. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): any;
  7863. dispose(): any;
  7864. }
  7865. }
  7866. declare module BABYLON {
  7867. interface PhysicsImpostorParameters {
  7868. mass: number;
  7869. friction?: number;
  7870. restitution?: number;
  7871. nativeOptions?: any;
  7872. }
  7873. interface IPhysicsEnabledObject {
  7874. position: Vector3;
  7875. rotationQuaternion: Quaternion;
  7876. scaling: Vector3;
  7877. rotation?: Vector3;
  7878. parent?: any;
  7879. getBoundingInfo?(): BoundingInfo;
  7880. computeWorldMatrix?(force: boolean): void;
  7881. getChildMeshes?(): Array<AbstractMesh>;
  7882. getVerticesData?(kind: string): Array<number> | Float32Array;
  7883. getIndices?(): Array<number> | Int32Array;
  7884. getScene?(): Scene;
  7885. }
  7886. class PhysicsImpostor {
  7887. object: IPhysicsEnabledObject;
  7888. type: number;
  7889. private _options;
  7890. private _scene;
  7891. static DEFAULT_OBJECT_SIZE: Vector3;
  7892. private _physicsEngine;
  7893. private _physicsBody;
  7894. private _bodyUpdateRequired;
  7895. private _onBeforePhysicsStepCallbacks;
  7896. private _onAfterPhysicsStepCallbacks;
  7897. private _onPhysicsCollideCallbacks;
  7898. private _deltaPosition;
  7899. private _deltaRotation;
  7900. private _deltaRotationConjugated;
  7901. private _parent;
  7902. uniqueId: number;
  7903. private _joints;
  7904. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene);
  7905. /**
  7906. * This function will completly initialize this impostor.
  7907. * It will create a new body - but only if this mesh has no parent.
  7908. * If it has, this impostor will not be used other than to define the impostor
  7909. * of the child mesh.
  7910. */
  7911. _init(): void;
  7912. private _getPhysicsParent();
  7913. /**
  7914. * Should a new body be generated.
  7915. */
  7916. isBodyInitRequired(): boolean;
  7917. setScalingUpdated(updated: boolean): void;
  7918. /**
  7919. * Force a regeneration of this or the parent's impostor's body.
  7920. * Use under cautious - This will remove all joints already implemented.
  7921. */
  7922. forceUpdate(): void;
  7923. /**
  7924. * Gets the body that holds this impostor. Either its own, or its parent.
  7925. */
  7926. /**
  7927. * Set the physics body. Used mainly by the physics engine/plugin
  7928. */
  7929. physicsBody: any;
  7930. parent: PhysicsImpostor;
  7931. resetUpdateFlags(): void;
  7932. getObjectExtendSize(): Vector3;
  7933. getObjectCenter(): Vector3;
  7934. /**
  7935. * Get a specific parametes from the options parameter.
  7936. */
  7937. getParam(paramName: string): any;
  7938. /**
  7939. * Sets a specific parameter in the options given to the physics plugin
  7940. */
  7941. setParam(paramName: string, value: number): void;
  7942. /**
  7943. * Specifically change the body's mass option. Won't recreate the physics body object
  7944. */
  7945. setMass(mass: number): void;
  7946. getLinearVelocity(): Vector3;
  7947. /**
  7948. * Set the body's linear velocity.
  7949. */
  7950. setLinearVelocity(velocity: Vector3): void;
  7951. getAngularVelocity(): Vector3;
  7952. /**
  7953. * Set the body's linear velocity.
  7954. */
  7955. setAngularVelocity(velocity: Vector3): void;
  7956. /**
  7957. * Execute a function with the physics plugin native code.
  7958. * Provide a function the will have two variables - the world object and the physics body object.
  7959. */
  7960. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  7961. /**
  7962. * Register a function that will be executed before the physics world is stepping forward.
  7963. */
  7964. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  7965. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  7966. /**
  7967. * Register a function that will be executed after the physics step
  7968. */
  7969. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  7970. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  7971. /**
  7972. * register a function that will be executed when this impostor collides against a different body.
  7973. */
  7974. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  7975. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  7976. private _tmpPositionWithDelta;
  7977. private _tmpRotationWithDelta;
  7978. /**
  7979. * this function is executed by the physics engine.
  7980. */
  7981. beforeStep: () => void;
  7982. /**
  7983. * this function is executed by the physics engine.
  7984. */
  7985. afterStep: () => void;
  7986. onCollide: (e: {
  7987. body: any;
  7988. }) => void;
  7989. /**
  7990. * Apply a force
  7991. */
  7992. applyForce(force: Vector3, contactPoint: Vector3): void;
  7993. /**
  7994. * Apply an impulse
  7995. */
  7996. applyImpulse(force: Vector3, contactPoint: Vector3): void;
  7997. /**
  7998. * A help function to create a joint.
  7999. */
  8000. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): void;
  8001. /**
  8002. * Add a joint to this impostor with a different impostor.
  8003. */
  8004. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  8005. /**
  8006. * Will keep this body still, in a sleep mode.
  8007. */
  8008. sleep(): void;
  8009. /**
  8010. * Wake the body up.
  8011. */
  8012. wakeUp(): void;
  8013. clone(newObject: IPhysicsEnabledObject): PhysicsImpostor;
  8014. dispose(): void;
  8015. setDeltaPosition(position: Vector3): void;
  8016. setDeltaRotation(rotation: Quaternion): void;
  8017. static NoImpostor: number;
  8018. static SphereImpostor: number;
  8019. static BoxImpostor: number;
  8020. static PlaneImpostor: number;
  8021. static MeshImpostor: number;
  8022. static CylinderImpostor: number;
  8023. static ParticleImpostor: number;
  8024. static HeightmapImpostor: number;
  8025. }
  8026. }
  8027. declare module BABYLON {
  8028. interface PhysicsJointData {
  8029. mainPivot?: Vector3;
  8030. connectedPivot?: Vector3;
  8031. mainAxis?: Vector3;
  8032. connectedAxis?: Vector3;
  8033. collision?: boolean;
  8034. nativeParams?: any;
  8035. }
  8036. /**
  8037. * This is a holder class for the physics joint created by the physics plugin.
  8038. * It holds a set of functions to control the underlying joint.
  8039. */
  8040. class PhysicsJoint {
  8041. type: number;
  8042. jointData: PhysicsJointData;
  8043. private _physicsJoint;
  8044. protected _physicsPlugin: IPhysicsEnginePlugin;
  8045. constructor(type: number, jointData: PhysicsJointData);
  8046. physicsJoint: any;
  8047. physicsPlugin: IPhysicsEnginePlugin;
  8048. /**
  8049. * Execute a function that is physics-plugin specific.
  8050. * @param {Function} func the function that will be executed.
  8051. * It accepts two parameters: the physics world and the physics joint.
  8052. */
  8053. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  8054. static DistanceJoint: number;
  8055. static HingeJoint: number;
  8056. static BallAndSocketJoint: number;
  8057. static WheelJoint: number;
  8058. static SliderJoint: number;
  8059. static PrismaticJoint: number;
  8060. static UniversalJoint: number;
  8061. static Hinge2Joint: number;
  8062. static PointToPointJoint: number;
  8063. static SpringJoint: number;
  8064. static LockJoint: number;
  8065. }
  8066. /**
  8067. * A class representing a physics distance joint.
  8068. */
  8069. class DistanceJoint extends PhysicsJoint {
  8070. constructor(jointData: DistanceJointData);
  8071. /**
  8072. * Update the predefined distance.
  8073. */
  8074. updateDistance(maxDistance: number, minDistance?: number): void;
  8075. }
  8076. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  8077. constructor(type: number, jointData: PhysicsJointData);
  8078. /**
  8079. * Set the motor values.
  8080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  8081. * @param {number} force the force to apply
  8082. * @param {number} maxForce max force for this motor.
  8083. */
  8084. setMotor(force?: number, maxForce?: number): void;
  8085. /**
  8086. * Set the motor's limits.
  8087. * Attention, this function is plugin specific. Engines won't react 100% the same.
  8088. */
  8089. setLimit(upperLimit: number, lowerLimit?: number): void;
  8090. }
  8091. /**
  8092. * This class represents a single hinge physics joint
  8093. */
  8094. class HingeJoint extends MotorEnabledJoint {
  8095. constructor(jointData: PhysicsJointData);
  8096. /**
  8097. * Set the motor values.
  8098. * Attention, this function is plugin specific. Engines won't react 100% the same.
  8099. * @param {number} force the force to apply
  8100. * @param {number} maxForce max force for this motor.
  8101. */
  8102. setMotor(force?: number, maxForce?: number): void;
  8103. /**
  8104. * Set the motor's limits.
  8105. * Attention, this function is plugin specific. Engines won't react 100% the same.
  8106. */
  8107. setLimit(upperLimit: number, lowerLimit?: number): void;
  8108. }
  8109. /**
  8110. * This class represents a dual hinge physics joint (same as wheel joint)
  8111. */
  8112. class Hinge2Joint extends MotorEnabledJoint {
  8113. constructor(jointData: PhysicsJointData);
  8114. /**
  8115. * Set the motor values.
  8116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  8117. * @param {number} force the force to apply
  8118. * @param {number} maxForce max force for this motor.
  8119. * @param {motorIndex} the motor's index, 0 or 1.
  8120. */
  8121. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  8122. /**
  8123. * Set the motor limits.
  8124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  8125. * @param {number} upperLimit the upper limit
  8126. * @param {number} lowerLimit lower limit
  8127. * @param {motorIndex} the motor's index, 0 or 1.
  8128. */
  8129. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  8130. }
  8131. interface IMotorEnabledJoint {
  8132. physicsJoint: any;
  8133. setMotor(force?: number, maxForce?: number, motorIndex?: number): any;
  8134. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): any;
  8135. }
  8136. interface DistanceJointData extends PhysicsJointData {
  8137. maxDistance: number;
  8138. }
  8139. interface SpringJointData extends PhysicsJointData {
  8140. length: number;
  8141. stiffness: number;
  8142. damping: number;
  8143. }
  8144. }
  8145. declare module BABYLON {
  8146. class AbstractMesh extends Node implements IDisposable, ICullable {
  8147. private static _BILLBOARDMODE_NONE;
  8148. private static _BILLBOARDMODE_X;
  8149. private static _BILLBOARDMODE_Y;
  8150. private static _BILLBOARDMODE_Z;
  8151. private static _BILLBOARDMODE_ALL;
  8152. static BILLBOARDMODE_NONE: number;
  8153. static BILLBOARDMODE_X: number;
  8154. static BILLBOARDMODE_Y: number;
  8155. static BILLBOARDMODE_Z: number;
  8156. static BILLBOARDMODE_ALL: number;
  8157. /**
  8158. * An event triggered when the mesh is disposed.
  8159. * @type {BABYLON.Observable}
  8160. */
  8161. onDisposeObservable: Observable<AbstractMesh>;
  8162. private _onDisposeObserver;
  8163. onDispose: () => void;
  8164. /**
  8165. * An event triggered when this mesh collides with another one
  8166. * @type {BABYLON.Observable}
  8167. */
  8168. onCollideObservable: Observable<AbstractMesh>;
  8169. private _onCollideObserver;
  8170. onCollide: () => void;
  8171. /**
  8172. * An event triggered when the collision's position changes
  8173. * @type {BABYLON.Observable}
  8174. */
  8175. onCollisionPositionChangeObservable: Observable<Vector3>;
  8176. private _onCollisionPositionChangeObserver;
  8177. onCollisionPositionChange: () => void;
  8178. /**
  8179. * An event triggered after the world matrix is updated
  8180. * @type {BABYLON.Observable}
  8181. */
  8182. onAfterWorldMatrixUpdateObservable: Observable<AbstractMesh>;
  8183. definedFacingForward: boolean;
  8184. position: Vector3;
  8185. private _rotation;
  8186. _rotationQuaternion: Quaternion;
  8187. private _scaling;
  8188. billboardMode: number;
  8189. visibility: number;
  8190. alphaIndex: number;
  8191. infiniteDistance: boolean;
  8192. isVisible: boolean;
  8193. isPickable: boolean;
  8194. showBoundingBox: boolean;
  8195. showSubMeshesBoundingBox: boolean;
  8196. isBlocker: boolean;
  8197. renderingGroupId: number;
  8198. material: Material;
  8199. receiveShadows: boolean;
  8200. renderOutline: boolean;
  8201. outlineColor: Color3;
  8202. outlineWidth: number;
  8203. renderOverlay: boolean;
  8204. overlayColor: Color3;
  8205. overlayAlpha: number;
  8206. hasVertexAlpha: boolean;
  8207. useVertexColors: boolean;
  8208. applyFog: boolean;
  8209. computeBonesUsingShaders: boolean;
  8210. scalingDeterminant: number;
  8211. numBoneInfluencers: number;
  8212. useOctreeForRenderingSelection: boolean;
  8213. useOctreeForPicking: boolean;
  8214. useOctreeForCollisions: boolean;
  8215. layerMask: number;
  8216. alwaysSelectAsActiveMesh: boolean;
  8217. /**
  8218. * This scene's action manager
  8219. * @type {BABYLON.ActionManager}
  8220. */
  8221. actionManager: ActionManager;
  8222. physicsImpostor: BABYLON.PhysicsImpostor;
  8223. onPhysicsCollide: (collidedMesh: AbstractMesh, contact: any) => void;
  8224. private _checkCollisions;
  8225. ellipsoid: Vector3;
  8226. ellipsoidOffset: Vector3;
  8227. private _collider;
  8228. private _oldPositionForCollisions;
  8229. private _diffPositionForCollisions;
  8230. private _newPositionForCollisions;
  8231. private _meshToBoneReferal;
  8232. edgesWidth: number;
  8233. edgesColor: Color4;
  8234. _edgesRenderer: EdgesRenderer;
  8235. private _localWorld;
  8236. _worldMatrix: Matrix;
  8237. private _rotateYByPI;
  8238. private _absolutePosition;
  8239. private _collisionsTransformMatrix;
  8240. private _collisionsScalingMatrix;
  8241. _positions: Vector3[];
  8242. private _isDirty;
  8243. _masterMesh: AbstractMesh;
  8244. _materialDefines: MaterialDefines;
  8245. _boundingInfo: BoundingInfo;
  8246. private _pivotMatrix;
  8247. _isDisposed: boolean;
  8248. _renderId: number;
  8249. subMeshes: SubMesh[];
  8250. _submeshesOctree: Octree<SubMesh>;
  8251. _intersectionsInProgress: AbstractMesh[];
  8252. private _isWorldMatrixFrozen;
  8253. _unIndexed: boolean;
  8254. _poseMatrix: Matrix;
  8255. _waitingActions: any;
  8256. _waitingFreezeWorldMatrix: boolean;
  8257. private _skeleton;
  8258. _bonesTransformMatrices: Float32Array;
  8259. skeleton: Skeleton;
  8260. constructor(name: string, scene: Scene);
  8261. /**
  8262. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  8263. */
  8264. toString(fullDetails?: boolean): string;
  8265. /**
  8266. * Getting the rotation object.
  8267. * If rotation quaternion is set, this vector will (almost always) be the Zero vector!
  8268. */
  8269. rotation: Vector3;
  8270. scaling: Vector3;
  8271. rotationQuaternion: Quaternion;
  8272. updatePoseMatrix(matrix: Matrix): void;
  8273. getPoseMatrix(): Matrix;
  8274. disableEdgesRendering(): void;
  8275. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): void;
  8276. isBlocked: boolean;
  8277. getLOD(camera: Camera): AbstractMesh;
  8278. getTotalVertices(): number;
  8279. getIndices(): number[] | Int32Array;
  8280. getVerticesData(kind: string): number[] | Float32Array;
  8281. isVerticesDataPresent(kind: string): boolean;
  8282. getBoundingInfo(): BoundingInfo;
  8283. useBones: boolean;
  8284. _preActivate(): void;
  8285. _preActivateForIntermediateRendering(renderId: number): void;
  8286. _activate(renderId: number): void;
  8287. getWorldMatrix(): Matrix;
  8288. worldMatrixFromCache: Matrix;
  8289. absolutePosition: Vector3;
  8290. freezeWorldMatrix(): void;
  8291. unfreezeWorldMatrix(): void;
  8292. isWorldMatrixFrozen: boolean;
  8293. private static _rotationAxisCache;
  8294. rotate(axis: Vector3, amount: number, space?: Space): void;
  8295. translate(axis: Vector3, distance: number, space?: Space): void;
  8296. getAbsolutePosition(): Vector3;
  8297. setAbsolutePosition(absolutePosition: Vector3): void;
  8298. /**
  8299. * Perform relative position change from the point of view of behind the front of the mesh.
  8300. * This is performed taking into account the meshes current rotation, so you do not have to care.
  8301. * Supports definition of mesh facing forward or backward.
  8302. * @param {number} amountRight
  8303. * @param {number} amountUp
  8304. * @param {number} amountForward
  8305. */
  8306. movePOV(amountRight: number, amountUp: number, amountForward: number): void;
  8307. /**
  8308. * Calculate relative position change from the point of view of behind the front of the mesh.
  8309. * This is performed taking into account the meshes current rotation, so you do not have to care.
  8310. * Supports definition of mesh facing forward or backward.
  8311. * @param {number} amountRight
  8312. * @param {number} amountUp
  8313. * @param {number} amountForward
  8314. */
  8315. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  8316. /**
  8317. * Perform relative rotation change from the point of view of behind the front of the mesh.
  8318. * Supports definition of mesh facing forward or backward.
  8319. * @param {number} flipBack
  8320. * @param {number} twirlClockwise
  8321. * @param {number} tiltRight
  8322. */
  8323. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): void;
  8324. /**
  8325. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  8326. * Supports definition of mesh facing forward or backward.
  8327. * @param {number} flipBack
  8328. * @param {number} twirlClockwise
  8329. * @param {number} tiltRight
  8330. */
  8331. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  8332. setPivotMatrix(matrix: Matrix): void;
  8333. getPivotMatrix(): Matrix;
  8334. _isSynchronized(): boolean;
  8335. _initCache(): void;
  8336. markAsDirty(property: string): void;
  8337. _updateBoundingInfo(): void;
  8338. _updateSubMeshesBoundingInfo(matrix: Matrix): void;
  8339. computeWorldMatrix(force?: boolean): Matrix;
  8340. /**
  8341. * If you'd like to be callbacked after the mesh position, rotation or scaling has been updated
  8342. * @param func: callback function to add
  8343. */
  8344. registerAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  8345. unregisterAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  8346. setPositionWithLocalVector(vector3: Vector3): void;
  8347. getPositionExpressedInLocalSpace(): Vector3;
  8348. locallyTranslate(vector3: Vector3): void;
  8349. private static _lookAtVectorCache;
  8350. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): void;
  8351. attachToBone(bone: Bone, affectedMesh: AbstractMesh): void;
  8352. detachFromBone(): void;
  8353. isInFrustum(frustumPlanes: Plane[]): boolean;
  8354. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8355. intersectsMesh(mesh: AbstractMesh, precise?: boolean): boolean;
  8356. intersectsPoint(point: Vector3): boolean;
  8357. /**
  8358. * @Deprecated. Use new PhysicsImpostor instead.
  8359. * */
  8360. setPhysicsState(impostor?: any, options?: PhysicsImpostorParameters): any;
  8361. getPhysicsImpostor(): PhysicsImpostor;
  8362. /**
  8363. * @Deprecated. Use getPhysicsImpostor().getParam("mass");
  8364. */
  8365. getPhysicsMass(): number;
  8366. /**
  8367. * @Deprecated. Use getPhysicsImpostor().getParam("friction");
  8368. */
  8369. getPhysicsFriction(): number;
  8370. /**
  8371. * @Deprecated. Use getPhysicsImpostor().getParam("restitution");
  8372. */
  8373. getPhysicsRestitution(): number;
  8374. getPositionInCameraSpace(camera?: Camera): Vector3;
  8375. getDistanceToCamera(camera?: Camera): number;
  8376. applyImpulse(force: Vector3, contactPoint: Vector3): void;
  8377. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): void;
  8378. /**
  8379. * @Deprecated
  8380. */
  8381. updatePhysicsBodyPosition(): void;
  8382. /**
  8383. * @Deprecated
  8384. * Calling this function is not needed anymore.
  8385. * The physics engine takes care of transofmration automatically.
  8386. */
  8387. updatePhysicsBody(): void;
  8388. checkCollisions: boolean;
  8389. moveWithCollisions(velocity: Vector3): void;
  8390. private _onCollisionPositionChange;
  8391. /**
  8392. * This function will create an octree to help select the right submeshes for rendering, picking and collisions
  8393. * Please note that you must have a decent number of submeshes to get performance improvements when using octree
  8394. */
  8395. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  8396. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): void;
  8397. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): void;
  8398. _checkCollision(collider: Collider): void;
  8399. _generatePointsArray(): boolean;
  8400. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  8401. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): AbstractMesh;
  8402. releaseSubMeshes(): void;
  8403. dispose(doNotRecurse?: boolean): void;
  8404. }
  8405. }
  8406. declare module BABYLON {
  8407. class Buffer {
  8408. private _engine;
  8409. private _buffer;
  8410. private _data;
  8411. private _updatable;
  8412. private _strideSize;
  8413. private _instanced;
  8414. constructor(engine: any, data: number[] | Float32Array, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  8415. createVertexBuffer(kind: string, offset: number, size: number, stride?: number): VertexBuffer;
  8416. isUpdatable(): boolean;
  8417. getData(): number[] | Float32Array;
  8418. getBuffer(): WebGLBuffer;
  8419. getStrideSize(): number;
  8420. getIsInstanced(): boolean;
  8421. create(data?: number[] | Float32Array): void;
  8422. update(data: number[] | Float32Array): void;
  8423. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  8424. dispose(): void;
  8425. }
  8426. }
  8427. declare module BABYLON {
  8428. class CSG {
  8429. private polygons;
  8430. matrix: Matrix;
  8431. position: Vector3;
  8432. rotation: Vector3;
  8433. rotationQuaternion: Quaternion;
  8434. scaling: Vector3;
  8435. static FromMesh(mesh: Mesh): CSG;
  8436. private static FromPolygons(polygons);
  8437. clone(): CSG;
  8438. private toPolygons();
  8439. union(csg: CSG): CSG;
  8440. unionInPlace(csg: CSG): void;
  8441. subtract(csg: CSG): CSG;
  8442. subtractInPlace(csg: CSG): void;
  8443. intersect(csg: CSG): CSG;
  8444. intersectInPlace(csg: CSG): void;
  8445. inverse(): CSG;
  8446. inverseInPlace(): void;
  8447. copyTransformAttributes(csg: CSG): CSG;
  8448. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  8449. toMesh(name: string, material: Material, scene: Scene, keepSubMeshes: boolean): Mesh;
  8450. }
  8451. }
  8452. declare module BABYLON {
  8453. class Geometry implements IGetSetVerticesData {
  8454. id: string;
  8455. delayLoadState: number;
  8456. delayLoadingFile: string;
  8457. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  8458. private _scene;
  8459. private _engine;
  8460. private _meshes;
  8461. private _totalVertices;
  8462. private _indices;
  8463. private _vertexBuffers;
  8464. private _isDisposed;
  8465. private _extend;
  8466. private _boundingBias;
  8467. _delayInfo: any;
  8468. private _indexBuffer;
  8469. _boundingInfo: BoundingInfo;
  8470. _delayLoadingFunction: (any: any, geometry: Geometry) => void;
  8471. _softwareSkinningRenderId: number;
  8472. /**
  8473. * The Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  8474. * @returns The Bias Vector
  8475. */
  8476. boundingBias: Vector2;
  8477. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Mesh);
  8478. extend: {
  8479. minimum: Vector3;
  8480. maximum: Vector3;
  8481. };
  8482. getScene(): Scene;
  8483. getEngine(): Engine;
  8484. isReady(): boolean;
  8485. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  8486. setVerticesData(kind: string, data: number[] | Float32Array, updatable?: boolean, stride?: number): void;
  8487. setVerticesBuffer(buffer: VertexBuffer): void;
  8488. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  8489. updateVerticesData(kind: string, data: number[] | Float32Array, updateExtends?: boolean): void;
  8490. private updateBoundingInfo(updateExtends, data);
  8491. getTotalVertices(): number;
  8492. getVerticesData(kind: string, copyWhenShared?: boolean): number[] | Float32Array;
  8493. getVertexBuffer(kind: string): VertexBuffer;
  8494. getVertexBuffers(): {
  8495. [key: string]: VertexBuffer;
  8496. };
  8497. isVerticesDataPresent(kind: string): boolean;
  8498. getVerticesDataKinds(): string[];
  8499. setIndices(indices: number[] | Int32Array, totalVertices?: number): void;
  8500. getTotalIndices(): number;
  8501. getIndices(copyWhenShared?: boolean): number[] | Int32Array;
  8502. getIndexBuffer(): WebGLBuffer;
  8503. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  8504. applyToMesh(mesh: Mesh): void;
  8505. private updateExtend(data?, stride?);
  8506. private _applyToMesh(mesh);
  8507. private notifyUpdate(kind?);
  8508. load(scene: Scene, onLoaded?: () => void): void;
  8509. private _queueLoad(scene, onLoaded?);
  8510. /**
  8511. * Invert the geometry to move from a right handed system to a left handed one.
  8512. */
  8513. toLeftHanded(): void;
  8514. isDisposed(): boolean;
  8515. dispose(): void;
  8516. copy(id: string): Geometry;
  8517. serialize(): any;
  8518. serializeVerticeData(): any;
  8519. static ExtractFromMesh(mesh: Mesh, id: string): Geometry;
  8520. static RandomId(): string;
  8521. static ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  8522. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Geometry;
  8523. }
  8524. module Geometry.Primitives {
  8525. class _Primitive extends Geometry {
  8526. private _canBeRegenerated;
  8527. private _beingRegenerated;
  8528. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Mesh);
  8529. canBeRegenerated(): boolean;
  8530. regenerate(): void;
  8531. asNewGeometry(id: string): Geometry;
  8532. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  8533. setVerticesData(kind: string, data: number[] | Int32Array | Float32Array, updatable?: boolean): void;
  8534. _regenerateVertexData(): VertexData;
  8535. copy(id: string): Geometry;
  8536. serialize(): any;
  8537. }
  8538. class Ribbon extends _Primitive {
  8539. pathArray: Vector3[][];
  8540. closeArray: boolean;
  8541. closePath: boolean;
  8542. offset: number;
  8543. side: number;
  8544. constructor(id: string, scene: Scene, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8545. _regenerateVertexData(): VertexData;
  8546. copy(id: string): Geometry;
  8547. }
  8548. class Box extends _Primitive {
  8549. size: number;
  8550. side: number;
  8551. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8552. _regenerateVertexData(): VertexData;
  8553. copy(id: string): Geometry;
  8554. serialize(): any;
  8555. static Parse(parsedBox: any, scene: Scene): Box;
  8556. }
  8557. class Sphere extends _Primitive {
  8558. segments: number;
  8559. diameter: number;
  8560. side: number;
  8561. constructor(id: string, scene: Scene, segments: number, diameter: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8562. _regenerateVertexData(): VertexData;
  8563. copy(id: string): Geometry;
  8564. serialize(): any;
  8565. static Parse(parsedSphere: any, scene: Scene): Geometry.Primitives.Sphere;
  8566. }
  8567. class Disc extends _Primitive {
  8568. radius: number;
  8569. tessellation: number;
  8570. side: number;
  8571. constructor(id: string, scene: Scene, radius: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8572. _regenerateVertexData(): VertexData;
  8573. copy(id: string): Geometry;
  8574. }
  8575. class Cylinder extends _Primitive {
  8576. height: number;
  8577. diameterTop: number;
  8578. diameterBottom: number;
  8579. tessellation: number;
  8580. subdivisions: number;
  8581. side: number;
  8582. constructor(id: string, scene: Scene, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8583. _regenerateVertexData(): VertexData;
  8584. copy(id: string): Geometry;
  8585. serialize(): any;
  8586. static Parse(parsedCylinder: any, scene: Scene): Geometry.Primitives.Cylinder;
  8587. }
  8588. class Torus extends _Primitive {
  8589. diameter: number;
  8590. thickness: number;
  8591. tessellation: number;
  8592. side: number;
  8593. constructor(id: string, scene: Scene, diameter: number, thickness: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8594. _regenerateVertexData(): VertexData;
  8595. copy(id: string): Geometry;
  8596. serialize(): any;
  8597. static Parse(parsedTorus: any, scene: Scene): Geometry.Primitives.Torus;
  8598. }
  8599. class Ground extends _Primitive {
  8600. width: number;
  8601. height: number;
  8602. subdivisions: number;
  8603. constructor(id: string, scene: Scene, width: number, height: number, subdivisions: number, canBeRegenerated?: boolean, mesh?: Mesh);
  8604. _regenerateVertexData(): VertexData;
  8605. copy(id: string): Geometry;
  8606. serialize(): any;
  8607. static Parse(parsedGround: any, scene: Scene): Geometry.Primitives.Ground;
  8608. }
  8609. class TiledGround extends _Primitive {
  8610. xmin: number;
  8611. zmin: number;
  8612. xmax: number;
  8613. zmax: number;
  8614. subdivisions: {
  8615. w: number;
  8616. h: number;
  8617. };
  8618. precision: {
  8619. w: number;
  8620. h: number;
  8621. };
  8622. constructor(id: string, scene: Scene, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  8623. w: number;
  8624. h: number;
  8625. }, precision: {
  8626. w: number;
  8627. h: number;
  8628. }, canBeRegenerated?: boolean, mesh?: Mesh);
  8629. _regenerateVertexData(): VertexData;
  8630. copy(id: string): Geometry;
  8631. }
  8632. class Plane extends _Primitive {
  8633. size: number;
  8634. side: number;
  8635. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8636. _regenerateVertexData(): VertexData;
  8637. copy(id: string): Geometry;
  8638. serialize(): any;
  8639. static Parse(parsedPlane: any, scene: Scene): Geometry.Primitives.Plane;
  8640. }
  8641. class TorusKnot extends _Primitive {
  8642. radius: number;
  8643. tube: number;
  8644. radialSegments: number;
  8645. tubularSegments: number;
  8646. p: number;
  8647. q: number;
  8648. side: number;
  8649. constructor(id: string, scene: Scene, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  8650. _regenerateVertexData(): VertexData;
  8651. copy(id: string): Geometry;
  8652. serialize(): any;
  8653. static Parse(parsedTorusKnot: any, scene: Scene): Geometry.Primitives.TorusKnot;
  8654. }
  8655. }
  8656. }
  8657. declare module BABYLON {
  8658. class GroundMesh extends Mesh {
  8659. generateOctree: boolean;
  8660. private _worldInverse;
  8661. private _heightQuads;
  8662. _subdivisions: number;
  8663. _width: number;
  8664. _height: number;
  8665. _minX: number;
  8666. _maxX: number;
  8667. _minZ: number;
  8668. _maxZ: number;
  8669. constructor(name: string, scene: Scene);
  8670. subdivisions: number;
  8671. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  8672. /**
  8673. * Returns a height (y) value in the Worl system :
  8674. * the ground altitude at the coordinates (x, z) expressed in the World system.
  8675. * Returns the ground y position if (x, z) are outside the ground surface.
  8676. * Not pertinent if the ground is rotated.
  8677. */
  8678. getHeightAtCoordinates(x: number, z: number): number;
  8679. /**
  8680. * Returns a normalized vector (Vector3) orthogonal to the ground
  8681. * at the ground coordinates (x, z) expressed in the World system.
  8682. * Returns Vector3(0, 1, 0) if (x, z) are outside the ground surface.
  8683. * Not pertinent if the ground is rotated.
  8684. */
  8685. getNormalAtCoordinates(x: number, z: number): Vector3;
  8686. /**
  8687. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  8688. * at the ground coordinates (x, z) expressed in the World system.
  8689. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  8690. * Not pertinent if the ground is rotated.
  8691. */
  8692. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): void;
  8693. /**
  8694. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  8695. * if the ground has been updated.
  8696. * This can be used in the render loop
  8697. */
  8698. updateCoordinateHeights(): void;
  8699. private _getFacetAt(x, z);
  8700. private _initHeightQuads();
  8701. private _computeHeightQuads();
  8702. }
  8703. }
  8704. declare module BABYLON {
  8705. /**
  8706. * Creates an instance based on a source mesh.
  8707. */
  8708. class InstancedMesh extends AbstractMesh {
  8709. private _sourceMesh;
  8710. private _currentLOD;
  8711. constructor(name: string, source: Mesh);
  8712. receiveShadows: boolean;
  8713. material: Material;
  8714. visibility: number;
  8715. skeleton: Skeleton;
  8716. renderingGroupId: number;
  8717. getTotalVertices(): number;
  8718. sourceMesh: Mesh;
  8719. getVerticesData(kind: string, copyWhenShared?: boolean): number[] | Float32Array;
  8720. isVerticesDataPresent(kind: string): boolean;
  8721. getIndices(): number[] | Int32Array;
  8722. _positions: Vector3[];
  8723. refreshBoundingInfo(): void;
  8724. _preActivate(): void;
  8725. _activate(renderId: number): void;
  8726. getLOD(camera: Camera): AbstractMesh;
  8727. _syncSubMeshes(): void;
  8728. _generatePointsArray(): boolean;
  8729. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  8730. dispose(doNotRecurse?: boolean): void;
  8731. }
  8732. }
  8733. declare module BABYLON {
  8734. class LinesMesh extends Mesh {
  8735. color: Color3;
  8736. alpha: number;
  8737. private _positionBuffer;
  8738. /**
  8739. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  8740. * This margin is expressed in world space coordinates, so its value may vary.
  8741. * Default value is 0.1
  8742. * @returns the intersection Threshold value.
  8743. */
  8744. /**
  8745. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  8746. * This margin is expressed in world space coordinates, so its value may vary.
  8747. * @param value the new threshold to apply
  8748. */
  8749. intersectionThreshold: number;
  8750. private _intersectionThreshold;
  8751. private _colorShader;
  8752. constructor(name: string, scene: Scene, parent?: Node, source?: LinesMesh, doNotCloneChildren?: boolean);
  8753. material: Material;
  8754. checkCollisions: boolean;
  8755. createInstance(name: string): InstancedMesh;
  8756. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  8757. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  8758. dispose(doNotRecurse?: boolean): void;
  8759. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  8760. }
  8761. }
  8762. declare module BABYLON {
  8763. class _InstancesBatch {
  8764. mustReturn: boolean;
  8765. visibleInstances: InstancedMesh[][];
  8766. renderSelf: boolean[];
  8767. }
  8768. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  8769. static _FRONTSIDE: number;
  8770. static _BACKSIDE: number;
  8771. static _DOUBLESIDE: number;
  8772. static _DEFAULTSIDE: number;
  8773. static _NO_CAP: number;
  8774. static _CAP_START: number;
  8775. static _CAP_END: number;
  8776. static _CAP_ALL: number;
  8777. /**
  8778. * Mesh side orientation : usually the external or front surface
  8779. */
  8780. static FRONTSIDE: number;
  8781. /**
  8782. * Mesh side orientation : usually the internal or back surface
  8783. */
  8784. static BACKSIDE: number;
  8785. /**
  8786. * Mesh side orientation : both internal and external or front and back surfaces
  8787. */
  8788. static DOUBLESIDE: number;
  8789. /**
  8790. * Mesh side orientation : by default, `FRONTSIDE`
  8791. */
  8792. static DEFAULTSIDE: number;
  8793. /**
  8794. * Mesh cap setting : no cap
  8795. */
  8796. static NO_CAP: number;
  8797. /**
  8798. * Mesh cap setting : one cap at the beginning of the mesh
  8799. */
  8800. static CAP_START: number;
  8801. /**
  8802. * Mesh cap setting : one cap at the end of the mesh
  8803. */
  8804. static CAP_END: number;
  8805. /**
  8806. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  8807. */
  8808. static CAP_ALL: number;
  8809. /**
  8810. * An event triggered before rendering the mesh
  8811. * @type {BABYLON.Observable}
  8812. */
  8813. onBeforeRenderObservable: Observable<Mesh>;
  8814. /**
  8815. * An event triggered after rendering the mesh
  8816. * @type {BABYLON.Observable}
  8817. */
  8818. onAfterRenderObservable: Observable<Mesh>;
  8819. /**
  8820. * An event triggered before drawing the mesh
  8821. * @type {BABYLON.Observable}
  8822. */
  8823. onBeforeDrawObservable: Observable<Mesh>;
  8824. private _onBeforeDrawObserver;
  8825. onBeforeDraw: () => void;
  8826. delayLoadState: number;
  8827. instances: InstancedMesh[];
  8828. delayLoadingFile: string;
  8829. _binaryInfo: any;
  8830. private _LODLevels;
  8831. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  8832. _geometry: Geometry;
  8833. _delayInfo: any;
  8834. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  8835. _visibleInstances: any;
  8836. private _renderIdForInstances;
  8837. private _batchCache;
  8838. private _instancesBufferSize;
  8839. private _instancesBuffer;
  8840. private _instancesData;
  8841. private _overridenInstanceCount;
  8842. _shouldGenerateFlatShading: boolean;
  8843. private _preActivateId;
  8844. private _sideOrientation;
  8845. private _areNormalsFrozen;
  8846. private _sourcePositions;
  8847. private _sourceNormals;
  8848. /**
  8849. * @constructor
  8850. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  8851. * @param {Scene} scene The scene to add this mesh to.
  8852. * @param {Node} parent The parent of this mesh, if it has one
  8853. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  8854. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  8855. * When false, achieved by calling a clone(), also passing False.
  8856. * This will make creation of children, recursive.
  8857. */
  8858. constructor(name: string, scene: Scene, parent?: Node, source?: Mesh, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  8859. /**
  8860. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  8861. */
  8862. toString(fullDetails?: boolean): string;
  8863. hasLODLevels: boolean;
  8864. private _sortLODLevels();
  8865. /**
  8866. * Add a mesh as LOD level triggered at the given distance.
  8867. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  8868. * @param {number} distance The distance from the center of the object to show this level
  8869. * @param {Mesh} mesh The mesh to be added as LOD level
  8870. * @return {Mesh} This mesh (for chaining)
  8871. */
  8872. addLODLevel(distance: number, mesh: Mesh): Mesh;
  8873. /**
  8874. * Returns the LOD level mesh at the passed distance or null if not found.
  8875. * It is related to the method `addLODLevel(distance, mesh)`.
  8876. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  8877. */
  8878. getLODLevelAtDistance(distance: number): Mesh;
  8879. /**
  8880. * Remove a mesh from the LOD array
  8881. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  8882. * @param {Mesh} mesh The mesh to be removed.
  8883. * @return {Mesh} This mesh (for chaining)
  8884. */
  8885. removeLODLevel(mesh: Mesh): Mesh;
  8886. /**
  8887. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  8888. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  8889. */
  8890. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  8891. /**
  8892. * Returns the mesh internal Geometry object.
  8893. */
  8894. geometry: Geometry;
  8895. /**
  8896. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  8897. */
  8898. getTotalVertices(): number;
  8899. /**
  8900. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  8901. * If `copywhenShared` is true (default false) and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  8902. * Returns null if the mesh has no geometry or no vertex buffer.
  8903. * Possible `kind` values :
  8904. * - BABYLON.VertexBuffer.PositionKind
  8905. * - BABYLON.VertexBuffer.UVKind
  8906. * - BABYLON.VertexBuffer.UV2Kind
  8907. * - BABYLON.VertexBuffer.UV3Kind
  8908. * - BABYLON.VertexBuffer.UV4Kind
  8909. * - BABYLON.VertexBuffer.UV5Kind
  8910. * - BABYLON.VertexBuffer.UV6Kind
  8911. * - BABYLON.VertexBuffer.ColorKind
  8912. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8913. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8914. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8915. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8916. */
  8917. getVerticesData(kind: string, copyWhenShared?: boolean): number[] | Float32Array;
  8918. /**
  8919. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  8920. * Returns `undefined` if the mesh has no geometry.
  8921. * Possible `kind` values :
  8922. * - BABYLON.VertexBuffer.PositionKind
  8923. * - BABYLON.VertexBuffer.UVKind
  8924. * - BABYLON.VertexBuffer.UV2Kind
  8925. * - BABYLON.VertexBuffer.UV3Kind
  8926. * - BABYLON.VertexBuffer.UV4Kind
  8927. * - BABYLON.VertexBuffer.UV5Kind
  8928. * - BABYLON.VertexBuffer.UV6Kind
  8929. * - BABYLON.VertexBuffer.ColorKind
  8930. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8931. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8932. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8933. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8934. */
  8935. getVertexBuffer(kind: any): VertexBuffer;
  8936. /**
  8937. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  8938. * Possible `kind` values :
  8939. * - BABYLON.VertexBuffer.PositionKind
  8940. * - BABYLON.VertexBuffer.UVKind
  8941. * - BABYLON.VertexBuffer.UV2Kind
  8942. * - BABYLON.VertexBuffer.UV3Kind
  8943. * - BABYLON.VertexBuffer.UV4Kind
  8944. * - BABYLON.VertexBuffer.UV5Kind
  8945. * - BABYLON.VertexBuffer.UV6Kind
  8946. * - BABYLON.VertexBuffer.ColorKind
  8947. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8948. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8949. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8950. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8951. */
  8952. isVerticesDataPresent(kind: string): boolean;
  8953. /**
  8954. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  8955. * Possible `kind` values :
  8956. * - BABYLON.VertexBuffer.PositionKind
  8957. * - BABYLON.VertexBuffer.UVKind
  8958. * - BABYLON.VertexBuffer.UV2Kind
  8959. * - BABYLON.VertexBuffer.UV3Kind
  8960. * - BABYLON.VertexBuffer.UV4Kind
  8961. * - BABYLON.VertexBuffer.UV5Kind
  8962. * - BABYLON.VertexBuffer.UV6Kind
  8963. * - BABYLON.VertexBuffer.ColorKind
  8964. * - BABYLON.VertexBuffer.MatricesIndicesKind
  8965. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  8966. * - BABYLON.VertexBuffer.MatricesWeightsKind
  8967. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  8968. */
  8969. getVerticesDataKinds(): string[];
  8970. /**
  8971. * Returns a positive integer : the total number of indices in this mesh geometry.
  8972. * Returns zero if the mesh has no geometry.
  8973. */
  8974. getTotalIndices(): number;
  8975. /**
  8976. * Returns an array of integers or a Int32Array populated with the mesh indices.
  8977. * If the parameter `copyWhenShared` is true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  8978. * Returns an empty array if the mesh has no geometry.
  8979. */
  8980. getIndices(copyWhenShared?: boolean): number[] | Int32Array;
  8981. isBlocked: boolean;
  8982. /**
  8983. * Boolean : true once the mesh is ready after all the delayed process (loading, etc) are complete.
  8984. */
  8985. isReady(): boolean;
  8986. /**
  8987. * Boolean : true if the mesh has been disposed.
  8988. */
  8989. isDisposed(): boolean;
  8990. /**
  8991. * Sets the mesh side orientation : BABYLON.Mesh.FRONTSIDE, BABYLON.Mesh.BACKSIDE, BABYLON.Mesh.DOUBLESIDE or BABYLON.Mesh.DEFAULTSIDE
  8992. * tuto : http://doc.babylonjs.com/tutorials/Discover_Basic_Elements#side-orientation
  8993. */
  8994. sideOrientation: number;
  8995. /**
  8996. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  8997. * This property is pertinent only for updatable parametric shapes.
  8998. */
  8999. areNormalsFrozen: boolean;
  9000. /**
  9001. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  9002. * It has no effect at all on other shapes.
  9003. * It prevents the mesh normals from being recomputed on next `positions` array update.
  9004. */
  9005. freezeNormals(): void;
  9006. /**
  9007. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  9008. * It has no effect at all on other shapes.
  9009. * It reactivates the mesh normals computation if it was previously frozen.
  9010. */
  9011. unfreezeNormals(): void;
  9012. /**
  9013. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  9014. */
  9015. overridenInstanceCount: number;
  9016. _preActivate(): void;
  9017. _preActivateForIntermediateRendering(renderId: number): void;
  9018. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): void;
  9019. /**
  9020. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  9021. * This means the mesh underlying bounding box and sphere are recomputed.
  9022. */
  9023. refreshBoundingInfo(): void;
  9024. _createGlobalSubMesh(): SubMesh;
  9025. subdivide(count: number): void;
  9026. /**
  9027. * Sets the vertex data of the mesh geometry for the requested `kind`.
  9028. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  9029. * The `data` are either a numeric array either a Float32Array.
  9030. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  9031. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  9032. * Note that a new underlying VertexBuffer object is created each call.
  9033. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  9034. *
  9035. * Possible `kind` values :
  9036. * - BABYLON.VertexBuffer.PositionKind
  9037. * - BABYLON.VertexBuffer.UVKind
  9038. * - BABYLON.VertexBuffer.UV2Kind
  9039. * - BABYLON.VertexBuffer.UV3Kind
  9040. * - BABYLON.VertexBuffer.UV4Kind
  9041. * - BABYLON.VertexBuffer.UV5Kind
  9042. * - BABYLON.VertexBuffer.UV6Kind
  9043. * - BABYLON.VertexBuffer.ColorKind
  9044. * - BABYLON.VertexBuffer.MatricesIndicesKind
  9045. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  9046. * - BABYLON.VertexBuffer.MatricesWeightsKind
  9047. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  9048. */
  9049. setVerticesData(kind: string, data: number[] | Float32Array, updatable?: boolean, stride?: number): void;
  9050. setVerticesBuffer(buffer: VertexBuffer): void;
  9051. /**
  9052. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  9053. * If the mesh has no geometry, it is simply returned as it is.
  9054. * The `data` are either a numeric array either a Float32Array.
  9055. * No new underlying VertexBuffer object is created.
  9056. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  9057. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  9058. *
  9059. * Possible `kind` values :
  9060. * - BABYLON.VertexBuffer.PositionKind
  9061. * - BABYLON.VertexBuffer.UVKind
  9062. * - BABYLON.VertexBuffer.UV2Kind
  9063. * - BABYLON.VertexBuffer.UV3Kind
  9064. * - BABYLON.VertexBuffer.UV4Kind
  9065. * - BABYLON.VertexBuffer.UV5Kind
  9066. * - BABYLON.VertexBuffer.UV6Kind
  9067. * - BABYLON.VertexBuffer.ColorKind
  9068. * - BABYLON.VertexBuffer.MatricesIndicesKind
  9069. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  9070. * - BABYLON.VertexBuffer.MatricesWeightsKind
  9071. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  9072. */
  9073. updateVerticesData(kind: string, data: number[] | Float32Array, updateExtends?: boolean, makeItUnique?: boolean): void;
  9074. /**
  9075. * Deprecated since BabylonJS v2.3
  9076. */
  9077. updateVerticesDataDirectly(kind: string, data: Float32Array, offset?: number, makeItUnique?: boolean): void;
  9078. /**
  9079. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  9080. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  9081. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  9082. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  9083. */
  9084. updateMeshPositions(positionFunction: any, computeNormals?: boolean): void;
  9085. makeGeometryUnique(): void;
  9086. /**
  9087. * Sets the mesh indices.
  9088. * Expects an array populated with integers or a Int32Array.
  9089. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  9090. * This method creates a new index buffer each call.
  9091. */
  9092. setIndices(indices: number[] | Int32Array, totalVertices?: number): void;
  9093. /**
  9094. * Invert the geometry to move from a right handed system to a left handed one.
  9095. */
  9096. toLeftHanded(): void;
  9097. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  9098. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  9099. /**
  9100. * Registers for this mesh a javascript function called just before the rendering process.
  9101. * This function is passed the current mesh and doesn't return anything.
  9102. */
  9103. registerBeforeRender(func: (mesh: AbstractMesh) => void): void;
  9104. /**
  9105. * Disposes a previously registered javascript function called before the rendering.
  9106. * This function is passed the current mesh and doesn't return anything.
  9107. */
  9108. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): void;
  9109. /**
  9110. * Registers for this mesh a javascript function called just after the rendering is complete.
  9111. * This function is passed the current mesh and doesn't return anything.
  9112. */
  9113. registerAfterRender(func: (mesh: AbstractMesh) => void): void;
  9114. /**
  9115. * Disposes a previously registered javascript function called after the rendering.
  9116. * This function is passed the current mesh and doesn't return anything.
  9117. */
  9118. unregisterAfterRender(func: (mesh: AbstractMesh) => void): void;
  9119. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  9120. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): void;
  9121. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): void;
  9122. /**
  9123. * Triggers the draw call for the mesh.
  9124. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  9125. */
  9126. render(subMesh: SubMesh, enableAlphaMode: boolean): void;
  9127. private _onBeforeDraw(isInstance, world, effectiveMaterial);
  9128. /**
  9129. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  9130. */
  9131. getEmittedParticleSystems(): ParticleSystem[];
  9132. /**
  9133. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  9134. */
  9135. getHierarchyEmittedParticleSystems(): ParticleSystem[];
  9136. _checkDelayState(): void;
  9137. private _queueLoad(mesh, scene);
  9138. /**
  9139. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  9140. */
  9141. isInFrustum(frustumPlanes: Plane[]): boolean;
  9142. /**
  9143. * Sets the mesh material by the material or multiMaterial `id` property.
  9144. * The material `id` is a string identifying the material or the multiMaterial.
  9145. * This method returns nothing.
  9146. */
  9147. setMaterialByID(id: string): void;
  9148. /**
  9149. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  9150. */
  9151. getAnimatables(): IAnimatable[];
  9152. /**
  9153. * Modifies the mesh geometry according to the passed transformation matrix.
  9154. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  9155. * The mesh normals are modified accordingly the same transformation.
  9156. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  9157. * Note that, under the hood, this method sets a new VertexBuffer each call.
  9158. */
  9159. bakeTransformIntoVertices(transform: Matrix): void;
  9160. /**
  9161. * Modifies the mesh geometry according to its own current World Matrix.
  9162. * The mesh World Matrix is then reset.
  9163. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  9164. * tuto : tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  9165. * Note that, under the hood, this method sets a new VertexBuffer each call.
  9166. */
  9167. bakeCurrentTransformIntoVertices(): void;
  9168. _resetPointsArrayCache(): void;
  9169. _generatePointsArray(): boolean;
  9170. /**
  9171. * Returns a new Mesh object generated from the current mesh properties.
  9172. * This method must not get confused with createInstance().
  9173. * The parameter `name` is a string, the name given to the new mesh.
  9174. * The optional parameter `newParent` can be any Node object (default `null`).
  9175. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  9176. * The parameter `clonePhysicsImpostor` (default `true`) allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any.
  9177. */
  9178. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  9179. /**
  9180. * Disposes the mesh.
  9181. * This also frees the memory allocated under the hood to all the buffers used by WebGL.
  9182. */
  9183. dispose(doNotRecurse?: boolean): void;
  9184. /**
  9185. * Modifies the mesh geometry according to a displacement map.
  9186. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  9187. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  9188. * This method returns nothing.
  9189. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  9190. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  9191. * The parameter `onSuccess` is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  9192. */
  9193. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void): void;
  9194. /**
  9195. * Modifies the mesh geometry according to a displacementMap buffer.
  9196. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  9197. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  9198. * This method returns nothing.
  9199. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  9200. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  9201. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  9202. */
  9203. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number): void;
  9204. /**
  9205. * Modify the mesh to get a flat shading rendering.
  9206. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  9207. * This method returns nothing.
  9208. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  9209. */
  9210. convertToFlatShadedMesh(): void;
  9211. /**
  9212. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  9213. * In other words, more vertices, no more indices and a single bigger VBO.
  9214. * This method returns nothing.
  9215. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  9216. *
  9217. */
  9218. convertToUnIndexedMesh(): void;
  9219. /**
  9220. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  9221. * This method returns nothing.
  9222. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  9223. */
  9224. flipFaces(flipNormals?: boolean): void;
  9225. /**
  9226. * Creates a new InstancedMesh object from the mesh model.
  9227. * An instance shares the same properties and the same material than its model.
  9228. * Only these properties of each instance can then be set individually :
  9229. * - position
  9230. * - rotation
  9231. * - rotationQuaternion
  9232. * - setPivotMatrix
  9233. * - scaling
  9234. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  9235. * Warning : this method is not supported for Line mesh and LineSystem
  9236. */
  9237. createInstance(name: string): InstancedMesh;
  9238. /**
  9239. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  9240. * After this call, all the mesh instances have the same submeshes than the current mesh.
  9241. * This method returns nothing.
  9242. */
  9243. synchronizeInstances(): void;
  9244. /**
  9245. * Simplify the mesh according to the given array of settings.
  9246. * Function will return immediately and will simplify async. It returns nothing.
  9247. * @param settings a collection of simplification settings.
  9248. * @param parallelProcessing should all levels calculate parallel or one after the other.
  9249. * @param type the type of simplification to run.
  9250. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  9251. */
  9252. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): void;
  9253. /**
  9254. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  9255. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  9256. * This should be used together with the simplification to avoid disappearing triangles.
  9257. * @param successCallback an optional success callback to be called after the optimization finished.
  9258. */
  9259. optimizeIndices(successCallback?: (mesh?: Mesh) => void): void;
  9260. /**
  9261. * Returns a new Mesh object what is a deep copy of the passed mesh.
  9262. * The parameter `parsedMesh` is the mesh to be copied.
  9263. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9264. */
  9265. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  9266. /**
  9267. * Creates a ribbon mesh.
  9268. * Please consider using the same method from the MeshBuilder class instead.
  9269. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9270. *
  9271. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  9272. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  9273. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  9274. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  9275. * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path.
  9276. * It's the offset to join together the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  9277. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  9278. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9279. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9280. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9281. */
  9282. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  9283. /**
  9284. * Creates a plane polygonal mesh. By default, this is a disc.
  9285. * Please consider using the same method from the MeshBuilder class instead.
  9286. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  9287. * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc.
  9288. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9289. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9290. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9291. */
  9292. static CreateDisc(name: string, radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  9293. /**
  9294. * Creates a box mesh.
  9295. * Please consider using the same method from the MeshBuilder class instead.
  9296. * The parameter `size` sets the size (float) of each box side (default 1).
  9297. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9298. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9299. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9300. */
  9301. static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  9302. /**
  9303. * Creates a sphere mesh.
  9304. * Please consider using the same method from the MeshBuilder class instead.
  9305. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  9306. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  9307. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9308. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9309. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9310. */
  9311. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  9312. /**
  9313. * Creates a cylinder or a cone mesh.
  9314. * Please consider using the same method from the MeshBuilder class instead.
  9315. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  9316. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  9317. * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  9318. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  9319. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  9320. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9321. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9322. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9323. */
  9324. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene: Scene, updatable?: any, sideOrientation?: number): Mesh;
  9325. /**
  9326. * Creates a torus mesh.
  9327. * Please consider using the same method from the MeshBuilder class instead.
  9328. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  9329. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  9330. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  9331. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9332. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9333. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9334. */
  9335. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  9336. /**
  9337. * Creates a torus knot mesh.
  9338. * Please consider using the same method from the MeshBuilder class instead.
  9339. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  9340. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  9341. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  9342. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  9343. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9344. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9345. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9346. */
  9347. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  9348. /**
  9349. * Creates a line mesh.
  9350. * Please consider using the same method from the MeshBuilder class instead.
  9351. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  9352. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  9353. * The parameter `points` is an array successive Vector3.
  9354. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  9355. * When updating an instance, remember that only point positions can change, not the number of points.
  9356. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9357. */
  9358. static CreateLines(name: string, points: Vector3[], scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  9359. /**
  9360. * Creates a dashed line mesh.
  9361. * Please consider using the same method from the MeshBuilder class instead.
  9362. * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  9363. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  9364. * The parameter `points` is an array successive Vector3.
  9365. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  9366. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  9367. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  9368. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  9369. * When updating an instance, remember that only point positions can change, not the number of points.
  9370. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9371. */
  9372. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene: Scene, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  9373. /**
  9374. * Creates an extruded shape mesh.
  9375. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9376. * Please consider using the same method from the MeshBuilder class instead.
  9377. *
  9378. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  9379. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  9380. * extruded along the Z axis.
  9381. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  9382. * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  9383. * The parameter `scale` (float, default 1) is the value to scale the shape.
  9384. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  9385. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  9386. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  9387. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9388. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9389. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9390. */
  9391. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  9392. /**
  9393. * Creates an custom extruded shape mesh.
  9394. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9395. * Please consider using the same method from the MeshBuilder class instead.
  9396. *
  9397. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  9398. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  9399. * extruded along the Z axis.
  9400. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  9401. * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  9402. * and the distance of this point from the begining of the path :
  9403. * ```javascript
  9404. * var rotationFunction = function(i, distance) {
  9405. * // do things
  9406. * return rotationValue; }
  9407. * ```
  9408. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  9409. * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  9410. * and the distance of this point from the begining of the path :
  9411. * ```javascript
  9412. * var scaleFunction = function(i, distance) {
  9413. * // do things
  9414. * return scaleValue;}
  9415. * ```
  9416. * It must returns a float value that will be the scale value applied to the shape on each path point.
  9417. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  9418. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  9419. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  9420. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  9421. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  9422. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9423. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9424. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9425. */
  9426. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  9427. /**
  9428. * Creates lathe mesh.
  9429. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  9430. * Please consider using the same method from the MeshBuilder class instead.
  9431. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be
  9432. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  9433. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  9434. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  9435. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9436. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9438. */
  9439. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  9440. /**
  9441. * Creates a plane mesh.
  9442. * Please consider using the same method from the MeshBuilder class instead.
  9443. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  9444. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9445. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9446. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9447. */
  9448. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  9449. /**
  9450. * Creates a ground mesh.
  9451. * Please consider using the same method from the MeshBuilder class instead.
  9452. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  9453. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  9454. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9455. */
  9456. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene: Scene, updatable?: boolean): Mesh;
  9457. /**
  9458. * Creates a tiled ground mesh.
  9459. * Please consider using the same method from the MeshBuilder class instead.
  9460. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  9461. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  9462. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  9463. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  9464. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  9465. * numbers of subdivisions on the ground width and height of each tile.
  9466. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9467. */
  9468. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  9469. w: number;
  9470. h: number;
  9471. }, precision: {
  9472. w: number;
  9473. h: number;
  9474. }, scene: Scene, updatable?: boolean): Mesh;
  9475. /**
  9476. * Creates a ground mesh from a height map.
  9477. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  9478. * Please consider using the same method from the MeshBuilder class instead.
  9479. * The parameter `url` sets the URL of the height map image resource.
  9480. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  9481. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  9482. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  9483. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  9484. * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  9485. * This function is passed the newly built mesh :
  9486. * ```javascript
  9487. * function(mesh) { // do things
  9488. * return; }
  9489. * ```
  9490. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9491. */
  9492. 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;
  9493. /**
  9494. * Creates a tube mesh.
  9495. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9496. * Please consider using the same method from the MeshBuilder class instead.
  9497. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  9498. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  9499. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  9500. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  9501. * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path.
  9502. * It must return a radius value (positive float) :
  9503. * ```javascript
  9504. * var radiusFunction = function(i, distance) {
  9505. * // do things
  9506. * return radius; }
  9507. * ```
  9508. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  9509. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  9510. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9511. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9512. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9513. */
  9514. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  9515. (i: number, distance: number): number;
  9516. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  9517. /**
  9518. * Creates a polyhedron mesh.
  9519. * Please consider using the same method from the MeshBuilder class instead.
  9520. * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial
  9521. * to choose the wanted type.
  9522. * The parameter `size` (positive float, default 1) sets the polygon size.
  9523. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  9524. * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`.
  9525. * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  9526. * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`).
  9527. * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  9528. * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored.
  9529. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9530. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9531. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9532. */
  9533. static CreatePolyhedron(name: string, options: {
  9534. type?: number;
  9535. size?: number;
  9536. sizeX?: number;
  9537. sizeY?: number;
  9538. sizeZ?: number;
  9539. custom?: any;
  9540. faceUV?: Vector4[];
  9541. faceColors?: Color4[];
  9542. updatable?: boolean;
  9543. sideOrientation?: number;
  9544. }, scene: Scene): Mesh;
  9545. /**
  9546. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  9547. * Please consider using the same method from the MeshBuilder class instead.
  9548. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  9549. * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`).
  9550. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  9551. * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface.
  9552. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9553. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9554. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9555. */
  9556. static CreateIcoSphere(name: string, options: {
  9557. radius?: number;
  9558. flat?: boolean;
  9559. subdivisions?: number;
  9560. sideOrientation?: number;
  9561. updatable?: boolean;
  9562. }, scene: Scene): Mesh;
  9563. /**
  9564. * Creates a decal mesh.
  9565. * Please consider using the same method from the MeshBuilder class instead.
  9566. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal.
  9567. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  9568. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  9569. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  9570. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  9571. */
  9572. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  9573. /**
  9574. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  9575. */
  9576. setPositionsForCPUSkinning(): Float32Array;
  9577. /**
  9578. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  9579. */
  9580. setNormalsForCPUSkinning(): Float32Array;
  9581. /**
  9582. * Update the vertex buffers by applying transformation from the bones
  9583. * @param {skeleton} skeleton to apply
  9584. */
  9585. applySkeleton(skeleton: Skeleton): Mesh;
  9586. /**
  9587. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  9588. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  9589. */
  9590. static MinMax(meshes: AbstractMesh[]): {
  9591. min: Vector3;
  9592. max: Vector3;
  9593. };
  9594. /**
  9595. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  9596. */
  9597. static Center(meshesOrMinMaxVector: any): Vector3;
  9598. /**
  9599. * Merge the array of meshes into a single mesh for performance reasons.
  9600. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  9601. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  9602. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  9603. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  9604. */
  9605. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh): Mesh;
  9606. }
  9607. }
  9608. declare module BABYLON {
  9609. interface IGetSetVerticesData {
  9610. isVerticesDataPresent(kind: string): boolean;
  9611. getVerticesData(kind: string, copyWhenShared?: boolean): number[] | Int32Array | Float32Array;
  9612. getIndices(copyWhenShared?: boolean): number[] | Int32Array;
  9613. setVerticesData(kind: string, data: number[] | Float32Array, updatable?: boolean): void;
  9614. updateVerticesData(kind: string, data: number[] | Float32Array, updateExtends?: boolean, makeItUnique?: boolean): void;
  9615. setIndices(indices: number[] | Int32Array): void;
  9616. }
  9617. class VertexData {
  9618. positions: number[] | Float32Array;
  9619. normals: number[] | Float32Array;
  9620. uvs: number[] | Float32Array;
  9621. uvs2: number[] | Float32Array;
  9622. uvs3: number[] | Float32Array;
  9623. uvs4: number[] | Float32Array;
  9624. uvs5: number[] | Float32Array;
  9625. uvs6: number[] | Float32Array;
  9626. colors: number[] | Float32Array;
  9627. matricesIndices: number[] | Float32Array;
  9628. matricesWeights: number[] | Float32Array;
  9629. matricesIndicesExtra: number[] | Float32Array;
  9630. matricesWeightsExtra: number[] | Float32Array;
  9631. indices: number[] | Int32Array;
  9632. set(data: number[] | Float32Array, kind: string): void;
  9633. applyToMesh(mesh: Mesh, updatable?: boolean): void;
  9634. applyToGeometry(geometry: Geometry, updatable?: boolean): void;
  9635. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): void;
  9636. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): void;
  9637. private _applyTo(meshOrGeometry, updatable?);
  9638. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  9639. transform(matrix: Matrix): void;
  9640. merge(other: VertexData): void;
  9641. private _mergeElement(source, other);
  9642. serialize(): any;
  9643. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean): VertexData;
  9644. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean): VertexData;
  9645. private static _ExtractFrom(meshOrGeometry, copyWhenShared?);
  9646. static CreateRibbon(options: {
  9647. pathArray: Vector3[][];
  9648. closeArray?: boolean;
  9649. closePath?: boolean;
  9650. offset?: number;
  9651. sideOrientation?: number;
  9652. invertUV?: boolean;
  9653. }): VertexData;
  9654. static CreateBox(options: {
  9655. size?: number;
  9656. width?: number;
  9657. height?: number;
  9658. depth?: number;
  9659. faceUV?: Vector4[];
  9660. faceColors?: Color4[];
  9661. sideOrientation?: number;
  9662. }): VertexData;
  9663. static CreateSphere(options: {
  9664. segments?: number;
  9665. diameter?: number;
  9666. diameterX?: number;
  9667. diameterY?: number;
  9668. diameterZ?: number;
  9669. arc?: number;
  9670. slice?: number;
  9671. sideOrientation?: number;
  9672. }): VertexData;
  9673. static CreateCylinder(options: {
  9674. height?: number;
  9675. diameterTop?: number;
  9676. diameterBottom?: number;
  9677. diameter?: number;
  9678. tessellation?: number;
  9679. subdivisions?: number;
  9680. arc?: number;
  9681. faceColors?: Color4[];
  9682. faceUV?: Vector4[];
  9683. hasRings?: boolean;
  9684. enclose?: boolean;
  9685. sideOrientation?: number;
  9686. }): VertexData;
  9687. static CreateTorus(options: {
  9688. diameter?: number;
  9689. thickness?: number;
  9690. tessellation?: number;
  9691. sideOrientation?: number;
  9692. }): VertexData;
  9693. static CreateLineSystem(options: {
  9694. lines: Vector3[][];
  9695. }): VertexData;
  9696. static CreateDashedLines(options: {
  9697. points: Vector3[];
  9698. dashSize?: number;
  9699. gapSize?: number;
  9700. dashNb?: number;
  9701. }): VertexData;
  9702. static CreateGround(options: {
  9703. width?: number;
  9704. height?: number;
  9705. subdivisions?: number;
  9706. }): VertexData;
  9707. static CreateTiledGround(options: {
  9708. xmin: number;
  9709. zmin: number;
  9710. xmax: number;
  9711. zmax: number;
  9712. subdivisions?: {
  9713. w: number;
  9714. h: number;
  9715. };
  9716. precision?: {
  9717. w: number;
  9718. h: number;
  9719. };
  9720. }): VertexData;
  9721. static CreateGroundFromHeightMap(options: {
  9722. width: number;
  9723. height: number;
  9724. subdivisions: number;
  9725. minHeight: number;
  9726. maxHeight: number;
  9727. buffer: Uint8Array;
  9728. bufferWidth: number;
  9729. bufferHeight: number;
  9730. }): VertexData;
  9731. static CreatePlane(options: {
  9732. size?: number;
  9733. width?: number;
  9734. height?: number;
  9735. sideOrientation?: number;
  9736. }): VertexData;
  9737. static CreateDisc(options: {
  9738. radius?: number;
  9739. tessellation?: number;
  9740. arc?: number;
  9741. sideOrientation?: number;
  9742. }): VertexData;
  9743. static CreateIcoSphere(options: {
  9744. radius?: number;
  9745. radiusX?: number;
  9746. radiusY?: number;
  9747. radiusZ?: number;
  9748. flat?: boolean;
  9749. subdivisions?: number;
  9750. sideOrientation?: number;
  9751. }): VertexData;
  9752. static CreatePolyhedron(options: {
  9753. type?: number;
  9754. size?: number;
  9755. sizeX?: number;
  9756. sizeY?: number;
  9757. sizeZ?: number;
  9758. custom?: any;
  9759. faceUV?: Vector4[];
  9760. faceColors?: Color4[];
  9761. flat?: boolean;
  9762. sideOrientation?: number;
  9763. }): VertexData;
  9764. static CreateTorusKnot(options: {
  9765. radius?: number;
  9766. tube?: number;
  9767. radialSegments?: number;
  9768. tubularSegments?: number;
  9769. p?: number;
  9770. q?: number;
  9771. sideOrientation?: number;
  9772. }): VertexData;
  9773. /**
  9774. * @param {any} - positions (number[] or Float32Array)
  9775. * @param {any} - indices (number[] or Uint16Array)
  9776. * @param {any} - normals (number[] or Float32Array)
  9777. */
  9778. static ComputeNormals(positions: any, indices: any, normals: any): void;
  9779. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs);
  9780. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  9781. }
  9782. }
  9783. declare module BABYLON {
  9784. class MeshBuilder {
  9785. /**
  9786. * Creates a box mesh.
  9787. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  9788. * The parameter `size` sets the size (float) of each box side (default 1).
  9789. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  9790. * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements).
  9791. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  9792. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9793. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9794. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9795. */
  9796. static CreateBox(name: string, options: {
  9797. size?: number;
  9798. width?: number;
  9799. height?: number;
  9800. depth?: number;
  9801. faceUV?: Vector4[];
  9802. faceColors?: Color4[];
  9803. sideOrientation?: number;
  9804. updatable?: boolean;
  9805. }, scene: Scene): Mesh;
  9806. /**
  9807. * Creates a sphere mesh.
  9808. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  9809. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  9810. * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value than `diameter`).
  9811. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  9812. * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  9813. * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude).
  9814. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9815. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9816. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9817. */
  9818. static CreateSphere(name: string, options: {
  9819. segments?: number;
  9820. diameter?: number;
  9821. diameterX?: number;
  9822. diameterY?: number;
  9823. diameterZ?: number;
  9824. arc?: number;
  9825. slice?: number;
  9826. sideOrientation?: number;
  9827. updatable?: boolean;
  9828. }, scene: any): Mesh;
  9829. /**
  9830. * Creates a plane polygonal mesh. By default, this is a disc.
  9831. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  9832. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  9833. * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc.
  9834. * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  9835. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9836. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9837. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9838. */
  9839. static CreateDisc(name: string, options: {
  9840. radius?: number;
  9841. tessellation?: number;
  9842. arc?: number;
  9843. updatable?: boolean;
  9844. sideOrientation?: number;
  9845. }, scene: Scene): Mesh;
  9846. /**
  9847. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  9848. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  9849. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  9850. * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`).
  9851. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  9852. * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface.
  9853. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9854. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9855. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9856. */
  9857. static CreateIcoSphere(name: string, options: {
  9858. radius?: number;
  9859. radiusX?: number;
  9860. radiusY?: number;
  9861. radiusZ?: number;
  9862. flat?: boolean;
  9863. subdivisions?: number;
  9864. sideOrientation?: number;
  9865. updatable?: boolean;
  9866. }, scene: Scene): Mesh;
  9867. /**
  9868. * Creates a ribbon mesh.
  9869. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  9870. *
  9871. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  9872. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  9873. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  9874. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  9875. * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path.
  9876. * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  9877. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  9878. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9879. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9880. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  9881. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9882. */
  9883. static CreateRibbon(name: string, options: {
  9884. pathArray: Vector3[][];
  9885. closeArray?: boolean;
  9886. closePath?: boolean;
  9887. offset?: number;
  9888. updatable?: boolean;
  9889. sideOrientation?: number;
  9890. instance?: Mesh;
  9891. invertUV?: boolean;
  9892. }, scene?: Scene): Mesh;
  9893. /**
  9894. * Creates a cylinder or a cone mesh.
  9895. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  9896. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  9897. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  9898. * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  9899. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  9900. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  9901. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  9902. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  9903. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  9904. * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  9905. * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  9906. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  9907. * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  9908. * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  9909. * If `enclose` is false, a ring surface is one element.
  9910. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  9911. * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  9912. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9913. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9914. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9915. */
  9916. static CreateCylinder(name: string, options: {
  9917. height?: number;
  9918. diameterTop?: number;
  9919. diameterBottom?: number;
  9920. diameter?: number;
  9921. tessellation?: number;
  9922. subdivisions?: number;
  9923. arc?: number;
  9924. faceColors?: Color4[];
  9925. faceUV?: Vector4[];
  9926. updatable?: boolean;
  9927. hasRings?: boolean;
  9928. enclose?: boolean;
  9929. sideOrientation?: number;
  9930. }, scene: any): Mesh;
  9931. /**
  9932. * Creates a torus mesh.
  9933. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  9934. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  9935. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  9936. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  9937. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9938. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9939. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9940. */
  9941. static CreateTorus(name: string, options: {
  9942. diameter?: number;
  9943. thickness?: number;
  9944. tessellation?: number;
  9945. updatable?: boolean;
  9946. sideOrientation?: number;
  9947. }, scene: any): Mesh;
  9948. /**
  9949. * Creates a torus knot mesh.
  9950. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  9951. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  9952. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  9953. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  9954. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  9955. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  9956. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  9957. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9958. */
  9959. static CreateTorusKnot(name: string, options: {
  9960. radius?: number;
  9961. tube?: number;
  9962. radialSegments?: number;
  9963. tubularSegments?: number;
  9964. p?: number;
  9965. q?: number;
  9966. updatable?: boolean;
  9967. sideOrientation?: number;
  9968. }, scene: any): Mesh;
  9969. /**
  9970. * Creates a line system mesh.
  9971. * A line system is a pool of many lines gathered in a single mesh.
  9972. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  9973. * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter.
  9974. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  9975. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  9976. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  9977. * updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  9978. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  9979. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9980. */
  9981. static CreateLineSystem(name: string, options: {
  9982. lines: Vector3[][];
  9983. updatable: boolean;
  9984. instance?: LinesMesh;
  9985. }, scene: Scene): LinesMesh;
  9986. /**
  9987. * Creates a line mesh.
  9988. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  9989. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  9990. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  9991. * The parameter `points` is an array successive Vector3.
  9992. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  9993. * When updating an instance, remember that only point positions can change, not the number of points.
  9994. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  9995. */
  9996. static CreateLines(name: string, options: {
  9997. points: Vector3[];
  9998. updatable?: boolean;
  9999. instance?: LinesMesh;
  10000. }, scene: Scene): LinesMesh;
  10001. /**
  10002. * Creates a dashed line mesh.
  10003. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  10004. * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter.
  10005. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  10006. * The parameter `points` is an array successive Vector3.
  10007. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  10008. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  10009. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  10010. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  10011. * When updating an instance, remember that only point positions can change, not the number of points.
  10012. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10013. */
  10014. static CreateDashedLines(name: string, options: {
  10015. points: Vector3[];
  10016. dashSize?: number;
  10017. gapSize?: number;
  10018. dashNb?: number;
  10019. updatable?: boolean;
  10020. instance?: LinesMesh;
  10021. }, scene: Scene): LinesMesh;
  10022. /**
  10023. * Creates an extruded shape mesh.
  10024. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  10025. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  10026. *
  10027. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  10028. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  10029. * extruded along the Z axis.
  10030. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  10031. * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  10032. * The parameter `scale` (float, default 1) is the value to scale the shape.
  10033. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  10034. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  10035. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  10036. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10037. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10038. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  10039. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10040. */
  10041. static ExtrudeShape(name: string, options: {
  10042. shape: Vector3[];
  10043. path: Vector3[];
  10044. scale?: number;
  10045. rotation?: number;
  10046. cap?: number;
  10047. updatable?: boolean;
  10048. sideOrientation?: number;
  10049. instance?: Mesh;
  10050. invertUV?: boolean;
  10051. }, scene: Scene): Mesh;
  10052. /**
  10053. * Creates an custom extruded shape mesh.
  10054. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  10055. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  10056. *
  10057. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  10058. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be
  10059. * extruded along the Z axis.
  10060. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  10061. * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  10062. * and the distance of this point from the begining of the path :
  10063. * ```javascript
  10064. * var rotationFunction = function(i, distance) {
  10065. * // do things
  10066. * return rotationValue; }
  10067. * ```
  10068. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  10069. * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path
  10070. * and the distance of this point from the begining of the path :
  10071. * ```javascript
  10072. * var scaleFunction = function(i, distance) {
  10073. * // do things
  10074. * return scaleValue;}
  10075. * ```
  10076. * It must returns a float value that will be the scale value applied to the shape on each path point.
  10077. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  10078. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  10079. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  10080. * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  10081. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  10082. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10083. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10084. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  10085. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10086. */
  10087. static ExtrudeShapeCustom(name: string, options: {
  10088. shape: Vector3[];
  10089. path: Vector3[];
  10090. scaleFunction?: any;
  10091. rotationFunction?: any;
  10092. ribbonCloseArray?: boolean;
  10093. ribbonClosePath?: boolean;
  10094. cap?: number;
  10095. updatable?: boolean;
  10096. sideOrientation?: number;
  10097. instance?: Mesh;
  10098. invertUV?: boolean;
  10099. }, scene: Scene): Mesh;
  10100. /**
  10101. * Creates lathe mesh.
  10102. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  10103. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  10104. *
  10105. * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be
  10106. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  10107. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  10108. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  10109. * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape.
  10110. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  10111. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  10112. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10113. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10114. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  10115. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10116. */
  10117. static CreateLathe(name: string, options: {
  10118. shape: Vector3[];
  10119. radius?: number;
  10120. tessellation?: number;
  10121. arc?: number;
  10122. closed?: boolean;
  10123. updatable?: boolean;
  10124. sideOrientation?: number;
  10125. cap?: number;
  10126. invertUV?: boolean;
  10127. }, scene: Scene): Mesh;
  10128. /**
  10129. * Creates a plane mesh.
  10130. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  10131. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  10132. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  10133. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  10134. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10135. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10136. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10137. */
  10138. static CreatePlane(name: string, options: {
  10139. size?: number;
  10140. width?: number;
  10141. height?: number;
  10142. sideOrientation?: number;
  10143. updatable?: boolean;
  10144. sourcePlane?: Plane;
  10145. }, scene: Scene): Mesh;
  10146. /**
  10147. * Creates a ground mesh.
  10148. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  10149. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  10150. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  10151. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10152. */
  10153. static CreateGround(name: string, options: {
  10154. width?: number;
  10155. height?: number;
  10156. subdivisions?: number;
  10157. updatable?: boolean;
  10158. }, scene: any): Mesh;
  10159. /**
  10160. * Creates a tiled ground mesh.
  10161. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  10162. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  10163. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  10164. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  10165. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  10166. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  10167. * numbers of subdivisions on the ground width and height of each tile.
  10168. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10169. */
  10170. static CreateTiledGround(name: string, options: {
  10171. xmin: number;
  10172. zmin: number;
  10173. xmax: number;
  10174. zmax: number;
  10175. subdivisions?: {
  10176. w: number;
  10177. h: number;
  10178. };
  10179. precision?: {
  10180. w: number;
  10181. h: number;
  10182. };
  10183. updatable?: boolean;
  10184. }, scene: Scene): Mesh;
  10185. /**
  10186. * Creates a ground mesh from a height map.
  10187. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  10188. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  10189. * The parameter `url` sets the URL of the height map image resource.
  10190. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  10191. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  10192. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  10193. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  10194. * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  10195. * This function is passed the newly built mesh :
  10196. * ```javascript
  10197. * function(mesh) { // do things
  10198. * return; }
  10199. * ```
  10200. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10201. */
  10202. static CreateGroundFromHeightMap(name: string, url: string, options: {
  10203. width?: number;
  10204. height?: number;
  10205. subdivisions?: number;
  10206. minHeight?: number;
  10207. maxHeight?: number;
  10208. updatable?: boolean;
  10209. onReady?: (mesh: GroundMesh) => void;
  10210. }, scene: Scene): GroundMesh;
  10211. /**
  10212. * Creates a tube mesh.
  10213. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  10214. *
  10215. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  10216. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  10217. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  10218. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  10219. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  10220. * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path.
  10221. * It must return a radius value (positive float) :
  10222. * ```javascript
  10223. * var radiusFunction = function(i, distance) {
  10224. * // do things
  10225. * return radius; }
  10226. * ```
  10227. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  10228. * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  10229. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  10230. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10231. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10232. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  10233. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10234. */
  10235. static CreateTube(name: string, options: {
  10236. path: Vector3[];
  10237. radius?: number;
  10238. tessellation?: number;
  10239. radiusFunction?: {
  10240. (i: number, distance: number): number;
  10241. };
  10242. cap?: number;
  10243. arc?: number;
  10244. updatable?: boolean;
  10245. sideOrientation?: number;
  10246. instance?: Mesh;
  10247. invertUV?: boolean;
  10248. }, scene: Scene): Mesh;
  10249. /**
  10250. * Creates a polyhedron mesh.
  10251. *
  10252. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  10253. * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial
  10254. * to choose the wanted type.
  10255. * The parameter `size` (positive float, default 1) sets the polygon size.
  10256. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  10257. * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`.
  10258. * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  10259. * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`).
  10260. * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  10261. * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored.
  10262. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  10263. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  10264. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  10265. */
  10266. static CreatePolyhedron(name: string, options: {
  10267. type?: number;
  10268. size?: number;
  10269. sizeX?: number;
  10270. sizeY?: number;
  10271. sizeZ?: number;
  10272. custom?: any;
  10273. faceUV?: Vector4[];
  10274. faceColors?: Color4[];
  10275. flat?: boolean;
  10276. updatable?: boolean;
  10277. sideOrientation?: number;
  10278. }, scene: Scene): Mesh;
  10279. /**
  10280. * Creates a decal mesh.
  10281. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  10282. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal.
  10283. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  10284. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  10285. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  10286. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  10287. */
  10288. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  10289. position?: Vector3;
  10290. normal?: Vector3;
  10291. size?: Vector3;
  10292. angle?: number;
  10293. }): Mesh;
  10294. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV);
  10295. }
  10296. }
  10297. declare module BABYLON.Internals {
  10298. class MeshLODLevel {
  10299. distance: number;
  10300. mesh: Mesh;
  10301. constructor(distance: number, mesh: Mesh);
  10302. }
  10303. }
  10304. declare module BABYLON {
  10305. /**
  10306. * A simplifier interface for future simplification implementations.
  10307. */
  10308. interface ISimplifier {
  10309. /**
  10310. * Simplification of a given mesh according to the given settings.
  10311. * Since this requires computation, it is assumed that the function runs async.
  10312. * @param settings The settings of the simplification, including quality and distance
  10313. * @param successCallback A callback that will be called after the mesh was simplified.
  10314. * @param errorCallback in case of an error, this callback will be called. optional.
  10315. */
  10316. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  10317. }
  10318. /**
  10319. * Expected simplification settings.
  10320. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  10321. */
  10322. interface ISimplificationSettings {
  10323. quality: number;
  10324. distance: number;
  10325. optimizeMesh?: boolean;
  10326. }
  10327. class SimplificationSettings implements ISimplificationSettings {
  10328. quality: number;
  10329. distance: number;
  10330. optimizeMesh: boolean;
  10331. constructor(quality: number, distance: number, optimizeMesh?: boolean);
  10332. }
  10333. interface ISimplificationTask {
  10334. settings: Array<ISimplificationSettings>;
  10335. simplificationType: SimplificationType;
  10336. mesh: Mesh;
  10337. successCallback?: () => void;
  10338. parallelProcessing: boolean;
  10339. }
  10340. class SimplificationQueue {
  10341. private _simplificationArray;
  10342. running: any;
  10343. constructor();
  10344. addTask(task: ISimplificationTask): void;
  10345. executeNext(): void;
  10346. runSimplification(task: ISimplificationTask): void;
  10347. private getSimplifier(task);
  10348. }
  10349. /**
  10350. * The implemented types of simplification.
  10351. * At the moment only Quadratic Error Decimation is implemented.
  10352. */
  10353. enum SimplificationType {
  10354. QUADRATIC = 0,
  10355. }
  10356. class DecimationTriangle {
  10357. vertices: Array<DecimationVertex>;
  10358. normal: Vector3;
  10359. error: Array<number>;
  10360. deleted: boolean;
  10361. isDirty: boolean;
  10362. borderFactor: number;
  10363. deletePending: boolean;
  10364. originalOffset: number;
  10365. constructor(vertices: Array<DecimationVertex>);
  10366. }
  10367. class DecimationVertex {
  10368. position: Vector3;
  10369. id: any;
  10370. q: QuadraticMatrix;
  10371. isBorder: boolean;
  10372. triangleStart: number;
  10373. triangleCount: number;
  10374. originalOffsets: Array<number>;
  10375. constructor(position: Vector3, id: any);
  10376. updatePosition(newPosition: Vector3): void;
  10377. }
  10378. class QuadraticMatrix {
  10379. data: Array<number>;
  10380. constructor(data?: Array<number>);
  10381. det(a11: any, a12: any, a13: any, a21: any, a22: any, a23: any, a31: any, a32: any, a33: any): number;
  10382. addInPlace(matrix: QuadraticMatrix): void;
  10383. addArrayInPlace(data: Array<number>): void;
  10384. add(matrix: QuadraticMatrix): QuadraticMatrix;
  10385. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  10386. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  10387. }
  10388. class Reference {
  10389. vertexId: number;
  10390. triangleId: number;
  10391. constructor(vertexId: number, triangleId: number);
  10392. }
  10393. /**
  10394. * An implementation of the Quadratic Error simplification algorithm.
  10395. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  10396. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  10397. * @author RaananW
  10398. */
  10399. class QuadraticErrorSimplification implements ISimplifier {
  10400. private _mesh;
  10401. private triangles;
  10402. private vertices;
  10403. private references;
  10404. private initialized;
  10405. private _reconstructedMesh;
  10406. syncIterations: number;
  10407. aggressiveness: number;
  10408. decimationIterations: number;
  10409. boundingBoxEpsilon: number;
  10410. constructor(_mesh: Mesh);
  10411. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  10412. private isTriangleOnBoundingBox(triangle);
  10413. private runDecimation(settings, submeshIndex, successCallback);
  10414. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  10415. private init(callback);
  10416. private reconstructMesh(submeshIndex);
  10417. private initDecimatedMesh();
  10418. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  10419. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  10420. private identifyBorder();
  10421. private updateMesh(identifyBorders?);
  10422. private vertexError(q, point);
  10423. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  10424. }
  10425. }
  10426. declare module BABYLON {
  10427. class Polygon {
  10428. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  10429. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  10430. static Parse(input: string): Vector2[];
  10431. static StartingAt(x: number, y: number): Path2;
  10432. }
  10433. class PolygonMeshBuilder {
  10434. private _points;
  10435. private _outlinepoints;
  10436. private _holes;
  10437. private _name;
  10438. private _scene;
  10439. private _epoints;
  10440. private _eholes;
  10441. private _addToepoint(points);
  10442. constructor(name: string, contours: Path2, scene: Scene);
  10443. constructor(name: string, contours: Vector2[], scene: Scene);
  10444. addHole(hole: Vector2[]): PolygonMeshBuilder;
  10445. build(updatable?: boolean, depth?: number): Mesh;
  10446. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  10447. }
  10448. }
  10449. declare module BABYLON {
  10450. class SubMesh implements ICullable {
  10451. materialIndex: number;
  10452. verticesStart: number;
  10453. verticesCount: number;
  10454. indexStart: any;
  10455. indexCount: number;
  10456. linesIndexCount: number;
  10457. private _mesh;
  10458. private _renderingMesh;
  10459. private _boundingInfo;
  10460. private _linesIndexBuffer;
  10461. _lastColliderWorldVertices: Vector3[];
  10462. _trianglePlanes: Plane[];
  10463. _lastColliderTransformMatrix: Matrix;
  10464. _renderId: number;
  10465. _alphaIndex: number;
  10466. _distanceToCamera: number;
  10467. _id: number;
  10468. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: any, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  10469. IsGlobal: boolean;
  10470. getBoundingInfo(): BoundingInfo;
  10471. getMesh(): AbstractMesh;
  10472. getRenderingMesh(): Mesh;
  10473. getMaterial(): Material;
  10474. refreshBoundingInfo(): void;
  10475. _checkCollision(collider: Collider): boolean;
  10476. updateBoundingInfo(world: Matrix): void;
  10477. isInFrustum(frustumPlanes: Plane[]): boolean;
  10478. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  10479. render(enableAlphaMode: boolean): void;
  10480. getLinesIndexBuffer(indices: number[] | Int32Array, engine: Engine): WebGLBuffer;
  10481. canIntersects(ray: Ray): boolean;
  10482. intersects(ray: Ray, positions: Vector3[], indices: number[] | Int32Array, fastCheck?: boolean): IntersectionInfo;
  10483. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  10484. dispose(): void;
  10485. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  10486. }
  10487. }
  10488. declare module BABYLON {
  10489. class VertexBuffer {
  10490. private _buffer;
  10491. private _kind;
  10492. private _offset;
  10493. private _size;
  10494. private _stride;
  10495. private _ownsBuffer;
  10496. constructor(engine: any, data: number[] | Float32Array | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  10497. getKind(): string;
  10498. isUpdatable(): boolean;
  10499. getData(): number[] | Float32Array;
  10500. getBuffer(): WebGLBuffer;
  10501. getStrideSize(): number;
  10502. getOffset(): number;
  10503. getSize(): number;
  10504. getIsInstanced(): boolean;
  10505. create(data?: number[] | Float32Array): void;
  10506. update(data: number[] | Float32Array): void;
  10507. updateDirectly(data: Float32Array, offset: number): void;
  10508. dispose(): void;
  10509. private static _PositionKind;
  10510. private static _NormalKind;
  10511. private static _UVKind;
  10512. private static _UV2Kind;
  10513. private static _UV3Kind;
  10514. private static _UV4Kind;
  10515. private static _UV5Kind;
  10516. private static _UV6Kind;
  10517. private static _ColorKind;
  10518. private static _MatricesIndicesKind;
  10519. private static _MatricesWeightsKind;
  10520. private static _MatricesIndicesExtraKind;
  10521. private static _MatricesWeightsExtraKind;
  10522. static PositionKind: string;
  10523. static NormalKind: string;
  10524. static UVKind: string;
  10525. static UV2Kind: string;
  10526. static UV3Kind: string;
  10527. static UV4Kind: string;
  10528. static UV5Kind: string;
  10529. static UV6Kind: string;
  10530. static ColorKind: string;
  10531. static MatricesIndicesKind: string;
  10532. static MatricesWeightsKind: string;
  10533. static MatricesIndicesExtraKind: string;
  10534. static MatricesWeightsExtraKind: string;
  10535. }
  10536. }
  10537. declare module BABYLON {
  10538. class ReflectionProbe {
  10539. name: string;
  10540. private _scene;
  10541. private _renderTargetTexture;
  10542. private _projectionMatrix;
  10543. private _viewMatrix;
  10544. private _target;
  10545. private _add;
  10546. private _attachedMesh;
  10547. invertYAxis: boolean;
  10548. position: Vector3;
  10549. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  10550. refreshRate: number;
  10551. getScene(): Scene;
  10552. cubeTexture: RenderTargetTexture;
  10553. renderList: AbstractMesh[];
  10554. attachToMesh(mesh: AbstractMesh): void;
  10555. dispose(): void;
  10556. }
  10557. }
  10558. declare module BABYLON {
  10559. class AnaglyphPostProcess extends PostProcess {
  10560. private _passedProcess;
  10561. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  10562. }
  10563. }
  10564. declare module BABYLON {
  10565. class BlackAndWhitePostProcess extends PostProcess {
  10566. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10567. }
  10568. }
  10569. declare module BABYLON {
  10570. class BlurPostProcess extends PostProcess {
  10571. direction: Vector2;
  10572. blurWidth: number;
  10573. constructor(name: string, direction: Vector2, blurWidth: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10574. }
  10575. }
  10576. declare module BABYLON {
  10577. class ColorCorrectionPostProcess extends PostProcess {
  10578. private _colorTableTexture;
  10579. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10580. }
  10581. }
  10582. declare module BABYLON {
  10583. class ConvolutionPostProcess extends PostProcess {
  10584. kernel: number[];
  10585. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10586. static EdgeDetect0Kernel: number[];
  10587. static EdgeDetect1Kernel: number[];
  10588. static EdgeDetect2Kernel: number[];
  10589. static SharpenKernel: number[];
  10590. static EmbossKernel: number[];
  10591. static GaussianKernel: number[];
  10592. }
  10593. }
  10594. declare module BABYLON {
  10595. class DisplayPassPostProcess extends PostProcess {
  10596. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10597. }
  10598. }
  10599. declare module BABYLON {
  10600. class FilterPostProcess extends PostProcess {
  10601. kernelMatrix: Matrix;
  10602. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10603. }
  10604. }
  10605. declare module BABYLON {
  10606. class FxaaPostProcess extends PostProcess {
  10607. texelWidth: number;
  10608. texelHeight: number;
  10609. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10610. }
  10611. }
  10612. declare module BABYLON {
  10613. class HDRRenderingPipeline extends PostProcessRenderPipeline implements IDisposable {
  10614. /**
  10615. * Public members
  10616. */
  10617. /**
  10618. * Gaussian blur coefficient
  10619. * @type {number}
  10620. */
  10621. gaussCoeff: number;
  10622. /**
  10623. * Gaussian blur mean
  10624. * @type {number}
  10625. */
  10626. gaussMean: number;
  10627. /**
  10628. * Gaussian blur standard deviation
  10629. * @type {number}
  10630. */
  10631. gaussStandDev: number;
  10632. /**
  10633. * Gaussian blur multiplier. Multiplies the blur effect
  10634. * @type {number}
  10635. */
  10636. gaussMultiplier: number;
  10637. /**
  10638. * Exposure, controls the overall intensity of the pipeline
  10639. * @type {number}
  10640. */
  10641. exposure: number;
  10642. /**
  10643. * Minimum luminance that the post-process can output. Luminance is >= 0
  10644. * @type {number}
  10645. */
  10646. minimumLuminance: number;
  10647. /**
  10648. * Maximum luminance that the post-process can output. Must be suprerior to minimumLuminance
  10649. * @type {number}
  10650. */
  10651. maximumLuminance: number;
  10652. /**
  10653. * Increase rate for luminance: eye adaptation speed to dark
  10654. * @type {number}
  10655. */
  10656. luminanceIncreaserate: number;
  10657. /**
  10658. * Decrease rate for luminance: eye adaptation speed to bright
  10659. * @type {number}
  10660. */
  10661. luminanceDecreaseRate: number;
  10662. /**
  10663. * Minimum luminance needed to compute HDR
  10664. * @type {number}
  10665. */
  10666. brightThreshold: number;
  10667. /**
  10668. * Private members
  10669. */
  10670. private _guassianBlurHPostProcess;
  10671. private _guassianBlurVPostProcess;
  10672. private _brightPassPostProcess;
  10673. private _textureAdderPostProcess;
  10674. private _downSampleX4PostProcess;
  10675. private _originalPostProcess;
  10676. private _hdrPostProcess;
  10677. private _hdrCurrentLuminance;
  10678. private _hdrOutputLuminance;
  10679. static LUM_STEPS: number;
  10680. private _downSamplePostProcesses;
  10681. private _scene;
  10682. private _needUpdate;
  10683. /**
  10684. * @constructor
  10685. * @param {string} name - The rendering pipeline name
  10686. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  10687. * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  10688. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  10689. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  10690. */
  10691. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: PostProcess, cameras?: Camera[]);
  10692. /**
  10693. * Tells the pipeline to update its post-processes
  10694. */
  10695. update(): void;
  10696. /**
  10697. * Returns the current calculated luminance
  10698. */
  10699. getCurrentLuminance(): number;
  10700. /**
  10701. * Returns the currently drawn luminance
  10702. */
  10703. getOutputLuminance(): number;
  10704. /**
  10705. * Releases the rendering pipeline and its internal effects. Detaches pipeline from cameras
  10706. */
  10707. dispose(): void;
  10708. /**
  10709. * Creates the HDR post-process and computes the luminance adaptation
  10710. */
  10711. private _createHDRPostProcess(scene, ratio);
  10712. /**
  10713. * Texture Adder post-process
  10714. */
  10715. private _createTextureAdderPostProcess(scene, ratio);
  10716. /**
  10717. * Down sample X4 post-process
  10718. */
  10719. private _createDownSampleX4PostProcess(scene, ratio);
  10720. /**
  10721. * Bright pass post-process
  10722. */
  10723. private _createBrightPassPostProcess(scene, ratio);
  10724. /**
  10725. * Luminance generator. Creates the luminance post-process and down sample post-processes
  10726. */
  10727. private _createLuminanceGeneratorPostProcess(scene);
  10728. /**
  10729. * Gaussian blur post-processes. Horizontal and Vertical
  10730. */
  10731. private _createGaussianBlurPostProcess(scene, ratio);
  10732. }
  10733. }
  10734. declare module BABYLON {
  10735. class LensRenderingPipeline extends PostProcessRenderPipeline {
  10736. /**
  10737. * The chromatic aberration PostProcess id in the pipeline
  10738. * @type {string}
  10739. */
  10740. LensChromaticAberrationEffect: string;
  10741. /**
  10742. * The highlights enhancing PostProcess id in the pipeline
  10743. * @type {string}
  10744. */
  10745. HighlightsEnhancingEffect: string;
  10746. /**
  10747. * The depth-of-field PostProcess id in the pipeline
  10748. * @type {string}
  10749. */
  10750. LensDepthOfFieldEffect: string;
  10751. private _scene;
  10752. private _depthTexture;
  10753. private _grainTexture;
  10754. private _chromaticAberrationPostProcess;
  10755. private _highlightsPostProcess;
  10756. private _depthOfFieldPostProcess;
  10757. private _edgeBlur;
  10758. private _grainAmount;
  10759. private _chromaticAberration;
  10760. private _distortion;
  10761. private _highlightsGain;
  10762. private _highlightsThreshold;
  10763. private _dofDistance;
  10764. private _dofAperture;
  10765. private _dofDarken;
  10766. private _dofPentagon;
  10767. private _blurNoise;
  10768. /**
  10769. * @constructor
  10770. *
  10771. * Effect parameters are as follow:
  10772. * {
  10773. * chromatic_aberration: number; // from 0 to x (1 for realism)
  10774. * edge_blur: number; // from 0 to x (1 for realism)
  10775. * distortion: number; // from 0 to x (1 for realism)
  10776. * grain_amount: number; // from 0 to 1
  10777. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  10778. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  10779. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  10780. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  10781. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  10782. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  10783. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  10784. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  10785. * }
  10786. * Note: if an effect parameter is unset, effect is disabled
  10787. *
  10788. * @param {string} name - The rendering pipeline name
  10789. * @param {object} parameters - An object containing all parameters (see above)
  10790. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  10791. * @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)
  10792. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  10793. */
  10794. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  10795. setEdgeBlur(amount: number): void;
  10796. disableEdgeBlur(): void;
  10797. setGrainAmount(amount: number): void;
  10798. disableGrain(): void;
  10799. setChromaticAberration(amount: number): void;
  10800. disableChromaticAberration(): void;
  10801. setEdgeDistortion(amount: number): void;
  10802. disableEdgeDistortion(): void;
  10803. setFocusDistance(amount: number): void;
  10804. disableDepthOfField(): void;
  10805. setAperture(amount: number): void;
  10806. setDarkenOutOfFocus(amount: number): void;
  10807. enablePentagonBokeh(): void;
  10808. disablePentagonBokeh(): void;
  10809. enableNoiseBlur(): void;
  10810. disableNoiseBlur(): void;
  10811. setHighlightsGain(amount: number): void;
  10812. setHighlightsThreshold(amount: number): void;
  10813. disableHighlights(): void;
  10814. /**
  10815. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  10816. */
  10817. dispose(disableDepthRender?: boolean): void;
  10818. private _createChromaticAberrationPostProcess(ratio);
  10819. private _createHighlightsPostProcess(ratio);
  10820. private _createDepthOfFieldPostProcess(ratio);
  10821. private _createGrainTexture();
  10822. }
  10823. }
  10824. declare module BABYLON {
  10825. class PassPostProcess extends PostProcess {
  10826. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10827. }
  10828. }
  10829. declare module BABYLON {
  10830. type PostProcessOptions = {
  10831. width: number;
  10832. height: number;
  10833. };
  10834. class PostProcess {
  10835. name: string;
  10836. width: number;
  10837. height: number;
  10838. renderTargetSamplingMode: number;
  10839. clearColor: Color4;
  10840. enablePixelPerfectMode: boolean;
  10841. private _camera;
  10842. private _scene;
  10843. private _engine;
  10844. private _options;
  10845. private _reusable;
  10846. private _textureType;
  10847. _textures: SmartArray<WebGLTexture>;
  10848. _currentRenderTextureInd: number;
  10849. private _effect;
  10850. private _samplers;
  10851. private _fragmentUrl;
  10852. private _parameters;
  10853. private _scaleRatio;
  10854. /**
  10855. * An event triggered when the postprocess is activated.
  10856. * @type {BABYLON.Observable}
  10857. */
  10858. onActivateObservable: Observable<Camera>;
  10859. private _onActivateObserver;
  10860. onActivate: (camera: Camera) => void;
  10861. /**
  10862. * An event triggered when the postprocess changes its size.
  10863. * @type {BABYLON.Observable}
  10864. */
  10865. onSizeChangedObservable: Observable<PostProcess>;
  10866. private _onSizeChangedObserver;
  10867. onSizeChanged: (postProcess: PostProcess) => void;
  10868. /**
  10869. * An event triggered when the postprocess applies its effect.
  10870. * @type {BABYLON.Observable}
  10871. */
  10872. onApplyObservable: Observable<Effect>;
  10873. private _onApplyObserver;
  10874. onApply: (effect: Effect) => void;
  10875. /**
  10876. * An event triggered before rendering the postprocess
  10877. * @type {BABYLON.Observable}
  10878. */
  10879. onBeforeRenderObservable: Observable<Effect>;
  10880. private _onBeforeRenderObserver;
  10881. onBeforeRender: (effect: Effect) => void;
  10882. /**
  10883. * An event triggered after rendering the postprocess
  10884. * @type {BABYLON.Observable}
  10885. */
  10886. onAfterRenderObservable: Observable<Effect>;
  10887. private _onAfterRenderObserver;
  10888. onAfterRender: (efect: Effect) => void;
  10889. constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string, textureType?: number);
  10890. updateEffect(defines?: string): void;
  10891. isReusable(): boolean;
  10892. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  10893. markTextureDirty(): void;
  10894. activate(camera: Camera, sourceTexture?: WebGLTexture): void;
  10895. isSupported: boolean;
  10896. apply(): Effect;
  10897. dispose(camera?: Camera): void;
  10898. }
  10899. }
  10900. declare module BABYLON {
  10901. class PostProcessManager {
  10902. private _scene;
  10903. private _indexBuffer;
  10904. private _vertexBuffers;
  10905. constructor(scene: Scene);
  10906. private _prepareBuffers();
  10907. _prepareFrame(sourceTexture?: WebGLTexture): boolean;
  10908. directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void;
  10909. _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, faceIndex?: number, postProcesses?: PostProcess[]): void;
  10910. dispose(): void;
  10911. }
  10912. }
  10913. declare module BABYLON {
  10914. class RefractionPostProcess extends PostProcess {
  10915. color: Color3;
  10916. depth: number;
  10917. colorLevel: number;
  10918. private _refRexture;
  10919. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  10920. dispose(camera: Camera): void;
  10921. }
  10922. }
  10923. declare module BABYLON {
  10924. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  10925. /**
  10926. * The PassPostProcess id in the pipeline that contains the original scene color
  10927. * @type {string}
  10928. */
  10929. SSAOOriginalSceneColorEffect: string;
  10930. /**
  10931. * The SSAO PostProcess id in the pipeline
  10932. * @type {string}
  10933. */
  10934. SSAORenderEffect: string;
  10935. /**
  10936. * The horizontal blur PostProcess id in the pipeline
  10937. * @type {string}
  10938. */
  10939. SSAOBlurHRenderEffect: string;
  10940. /**
  10941. * The vertical blur PostProcess id in the pipeline
  10942. * @type {string}
  10943. */
  10944. SSAOBlurVRenderEffect: string;
  10945. /**
  10946. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  10947. * @type {string}
  10948. */
  10949. SSAOCombineRenderEffect: string;
  10950. /**
  10951. * The output strength of the SSAO post-process. Default value is 1.0.
  10952. * @type {number}
  10953. */
  10954. totalStrength: number;
  10955. /**
  10956. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  10957. * @type {number}
  10958. */
  10959. radius: number;
  10960. /**
  10961. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  10962. * Must not be equal to fallOff and superior to fallOff.
  10963. * Default value is 0.975
  10964. * @type {number}
  10965. */
  10966. area: number;
  10967. /**
  10968. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  10969. * Must not be equal to area and inferior to area.
  10970. * Default value is 0.0
  10971. * @type {number}
  10972. */
  10973. fallOff: number;
  10974. /**
  10975. * The base color of the SSAO post-process
  10976. * The final result is "base + ssao" between [0, 1]
  10977. * @type {number}
  10978. */
  10979. base: number;
  10980. private _scene;
  10981. private _depthTexture;
  10982. private _randomTexture;
  10983. private _originalColorPostProcess;
  10984. private _ssaoPostProcess;
  10985. private _blurHPostProcess;
  10986. private _blurVPostProcess;
  10987. private _ssaoCombinePostProcess;
  10988. private _firstUpdate;
  10989. private _ratio;
  10990. /**
  10991. * @constructor
  10992. * @param {string} name - The rendering pipeline name
  10993. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  10994. * @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 }
  10995. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  10996. */
  10997. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  10998. /**
  10999. * Returns the horizontal blur PostProcess
  11000. * @return {BABYLON.BlurPostProcess} The horizontal blur post-process
  11001. */
  11002. getBlurHPostProcess(): BlurPostProcess;
  11003. /**
  11004. * Returns the vertical blur PostProcess
  11005. * @return {BABYLON.BlurPostProcess} The vertical blur post-process
  11006. */
  11007. getBlurVPostProcess(): BlurPostProcess;
  11008. /**
  11009. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  11010. */
  11011. dispose(disableDepthRender?: boolean): void;
  11012. private _createBlurPostProcess(ratio);
  11013. private _createSSAOPostProcess(ratio);
  11014. private _createSSAOCombinePostProcess(ratio);
  11015. private _createRandomTexture();
  11016. }
  11017. }
  11018. declare module BABYLON {
  11019. class StereoscopicInterlacePostProcess extends PostProcess {
  11020. private _stepSize;
  11021. private _passedProcess;
  11022. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  11023. }
  11024. }
  11025. declare module BABYLON {
  11026. enum TonemappingOperator {
  11027. Hable = 0,
  11028. Reinhard = 1,
  11029. HejiDawson = 2,
  11030. Photographic = 3,
  11031. }
  11032. class TonemapPostProcess extends PostProcess {
  11033. private _operator;
  11034. exposureAdjustment: number;
  11035. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  11036. }
  11037. }
  11038. declare module BABYLON {
  11039. class VolumetricLightScatteringPostProcess extends PostProcess {
  11040. private _volumetricLightScatteringPass;
  11041. private _volumetricLightScatteringRTT;
  11042. private _viewPort;
  11043. private _screenCoordinates;
  11044. private _cachedDefines;
  11045. /**
  11046. * If not undefined, the mesh position is computed from the attached node position
  11047. * @type {{position: Vector3}}
  11048. */
  11049. attachedNode: {
  11050. position: Vector3;
  11051. };
  11052. /**
  11053. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  11054. * @type {Vector3}
  11055. */
  11056. customMeshPosition: Vector3;
  11057. /**
  11058. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  11059. * @type {boolean}
  11060. */
  11061. useCustomMeshPosition: boolean;
  11062. /**
  11063. * If the post-process should inverse the light scattering direction
  11064. * @type {boolean}
  11065. */
  11066. invert: boolean;
  11067. /**
  11068. * The internal mesh used by the post-process
  11069. * @type {boolean}
  11070. */
  11071. mesh: Mesh;
  11072. useDiffuseColor: boolean;
  11073. /**
  11074. * Array containing the excluded meshes not rendered in the internal pass
  11075. */
  11076. excludedMeshes: AbstractMesh[];
  11077. /**
  11078. * Controls the overall intensity of the post-process
  11079. * @type {number}
  11080. */
  11081. exposure: number;
  11082. /**
  11083. * Dissipates each sample's contribution in range [0, 1]
  11084. * @type {number}
  11085. */
  11086. decay: number;
  11087. /**
  11088. * Controls the overall intensity of each sample
  11089. * @type {number}
  11090. */
  11091. weight: number;
  11092. /**
  11093. * Controls the density of each sample
  11094. * @type {number}
  11095. */
  11096. density: number;
  11097. /**
  11098. * @constructor
  11099. * @param {string} name - The post-process name
  11100. * @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)
  11101. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  11102. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  11103. * @param {number} samples - The post-process quality, default 100
  11104. * @param {number} samplingMode - The post-process filtering mode
  11105. * @param {BABYLON.Engine} engine - The babylon engine
  11106. * @param {boolean} reusable - If the post-process is reusable
  11107. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  11108. */
  11109. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  11110. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11111. /**
  11112. * Sets the new light position for light scattering effect
  11113. * @param {BABYLON.Vector3} The new custom light position
  11114. */
  11115. setCustomMeshPosition(position: Vector3): void;
  11116. /**
  11117. * Returns the light position for light scattering effect
  11118. * @return {BABYLON.Vector3} The custom light position
  11119. */
  11120. getCustomMeshPosition(): Vector3;
  11121. /**
  11122. * Disposes the internal assets and detaches the post-process from the camera
  11123. */
  11124. dispose(camera: Camera): void;
  11125. /**
  11126. * Returns the render target texture used by the post-process
  11127. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  11128. */
  11129. getPass(): RenderTargetTexture;
  11130. private _meshExcluded(mesh);
  11131. private _createPass(scene, ratio);
  11132. private _updateMeshScreenCoordinates(scene);
  11133. /**
  11134. * Creates a default mesh for the Volumeric Light Scattering post-process
  11135. * @param {string} The mesh name
  11136. * @param {BABYLON.Scene} The scene where to create the mesh
  11137. * @return {BABYLON.Mesh} the default mesh
  11138. */
  11139. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  11140. }
  11141. }
  11142. declare module BABYLON {
  11143. class VRDistortionCorrectionPostProcess extends PostProcess {
  11144. aspectRatio: number;
  11145. private _isRightEye;
  11146. private _distortionFactors;
  11147. private _postProcessScaleFactor;
  11148. private _lensCenterOffset;
  11149. private _scaleIn;
  11150. private _scaleFactor;
  11151. private _lensCenter;
  11152. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  11153. }
  11154. }
  11155. declare module BABYLON {
  11156. class BoundingBoxRenderer {
  11157. frontColor: Color3;
  11158. backColor: Color3;
  11159. showBackLines: boolean;
  11160. renderList: SmartArray<BoundingBox>;
  11161. private _scene;
  11162. private _colorShader;
  11163. private _vertexBuffers;
  11164. private _indexBuffer;
  11165. constructor(scene: Scene);
  11166. private _prepareRessources();
  11167. reset(): void;
  11168. render(): void;
  11169. dispose(): void;
  11170. }
  11171. }
  11172. declare module BABYLON {
  11173. class DepthRenderer {
  11174. private _scene;
  11175. private _depthMap;
  11176. private _effect;
  11177. private _viewMatrix;
  11178. private _projectionMatrix;
  11179. private _transformMatrix;
  11180. private _worldViewProjection;
  11181. private _cachedDefines;
  11182. constructor(scene: Scene, type?: number);
  11183. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11184. getDepthMap(): RenderTargetTexture;
  11185. dispose(): void;
  11186. }
  11187. }
  11188. declare module BABYLON {
  11189. class EdgesRenderer {
  11190. edgesWidthScalerForOrthographic: number;
  11191. edgesWidthScalerForPerspective: number;
  11192. private _source;
  11193. private _linesPositions;
  11194. private _linesNormals;
  11195. private _linesIndices;
  11196. private _epsilon;
  11197. private _indicesCount;
  11198. private _lineShader;
  11199. private _ib;
  11200. private _buffers;
  11201. private _checkVerticesInsteadOfIndices;
  11202. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  11203. private _prepareRessources();
  11204. dispose(): void;
  11205. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  11206. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  11207. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  11208. _generateEdgesLines(): void;
  11209. render(): void;
  11210. }
  11211. }
  11212. declare module BABYLON {
  11213. class OutlineRenderer {
  11214. private _scene;
  11215. private _effect;
  11216. private _cachedDefines;
  11217. constructor(scene: Scene);
  11218. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  11219. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11220. }
  11221. }
  11222. declare module BABYLON {
  11223. class RenderingGroup {
  11224. index: number;
  11225. private _scene;
  11226. private _opaqueSubMeshes;
  11227. private _transparentSubMeshes;
  11228. private _alphaTestSubMeshes;
  11229. private _activeVertices;
  11230. onBeforeTransparentRendering: () => void;
  11231. constructor(index: number, scene: Scene);
  11232. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void): boolean;
  11233. prepare(): void;
  11234. dispatch(subMesh: SubMesh): void;
  11235. }
  11236. }
  11237. declare module BABYLON {
  11238. class RenderingManager {
  11239. static MAX_RENDERINGGROUPS: number;
  11240. private _scene;
  11241. private _renderingGroups;
  11242. private _depthBufferAlreadyCleaned;
  11243. private _currentIndex;
  11244. private _currentActiveMeshes;
  11245. private _currentRenderParticles;
  11246. private _currentRenderSprites;
  11247. constructor(scene: Scene);
  11248. private _renderParticles(index, activeMeshes);
  11249. private _renderSprites(index);
  11250. private _clearDepthBuffer();
  11251. private _renderSpritesAndParticles();
  11252. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void;
  11253. reset(): void;
  11254. dispatch(subMesh: SubMesh): void;
  11255. }
  11256. }
  11257. declare module BABYLON {
  11258. class Sprite {
  11259. name: string;
  11260. position: Vector3;
  11261. color: Color4;
  11262. width: number;
  11263. height: number;
  11264. angle: number;
  11265. cellIndex: number;
  11266. invertU: number;
  11267. invertV: number;
  11268. disposeWhenFinishedAnimating: boolean;
  11269. animations: Animation[];
  11270. isPickable: boolean;
  11271. actionManager: ActionManager;
  11272. private _animationStarted;
  11273. private _loopAnimation;
  11274. private _fromIndex;
  11275. private _toIndex;
  11276. private _delay;
  11277. private _direction;
  11278. private _frameCount;
  11279. private _manager;
  11280. private _time;
  11281. size: number;
  11282. constructor(name: string, manager: SpriteManager);
  11283. playAnimation(from: number, to: number, loop: boolean, delay: number): void;
  11284. stopAnimation(): void;
  11285. _animate(deltaTime: number): void;
  11286. dispose(): void;
  11287. }
  11288. }
  11289. declare module BABYLON {
  11290. class SpriteManager {
  11291. name: string;
  11292. cellSize: number;
  11293. sprites: Sprite[];
  11294. renderingGroupId: number;
  11295. layerMask: number;
  11296. fogEnabled: boolean;
  11297. isPickable: boolean;
  11298. /**
  11299. * An event triggered when the manager is disposed.
  11300. * @type {BABYLON.Observable}
  11301. */
  11302. onDisposeObservable: Observable<SpriteManager>;
  11303. private _onDisposeObserver;
  11304. onDispose: () => void;
  11305. private _capacity;
  11306. private _spriteTexture;
  11307. private _epsilon;
  11308. private _scene;
  11309. private _vertexData;
  11310. private _buffer;
  11311. private _vertexBuffers;
  11312. private _indexBuffer;
  11313. private _effectBase;
  11314. private _effectFog;
  11315. texture: Texture;
  11316. constructor(name: string, imgUrl: string, capacity: number, cellSize: number, scene: Scene, epsilon?: number, samplingMode?: number);
  11317. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  11318. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): PickingInfo;
  11319. render(): void;
  11320. dispose(): void;
  11321. }
  11322. }
  11323. declare module BABYLON.Internals {
  11324. class _AlphaState {
  11325. private _isAlphaBlendDirty;
  11326. private _isBlendFunctionParametersDirty;
  11327. private _alphaBlend;
  11328. private _blendFunctionParameters;
  11329. isDirty: boolean;
  11330. alphaBlend: boolean;
  11331. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  11332. reset(): void;
  11333. apply(gl: WebGLRenderingContext): void;
  11334. }
  11335. }
  11336. declare module BABYLON.Internals {
  11337. class _DepthCullingState {
  11338. private _isDepthTestDirty;
  11339. private _isDepthMaskDirty;
  11340. private _isDepthFuncDirty;
  11341. private _isCullFaceDirty;
  11342. private _isCullDirty;
  11343. private _isZOffsetDirty;
  11344. private _depthTest;
  11345. private _depthMask;
  11346. private _depthFunc;
  11347. private _cull;
  11348. private _cullFace;
  11349. private _zOffset;
  11350. isDirty: boolean;
  11351. zOffset: number;
  11352. cullFace: number;
  11353. cull: boolean;
  11354. depthFunc: number;
  11355. depthMask: boolean;
  11356. depthTest: boolean;
  11357. reset(): void;
  11358. apply(gl: WebGLRenderingContext): void;
  11359. }
  11360. }
  11361. declare module BABYLON.Internals {
  11362. class AndOrNotEvaluator {
  11363. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  11364. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  11365. private static _SimplifyNegation(booleanString);
  11366. }
  11367. }
  11368. declare module BABYLON {
  11369. interface IAssetTask {
  11370. onSuccess: (task: IAssetTask) => void;
  11371. onError: (task: IAssetTask) => void;
  11372. isCompleted: boolean;
  11373. run(scene: Scene, onSuccess: () => void, onError: () => void): any;
  11374. }
  11375. class MeshAssetTask implements IAssetTask {
  11376. name: string;
  11377. meshesNames: any;
  11378. rootUrl: string;
  11379. sceneFilename: string;
  11380. loadedMeshes: Array<AbstractMesh>;
  11381. loadedParticleSystems: Array<ParticleSystem>;
  11382. loadedSkeletons: Array<Skeleton>;
  11383. onSuccess: (task: IAssetTask) => void;
  11384. onError: (task: IAssetTask) => void;
  11385. isCompleted: boolean;
  11386. constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string);
  11387. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11388. }
  11389. class TextFileAssetTask implements IAssetTask {
  11390. name: string;
  11391. url: string;
  11392. onSuccess: (task: IAssetTask) => void;
  11393. onError: (task: IAssetTask) => void;
  11394. isCompleted: boolean;
  11395. text: string;
  11396. constructor(name: string, url: string);
  11397. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11398. }
  11399. class BinaryFileAssetTask implements IAssetTask {
  11400. name: string;
  11401. url: string;
  11402. onSuccess: (task: IAssetTask) => void;
  11403. onError: (task: IAssetTask) => void;
  11404. isCompleted: boolean;
  11405. data: ArrayBuffer;
  11406. constructor(name: string, url: string);
  11407. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11408. }
  11409. class ImageAssetTask implements IAssetTask {
  11410. name: string;
  11411. url: string;
  11412. onSuccess: (task: IAssetTask) => void;
  11413. onError: (task: IAssetTask) => void;
  11414. isCompleted: boolean;
  11415. image: HTMLImageElement;
  11416. constructor(name: string, url: string);
  11417. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11418. }
  11419. class TextureAssetTask implements IAssetTask {
  11420. name: string;
  11421. url: string;
  11422. noMipmap: boolean;
  11423. invertY: boolean;
  11424. samplingMode: number;
  11425. onSuccess: (task: IAssetTask) => void;
  11426. onError: (task: IAssetTask) => void;
  11427. isCompleted: boolean;
  11428. texture: Texture;
  11429. constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number);
  11430. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  11431. }
  11432. class AssetsManager {
  11433. private _tasks;
  11434. private _scene;
  11435. private _waitingTasksCount;
  11436. onFinish: (tasks: IAssetTask[]) => void;
  11437. onTaskSuccess: (task: IAssetTask) => void;
  11438. onTaskError: (task: IAssetTask) => void;
  11439. useDefaultLoadingScreen: boolean;
  11440. constructor(scene: Scene);
  11441. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask;
  11442. addTextFileTask(taskName: string, url: string): IAssetTask;
  11443. addBinaryFileTask(taskName: string, url: string): IAssetTask;
  11444. addImageTask(taskName: string, url: string): IAssetTask;
  11445. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): IAssetTask;
  11446. private _decreaseWaitingTasksCount();
  11447. private _runTask(task);
  11448. reset(): AssetsManager;
  11449. load(): AssetsManager;
  11450. }
  11451. }
  11452. declare module BABYLON {
  11453. class Database {
  11454. private callbackManifestChecked;
  11455. private currentSceneUrl;
  11456. private db;
  11457. private enableSceneOffline;
  11458. private enableTexturesOffline;
  11459. private manifestVersionFound;
  11460. private mustUpdateRessources;
  11461. private hasReachedQuota;
  11462. private isSupported;
  11463. private idbFactory;
  11464. static IsUASupportingBlobStorage: boolean;
  11465. static IDBStorageEnabled: boolean;
  11466. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  11467. static parseURL: (url: string) => string;
  11468. static ReturnFullUrlLocation: (url: string) => string;
  11469. checkManifestFile(): void;
  11470. openAsync(successCallback: any, errorCallback: any): void;
  11471. loadImageFromDB(url: string, image: HTMLImageElement): void;
  11472. private _loadImageFromDBAsync(url, image, notInDBCallback);
  11473. private _saveImageIntoDBAsync(url, image);
  11474. private _checkVersionFromDB(url, versionLoaded);
  11475. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  11476. private _saveVersionIntoDBAsync(url, callback);
  11477. private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?);
  11478. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  11479. private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?);
  11480. }
  11481. }
  11482. declare module BABYLON {
  11483. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11484. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11485. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11486. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11487. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11488. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11489. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11490. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  11491. class SerializationHelper {
  11492. static Serialize<T>(entity: T, serializationObject?: any): any;
  11493. static Parse<T>(creationFunction: () => T, source: any, scene: Scene, rootUrl?: string): T;
  11494. static Clone<T>(creationFunction: () => T, source: T): T;
  11495. }
  11496. }
  11497. declare module BABYLON {
  11498. class DynamicFloatArrayElementInfo {
  11499. offset: number;
  11500. }
  11501. /**
  11502. * The purpose of this class is to store float32 based elements of a given size (defined by the stride argument) in a dynamic fashion, that is, you can add/free elements. You can then access to a defragmented/packed version of the underlying Float32Array by calling the pack() method.
  11503. * The intent is to maintain through time data that will be bound to a WebGlBuffer with the ability to change add/remove elements.
  11504. * It was first built to efficiently maintain the WebGlBuffer that contain instancing based data.
  11505. * Allocating an Element will return a instance of DynamicFloatArrayElement which contains the offset into the Float32Array of where the element starts, you are then responsible to copy your data using this offset.
  11506. * Beware, calling pack() may change the offset of some Entries because this method will defragment the Float32Array to replace empty elements by moving allocated ones at their location.
  11507. * This method will return an ArrayBufferView on the existing Float32Array that describes the used elements. Use this View to update the WebGLBuffer and NOT the "buffer" field of the class. The pack() method won't shrink/reallocate the buffer to keep it GC friendly, all the empty space will be put at the end of the buffer, the method just ensure there are no "free holes".
  11508. */
  11509. class DynamicFloatArray {
  11510. /**
  11511. * Construct an instance of the dynamic float array
  11512. * @param stride size of one element in float (i.e. not bytes!)
  11513. * @param initialElementCount the number of available entries at construction
  11514. */
  11515. constructor(stride: number, initialElementCount: number);
  11516. /**
  11517. * Allocate an element in the array.
  11518. * @return the element info instance that contains the offset into the main buffer of the element's location.
  11519. * Beware, this offset may change when you call pack()
  11520. */
  11521. allocElement(): DynamicFloatArrayElementInfo;
  11522. /**
  11523. * Free the element corresponding to the given element info
  11524. * @param elInfo the element that describe the allocated element
  11525. */
  11526. freeElement(elInfo: DynamicFloatArrayElementInfo): void;
  11527. /**
  11528. * This method will pack all the used elements into a linear sequence and put all the free space at the end.
  11529. * Instances of DynamicFloatArrayElement may have their 'offset' member changed as data could be copied from one location to another, so be sure to read/write your data based on the value inside this member after you called pack().
  11530. * @return the subArray that is the view of the used elements area, you can use it as a source to update a WebGLBuffer
  11531. */
  11532. pack(): Float32Array;
  11533. private _moveElement(element, destOffset);
  11534. private _growBuffer();
  11535. /**
  11536. * This is the main buffer, all elements are stored inside, you use the DynamicFloatArrayElement instance of a given element to know its location into this buffer, then you have the responsibility to perform write operations in this buffer at the right location!
  11537. * Don't use this buffer for a WebGL bufferSubData() operation, but use the one returned by the pack() method.
  11538. */
  11539. buffer: Float32Array;
  11540. /**
  11541. * Get the total count of entries that can fit in the current buffer
  11542. * @returns the elements count
  11543. */
  11544. totalElementCount: number;
  11545. /**
  11546. * Get the count of free entries that can still be allocated without resizing the buffer
  11547. * @returns the free elements count
  11548. */
  11549. freeElementCount: number;
  11550. /**
  11551. * Get the count of allocated elements
  11552. * @returns the allocated elements count
  11553. */
  11554. usedElementCount: number;
  11555. /**
  11556. * Return the size of one element in float
  11557. * @returns the size in float
  11558. */
  11559. stride: number;
  11560. compareValueOffset: number;
  11561. sortingAscending: boolean;
  11562. sort(): boolean;
  11563. private _allEntries;
  11564. private _freeEntries;
  11565. private _stride;
  11566. private _lastUsed;
  11567. private _firstFree;
  11568. private _sortTable;
  11569. private _sortedTable;
  11570. }
  11571. }
  11572. declare module Earcut {
  11573. /**
  11574. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  11575. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  11576. * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11).
  11577. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  11578. */
  11579. function earcut(data: number[], holeIndices: number[], dim: number): any[];
  11580. /**
  11581. * return a percentage difference between the polygon area and its triangulation area;
  11582. * used to verify correctness of triangulation
  11583. */
  11584. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  11585. /**
  11586. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  11587. */
  11588. function flatten(data: number[][][]): {
  11589. vertices: any[];
  11590. holes: any[];
  11591. dimensions: number;
  11592. };
  11593. }
  11594. declare module BABYLON {
  11595. class FilesInput {
  11596. private _engine;
  11597. private _currentScene;
  11598. private _canvas;
  11599. private _sceneLoadedCallback;
  11600. private _progressCallback;
  11601. private _additionnalRenderLoopLogicCallback;
  11602. private _textureLoadingCallback;
  11603. private _startingProcessingFilesCallback;
  11604. private _elementToMonitor;
  11605. static FilesTextures: any[];
  11606. static FilesToLoad: any[];
  11607. private _sceneFileToLoad;
  11608. private _filesToLoad;
  11609. 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);
  11610. monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void;
  11611. private renderFunction();
  11612. private drag(e);
  11613. private drop(eventDrop);
  11614. loadFiles(event: any): void;
  11615. reload(): void;
  11616. }
  11617. }
  11618. declare module BABYLON {
  11619. class Gamepads {
  11620. private babylonGamepads;
  11621. private oneGamepadConnected;
  11622. private isMonitoring;
  11623. private gamepadEventSupported;
  11624. private gamepadSupportAvailable;
  11625. private _callbackGamepadConnected;
  11626. private _onGamepadConnectedEvent;
  11627. private _onGamepadDisonnectedEvent;
  11628. private static gamepadDOMInfo;
  11629. constructor(ongamedpadconnected: (gamepad: Gamepad) => void);
  11630. dispose(): void;
  11631. private _onGamepadConnected(evt);
  11632. private _addNewGamepad(gamepad);
  11633. private _onGamepadDisconnected(evt);
  11634. private _startMonitoringGamepads();
  11635. private _stopMonitoringGamepads();
  11636. private _checkGamepadsStatus();
  11637. private _updateGamepadObjects();
  11638. }
  11639. class StickValues {
  11640. x: any;
  11641. y: any;
  11642. constructor(x: any, y: any);
  11643. }
  11644. class Gamepad {
  11645. id: string;
  11646. index: number;
  11647. browserGamepad: any;
  11648. private _leftStick;
  11649. private _rightStick;
  11650. private _onleftstickchanged;
  11651. private _onrightstickchanged;
  11652. constructor(id: string, index: number, browserGamepad: any);
  11653. onleftstickchanged(callback: (values: StickValues) => void): void;
  11654. onrightstickchanged(callback: (values: StickValues) => void): void;
  11655. leftStick: StickValues;
  11656. rightStick: StickValues;
  11657. update(): void;
  11658. }
  11659. class GenericPad extends Gamepad {
  11660. id: string;
  11661. index: number;
  11662. gamepad: any;
  11663. private _buttons;
  11664. private _onbuttondown;
  11665. private _onbuttonup;
  11666. onbuttondown(callback: (buttonPressed: number) => void): void;
  11667. onbuttonup(callback: (buttonReleased: number) => void): void;
  11668. constructor(id: string, index: number, gamepad: any);
  11669. private _setButtonValue(newValue, currentValue, buttonIndex);
  11670. update(): void;
  11671. }
  11672. enum Xbox360Button {
  11673. A = 0,
  11674. B = 1,
  11675. X = 2,
  11676. Y = 3,
  11677. Start = 4,
  11678. Back = 5,
  11679. LB = 6,
  11680. RB = 7,
  11681. LeftStick = 8,
  11682. RightStick = 9,
  11683. }
  11684. enum Xbox360Dpad {
  11685. Up = 0,
  11686. Down = 1,
  11687. Left = 2,
  11688. Right = 3,
  11689. }
  11690. class Xbox360Pad extends Gamepad {
  11691. private _leftTrigger;
  11692. private _rightTrigger;
  11693. private _onlefttriggerchanged;
  11694. private _onrighttriggerchanged;
  11695. private _onbuttondown;
  11696. private _onbuttonup;
  11697. private _ondpaddown;
  11698. private _ondpadup;
  11699. private _buttonA;
  11700. private _buttonB;
  11701. private _buttonX;
  11702. private _buttonY;
  11703. private _buttonBack;
  11704. private _buttonStart;
  11705. private _buttonLB;
  11706. private _buttonRB;
  11707. private _buttonLeftStick;
  11708. private _buttonRightStick;
  11709. private _dPadUp;
  11710. private _dPadDown;
  11711. private _dPadLeft;
  11712. private _dPadRight;
  11713. onlefttriggerchanged(callback: (value: number) => void): void;
  11714. onrighttriggerchanged(callback: (value: number) => void): void;
  11715. leftTrigger: number;
  11716. rightTrigger: number;
  11717. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  11718. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  11719. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  11720. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  11721. private _setButtonValue(newValue, currentValue, buttonType);
  11722. private _setDPadValue(newValue, currentValue, buttonType);
  11723. buttonA: number;
  11724. buttonB: number;
  11725. buttonX: number;
  11726. buttonY: number;
  11727. buttonStart: number;
  11728. buttonBack: number;
  11729. buttonLB: number;
  11730. buttonRB: number;
  11731. buttonLeftStick: number;
  11732. buttonRightStick: number;
  11733. dPadUp: number;
  11734. dPadDown: number;
  11735. dPadLeft: number;
  11736. dPadRight: number;
  11737. update(): void;
  11738. }
  11739. }
  11740. interface Navigator {
  11741. getGamepads(func?: any): any;
  11742. webkitGetGamepads(func?: any): any;
  11743. msGetGamepads(func?: any): any;
  11744. webkitGamepads(func?: any): any;
  11745. }
  11746. declare module BABYLON {
  11747. interface ILoadingScreen {
  11748. displayLoadingUI: () => void;
  11749. hideLoadingUI: () => void;
  11750. loadingUIBackgroundColor: string;
  11751. loadingUIText: string;
  11752. }
  11753. class DefaultLoadingScreen implements ILoadingScreen {
  11754. private _renderingCanvas;
  11755. private _loadingText;
  11756. private _loadingDivBackgroundColor;
  11757. private _loadingDiv;
  11758. private _loadingTextDiv;
  11759. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11760. displayLoadingUI(): void;
  11761. hideLoadingUI(): void;
  11762. loadingUIText: string;
  11763. loadingUIBackgroundColor: string;
  11764. private _resizeLoadingUI;
  11765. }
  11766. }
  11767. declare module BABYLON {
  11768. /**
  11769. * A class serves as a medium between the observable and its observers
  11770. */
  11771. class EventState {
  11772. /**
  11773. * If the callback of a given Observer set skipNextObservers to true the following observers will be ignored
  11774. */
  11775. constructor(mask: number, skipNextObservers?: boolean);
  11776. initalize(mask: number, skipNextObservers?: boolean): EventState;
  11777. /**
  11778. * An Observer can set this property to true to prevent subsequent observers of being notified
  11779. */
  11780. skipNextObservers: boolean;
  11781. /**
  11782. * Get the mask value that were used to trigger the event corresponding to this EventState object
  11783. */
  11784. mask: number;
  11785. }
  11786. /**
  11787. * Represent an Observer registered to a given Observable object.
  11788. */
  11789. class Observer<T> {
  11790. callback: (eventData: T, eventState: EventState) => void;
  11791. mask: number;
  11792. constructor(callback: (eventData: T, eventState: EventState) => void, mask: number);
  11793. }
  11794. /**
  11795. * The Observable class is a simple implementation of the Observable pattern.
  11796. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  11797. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  11798. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  11799. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  11800. */
  11801. class Observable<T> {
  11802. private static _pooledEventState;
  11803. _observers: Observer<T>[];
  11804. /**
  11805. * Create a new Observer with the specified callback
  11806. * @param callback the callback that will be executed for that Observer
  11807. * @param mask the mask used to filter observers
  11808. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  11809. */
  11810. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean): Observer<T>;
  11811. /**
  11812. * Remove an Observer from the Observable object
  11813. * @param observer the instance of the Observer to remove. If it doesn't belong to this Observable, false will be returned.
  11814. */
  11815. remove(observer: Observer<T>): boolean;
  11816. /**
  11817. * Remove a callback from the Observable object
  11818. * @param callback the callback to remove. If it doesn't belong to this Observable, false will be returned.
  11819. */
  11820. removeCallback(callback: (eventData: T, eventState: EventState) => void): boolean;
  11821. /**
  11822. * Notify all Observers by calling their respective callback with the given data
  11823. * @param eventData
  11824. * @param mask
  11825. */
  11826. notifyObservers(eventData: T, mask?: number): void;
  11827. /**
  11828. * return true is the Observable has at least one Observer registered
  11829. */
  11830. hasObservers(): boolean;
  11831. /**
  11832. * Clear the list of observers
  11833. */
  11834. clear(): void;
  11835. /**
  11836. * Clone the current observable
  11837. */
  11838. clone(): Observable<T>;
  11839. }
  11840. }
  11841. declare module BABYLON {
  11842. /**
  11843. * This class describe a rectangle that were added to the map.
  11844. * You have access to its coordinates either in pixel or normalized (UV)
  11845. */
  11846. class PackedRect {
  11847. constructor(root: PackedRect, parent: PackedRect, pos: Vector2, size: Size);
  11848. /**
  11849. * @returns the position of this node into the map
  11850. */
  11851. pos: Vector2;
  11852. /**
  11853. * @returns the size of the rectangle this node handles
  11854. */
  11855. contentSize: Size;
  11856. /**
  11857. * Compute the UV of the top/left, top/right, bottom/right, bottom/left points of the rectangle this node handles into the map
  11858. * @returns And array of 4 Vector2, containing UV coordinates for the four corners of the Rectangle into the map
  11859. */
  11860. UVs: Vector2[];
  11861. /**
  11862. * You may have allocated the PackedRect using over-provisioning (you allocated more than you need in order to prevent frequent deallocations/reallocations) and then using only a part of the PackRect.
  11863. * This method will return the UVs for this part by given the custom size of what you really use
  11864. * @param customSize must be less/equal to the allocated size, UV will be compute from this
  11865. */
  11866. getUVsForCustomSize(customSize: Size): Vector2[];
  11867. /**
  11868. * Free this rectangle from the map.
  11869. * Call this method when you no longer need the rectangle to be in the map.
  11870. */
  11871. freeContent(): void;
  11872. protected isUsed: boolean;
  11873. protected findAndSplitNode(contentSize: Size): PackedRect;
  11874. private findNode(size);
  11875. private splitNode(contentSize);
  11876. private attemptDefrag();
  11877. private clearNode();
  11878. private isRecursiveFree;
  11879. protected evalFreeSize(size: number): number;
  11880. protected _root: PackedRect;
  11881. protected _parent: PackedRect;
  11882. private _contentSize;
  11883. private _initialSize;
  11884. private _leftNode;
  11885. private _rightNode;
  11886. private _bottomNode;
  11887. private _pos;
  11888. protected _size: Size;
  11889. }
  11890. /**
  11891. * The purpose of this class is to pack several Rectangles into a big map, while trying to fit everything as optimally as possible.
  11892. * This class is typically used to build lightmaps, sprite map or to pack several little textures into a big one.
  11893. * Note that this class allows allocated Rectangles to be freed: that is the map is dynamically maintained so you can add/remove rectangle based on their life-cycle.
  11894. */
  11895. class RectPackingMap extends PackedRect {
  11896. /**
  11897. * Create an instance of the object with a dimension using the given size
  11898. * @param size The dimension of the rectangle that will contain all the sub ones.
  11899. */
  11900. constructor(size: Size);
  11901. /**
  11902. * Add a rectangle, finding the best location to store it into the map
  11903. * @param size the dimension of the rectangle to store
  11904. * @return the Node containing the rectangle information, or null if we couldn't find a free spot
  11905. */
  11906. addRect(size: Size): PackedRect;
  11907. /**
  11908. * Return the current space free normalized between [0;1]
  11909. * @returns {}
  11910. */
  11911. freeSpace: number;
  11912. }
  11913. }
  11914. declare module BABYLON {
  11915. class SceneOptimization {
  11916. priority: number;
  11917. apply: (scene: Scene) => boolean;
  11918. constructor(priority?: number);
  11919. }
  11920. class TextureOptimization extends SceneOptimization {
  11921. priority: number;
  11922. maximumSize: number;
  11923. constructor(priority?: number, maximumSize?: number);
  11924. apply: (scene: Scene) => boolean;
  11925. }
  11926. class HardwareScalingOptimization extends SceneOptimization {
  11927. priority: number;
  11928. maximumScale: number;
  11929. private _currentScale;
  11930. constructor(priority?: number, maximumScale?: number);
  11931. apply: (scene: Scene) => boolean;
  11932. }
  11933. class ShadowsOptimization extends SceneOptimization {
  11934. apply: (scene: Scene) => boolean;
  11935. }
  11936. class PostProcessesOptimization extends SceneOptimization {
  11937. apply: (scene: Scene) => boolean;
  11938. }
  11939. class LensFlaresOptimization extends SceneOptimization {
  11940. apply: (scene: Scene) => boolean;
  11941. }
  11942. class ParticlesOptimization extends SceneOptimization {
  11943. apply: (scene: Scene) => boolean;
  11944. }
  11945. class RenderTargetsOptimization extends SceneOptimization {
  11946. apply: (scene: Scene) => boolean;
  11947. }
  11948. class MergeMeshesOptimization extends SceneOptimization {
  11949. static _UpdateSelectionTree: boolean;
  11950. static UpdateSelectionTree: boolean;
  11951. private _canBeMerged;
  11952. apply: (scene: Scene, updateSelectionTree?: boolean) => boolean;
  11953. }
  11954. class SceneOptimizerOptions {
  11955. targetFrameRate: number;
  11956. trackerDuration: number;
  11957. optimizations: SceneOptimization[];
  11958. constructor(targetFrameRate?: number, trackerDuration?: number);
  11959. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  11960. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  11961. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  11962. }
  11963. class SceneOptimizer {
  11964. static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void;
  11965. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void;
  11966. }
  11967. }
  11968. declare module BABYLON {
  11969. class SceneSerializer {
  11970. static ClearCache(): void;
  11971. static Serialize(scene: Scene): any;
  11972. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  11973. }
  11974. }
  11975. declare module BABYLON {
  11976. class SmartArray<T> {
  11977. data: Array<T>;
  11978. length: number;
  11979. private _id;
  11980. private _duplicateId;
  11981. constructor(capacity: number);
  11982. push(value: any): void;
  11983. pushNoDuplicate(value: any): boolean;
  11984. sort(compareFn: any): void;
  11985. reset(): void;
  11986. concat(array: any): void;
  11987. concatWithNoDuplicate(array: any): void;
  11988. indexOf(value: any): number;
  11989. private static _GlobalId;
  11990. }
  11991. }
  11992. declare module BABYLON {
  11993. /**
  11994. * This class implement a typical dictionary using a string as key and the generic type T as value.
  11995. * The underlying implementation relies on an associative array to ensure the best performances.
  11996. * The value can be anything including 'null' but except 'undefined'
  11997. */
  11998. class StringDictionary<T> {
  11999. /**
  12000. * Get a value based from its key
  12001. * @param key the given key to get the matching value from
  12002. * @return the value if found, otherwise undefined is returned
  12003. */
  12004. get(key: string): T;
  12005. /**
  12006. * Get a value from its key or add it if it doesn't exist.
  12007. * This method will ensure you that a given key/data will be present in the dictionary.
  12008. * @param key the given key to get the matching value from
  12009. * @param factory the factory that will create the value if the key is not present in the dictionary.
  12010. * The factory will only be invoked if there's no data for the given key.
  12011. * @return the value corresponding to the key.
  12012. */
  12013. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  12014. /**
  12015. * Get a value from its key if present in the dictionary otherwise add it
  12016. * @param key the key to get the value from
  12017. * @param val if there's no such key/value pair in the dictionary add it with this value
  12018. * @return the value corresponding to the key
  12019. */
  12020. getOrAdd(key: string, val: T): T;
  12021. /**
  12022. * Check if there's a given key in the dictionary
  12023. * @param key the key to check for
  12024. * @return true if the key is present, false otherwise
  12025. */
  12026. contains(key: any): boolean;
  12027. /**
  12028. * Add a new key and its corresponding value
  12029. * @param key the key to add
  12030. * @param value the value corresponding to the key
  12031. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  12032. */
  12033. add(key: string, value: T): boolean;
  12034. set(key: string, value: T): boolean;
  12035. /**
  12036. * Remove a key/value from the dictionary.
  12037. * @param key the key to remove
  12038. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  12039. */
  12040. remove(key: string): boolean;
  12041. /**
  12042. * Clear the whole content of the dictionary
  12043. */
  12044. clear(): void;
  12045. count: number;
  12046. /**
  12047. * Execute a callback on each key/val of the dictionary.
  12048. * Note that you can remove any element in this dictionary in the callback implementation
  12049. * @param callback the callback to execute on a given key/value pair
  12050. */
  12051. forEach(callback: (key: string, val: T) => void): void;
  12052. /**
  12053. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  12054. * If the callback returns null or undefined the method will iterate to the next key/value pair
  12055. * Note that you can remove any element in this dictionary in the callback implementation
  12056. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  12057. */
  12058. first<TRes>(callback: (key: string, val: T) => TRes): TRes;
  12059. private _count;
  12060. private _data;
  12061. }
  12062. }
  12063. declare module BABYLON {
  12064. class Tags {
  12065. static EnableFor(obj: any): void;
  12066. static DisableFor(obj: any): void;
  12067. static HasTags(obj: any): boolean;
  12068. static GetTags(obj: any, asString?: boolean): any;
  12069. static AddTagsTo(obj: any, tagsString: string): void;
  12070. static _AddTagTo(obj: any, tag: string): void;
  12071. static RemoveTagsFrom(obj: any, tagsString: string): void;
  12072. static _RemoveTagFrom(obj: any, tag: string): void;
  12073. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  12074. }
  12075. }
  12076. declare module BABYLON.Internals {
  12077. interface DDSInfo {
  12078. width: number;
  12079. height: number;
  12080. mipmapCount: number;
  12081. isFourCC: boolean;
  12082. isRGB: boolean;
  12083. isLuminance: boolean;
  12084. isCube: boolean;
  12085. }
  12086. class DDSTools {
  12087. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  12088. private static GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  12089. private static GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  12090. private static GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  12091. static UploadDDSLevels(gl: WebGLRenderingContext, ext: any, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number): void;
  12092. }
  12093. }
  12094. declare module BABYLON.Internals {
  12095. class TGATools {
  12096. private static _TYPE_NO_DATA;
  12097. private static _TYPE_INDEXED;
  12098. private static _TYPE_RGB;
  12099. private static _TYPE_GREY;
  12100. private static _TYPE_RLE_INDEXED;
  12101. private static _TYPE_RLE_RGB;
  12102. private static _TYPE_RLE_GREY;
  12103. private static _ORIGIN_MASK;
  12104. private static _ORIGIN_SHIFT;
  12105. private static _ORIGIN_BL;
  12106. private static _ORIGIN_BR;
  12107. private static _ORIGIN_UL;
  12108. private static _ORIGIN_UR;
  12109. static GetTGAHeader(data: Uint8Array): any;
  12110. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  12111. 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;
  12112. 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;
  12113. 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;
  12114. 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;
  12115. 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;
  12116. 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;
  12117. }
  12118. }
  12119. declare module BABYLON {
  12120. interface IAnimatable {
  12121. animations: Array<Animation>;
  12122. }
  12123. class Tools {
  12124. static BaseUrl: string;
  12125. static CorsBehavior: any;
  12126. static UseFallbackTexture: boolean;
  12127. static Instantiate(className: string): any;
  12128. static SetImmediate(action: () => void): void;
  12129. static IsExponentOfTwo(value: number): boolean;
  12130. static GetExponentOfTwo(value: number, max: number): number;
  12131. static GetFilename(path: string): string;
  12132. static GetDOMTextContent(element: HTMLElement): string;
  12133. static ToDegrees(angle: number): number;
  12134. static ToRadians(angle: number): number;
  12135. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  12136. static ExtractMinAndMaxIndexed(positions: number[] | Float32Array, indices: number[] | Int32Array, indexStart: number, indexCount: number, bias?: Vector2): {
  12137. minimum: Vector3;
  12138. maximum: Vector3;
  12139. };
  12140. static ExtractMinAndMax(positions: number[] | Float32Array, start: number, count: number, bias?: Vector2, stride?: number): {
  12141. minimum: Vector3;
  12142. maximum: Vector3;
  12143. };
  12144. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i) => Vector2;
  12145. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Vector2): {
  12146. minimum: Vector2;
  12147. maximum: Vector2;
  12148. };
  12149. static MakeArray(obj: any, allowsNullUndefined?: boolean): Array<any>;
  12150. static GetPointerPrefix(): string;
  12151. static QueueNewFrame(func: any): void;
  12152. static RequestFullscreen(element: any, options?: any): void;
  12153. static ExitFullscreen(): void;
  12154. static CleanUrl(url: string): string;
  12155. static LoadImage(url: any, onload: any, onerror: any, database: any): HTMLImageElement;
  12156. static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: () => void, database?: any, useArrayBuffer?: boolean, onError?: () => void): void;
  12157. static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void;
  12158. static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void;
  12159. static FileAsURL(content: string): string;
  12160. static Format(value: number, decimals?: number): string;
  12161. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  12162. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  12163. static IsEmpty(obj: any): boolean;
  12164. static RegisterTopRootEvents(events: {
  12165. name: string;
  12166. handler: EventListener;
  12167. }[]): void;
  12168. static UnregisterTopRootEvents(events: {
  12169. name: string;
  12170. handler: EventListener;
  12171. }[]): void;
  12172. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void): void;
  12173. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void): void;
  12174. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  12175. private static _NoneLogLevel;
  12176. private static _MessageLogLevel;
  12177. private static _WarningLogLevel;
  12178. private static _ErrorLogLevel;
  12179. private static _LogCache;
  12180. static errorsCount: number;
  12181. static OnNewCacheEntry: (entry: string) => void;
  12182. static NoneLogLevel: number;
  12183. static MessageLogLevel: number;
  12184. static WarningLogLevel: number;
  12185. static ErrorLogLevel: number;
  12186. static AllLogLevel: number;
  12187. private static _AddLogEntry(entry);
  12188. private static _FormatMessage(message);
  12189. static Log: (message: string) => void;
  12190. private static _LogDisabled(message);
  12191. private static _LogEnabled(message);
  12192. static Warn: (message: string) => void;
  12193. private static _WarnDisabled(message);
  12194. private static _WarnEnabled(message);
  12195. static Error: (message: string) => void;
  12196. private static _ErrorDisabled(message);
  12197. private static _ErrorEnabled(message);
  12198. static LogCache: string;
  12199. static ClearLogCache(): void;
  12200. static LogLevels: number;
  12201. private static _PerformanceNoneLogLevel;
  12202. private static _PerformanceUserMarkLogLevel;
  12203. private static _PerformanceConsoleLogLevel;
  12204. private static _performance;
  12205. static PerformanceNoneLogLevel: number;
  12206. static PerformanceUserMarkLogLevel: number;
  12207. static PerformanceConsoleLogLevel: number;
  12208. static PerformanceLogLevel: number;
  12209. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  12210. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  12211. static _StartUserMark(counterName: string, condition?: boolean): void;
  12212. static _EndUserMark(counterName: string, condition?: boolean): void;
  12213. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  12214. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  12215. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  12216. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  12217. static Now: number;
  12218. /**
  12219. * This method will return the name of the class used to create the instance of the given object.
  12220. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  12221. * @param object the object to get the class name from
  12222. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  12223. */
  12224. static getClassName(object: any, isType?: boolean): string;
  12225. static first<T>(array: Array<T>, predicate: (item) => boolean): T;
  12226. /**
  12227. * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
  12228. * @param array
  12229. */
  12230. static arrayOrStringFeeder(array: any): (i) => number;
  12231. /**
  12232. * Compute the hashCode of a stream of number
  12233. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  12234. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  12235. * @return the hash code computed
  12236. */
  12237. static hashCodeFromStream(feeder: (index: number) => number): number;
  12238. }
  12239. /**
  12240. * This class is used to track a performance counter which is number based.
  12241. * The user has access to many properties which give statistics of different nature
  12242. *
  12243. * The implementer can track two kinds of Performance Counter: time and count
  12244. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  12245. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  12246. */
  12247. class PerfCounter {
  12248. /**
  12249. * Returns the smallest value ever
  12250. */
  12251. min: number;
  12252. /**
  12253. * Returns the biggest value ever
  12254. */
  12255. max: number;
  12256. /**
  12257. * Returns the average value since the performance counter is running
  12258. */
  12259. average: number;
  12260. /**
  12261. * Returns the average value of the last second the counter was monitored
  12262. */
  12263. lastSecAverage: number;
  12264. /**
  12265. * Returns the current value
  12266. */
  12267. current: number;
  12268. total: number;
  12269. constructor();
  12270. /**
  12271. * Call this method to start monitoring a new frame.
  12272. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  12273. */
  12274. fetchNewFrame(): void;
  12275. /**
  12276. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  12277. * @param newCount the count value to add to the monitored count
  12278. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  12279. */
  12280. addCount(newCount: number, fetchResult: boolean): void;
  12281. /**
  12282. * Start monitoring this performance counter
  12283. */
  12284. beginMonitoring(): void;
  12285. /**
  12286. * Compute the time lapsed since the previous beginMonitoring() call.
  12287. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  12288. */
  12289. endMonitoring(newFrame?: boolean): void;
  12290. private _fetchResult();
  12291. private _startMonitoringTime;
  12292. private _min;
  12293. private _max;
  12294. private _average;
  12295. private _current;
  12296. private _totalValueCount;
  12297. private _totalAccumulated;
  12298. private _lastSecAverage;
  12299. private _lastSecAccumulated;
  12300. private _lastSecTime;
  12301. private _lastSecValueCount;
  12302. }
  12303. /**
  12304. * Use this className as a decorator on a given class definition to add it a name.
  12305. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  12306. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  12307. * @param name
  12308. */
  12309. function className(name: string): (target: Object) => void;
  12310. /**
  12311. * An implementation of a loop for asynchronous functions.
  12312. */
  12313. class AsyncLoop {
  12314. iterations: number;
  12315. private _fn;
  12316. private _successCallback;
  12317. index: number;
  12318. private _done;
  12319. /**
  12320. * Constroctor.
  12321. * @param iterations the number of iterations.
  12322. * @param _fn the function to run each iteration
  12323. * @param _successCallback the callback that will be called upon succesful execution
  12324. * @param offset starting offset.
  12325. */
  12326. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  12327. /**
  12328. * Execute the next iteration. Must be called after the last iteration was finished.
  12329. */
  12330. executeNext(): void;
  12331. /**
  12332. * Break the loop and run the success callback.
  12333. */
  12334. breakLoop(): void;
  12335. /**
  12336. * Helper function
  12337. */
  12338. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  12339. /**
  12340. * A for-loop that will run a given number of iterations synchronous and the rest async.
  12341. * @param iterations total number of iterations
  12342. * @param syncedIterations number of synchronous iterations in each async iteration.
  12343. * @param fn the function to call each iteration.
  12344. * @param callback a success call back that will be called when iterating stops.
  12345. * @param breakFunction a break condition (optional)
  12346. * @param timeout timeout settings for the setTimeout function. default - 0.
  12347. * @constructor
  12348. */
  12349. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  12350. }
  12351. }
  12352. declare module BABYLON {
  12353. enum JoystickAxis {
  12354. X = 0,
  12355. Y = 1,
  12356. Z = 2,
  12357. }
  12358. class VirtualJoystick {
  12359. reverseLeftRight: boolean;
  12360. reverseUpDown: boolean;
  12361. deltaPosition: Vector3;
  12362. pressed: boolean;
  12363. private static _globalJoystickIndex;
  12364. private static vjCanvas;
  12365. private static vjCanvasContext;
  12366. private static vjCanvasWidth;
  12367. private static vjCanvasHeight;
  12368. private static halfWidth;
  12369. private static halfHeight;
  12370. private _action;
  12371. private _axisTargetedByLeftAndRight;
  12372. private _axisTargetedByUpAndDown;
  12373. private _joystickSensibility;
  12374. private _inversedSensibility;
  12375. private _rotationSpeed;
  12376. private _inverseRotationSpeed;
  12377. private _rotateOnAxisRelativeToMesh;
  12378. private _joystickPointerID;
  12379. private _joystickColor;
  12380. private _joystickPointerPos;
  12381. private _joystickPreviousPointerPos;
  12382. private _joystickPointerStartPos;
  12383. private _deltaJoystickVector;
  12384. private _leftJoystick;
  12385. private _joystickIndex;
  12386. private _touches;
  12387. private _onPointerDownHandlerRef;
  12388. private _onPointerMoveHandlerRef;
  12389. private _onPointerUpHandlerRef;
  12390. private _onPointerOutHandlerRef;
  12391. private _onResize;
  12392. constructor(leftJoystick?: boolean);
  12393. setJoystickSensibility(newJoystickSensibility: number): void;
  12394. private _onPointerDown(e);
  12395. private _onPointerMove(e);
  12396. private _onPointerUp(e);
  12397. /**
  12398. * Change the color of the virtual joystick
  12399. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  12400. */
  12401. setJoystickColor(newColor: string): void;
  12402. setActionOnTouch(action: () => any): void;
  12403. setAxisForLeftRight(axis: JoystickAxis): void;
  12404. setAxisForUpDown(axis: JoystickAxis): void;
  12405. private _clearCanvas();
  12406. private _drawVirtualJoystick();
  12407. releaseCanvas(): void;
  12408. }
  12409. }
  12410. declare module BABYLON {
  12411. class VRCameraMetrics {
  12412. hResolution: number;
  12413. vResolution: number;
  12414. hScreenSize: number;
  12415. vScreenSize: number;
  12416. vScreenCenter: number;
  12417. eyeToScreenDistance: number;
  12418. lensSeparationDistance: number;
  12419. interpupillaryDistance: number;
  12420. distortionK: number[];
  12421. chromaAbCorrection: number[];
  12422. postProcessScaleFactor: number;
  12423. lensCenterOffset: number;
  12424. compensateDistortion: boolean;
  12425. aspectRatio: number;
  12426. aspectRatioFov: number;
  12427. leftHMatrix: Matrix;
  12428. rightHMatrix: Matrix;
  12429. leftPreViewMatrix: Matrix;
  12430. rightPreViewMatrix: Matrix;
  12431. static GetDefault(): VRCameraMetrics;
  12432. }
  12433. }
  12434. declare module BABYLON {
  12435. class VRDeviceOrientationFreeCamera extends FreeCamera {
  12436. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean);
  12437. getTypeName(): string;
  12438. }
  12439. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  12440. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean);
  12441. getTypeName(): string;
  12442. }
  12443. }
  12444. declare var HMDVRDevice: any;
  12445. declare var PositionSensorVRDevice: any;
  12446. declare module BABYLON {
  12447. class WebVRFreeCamera extends FreeCamera {
  12448. _hmdDevice: any;
  12449. _sensorDevice: any;
  12450. private _cacheState;
  12451. _vrEnabled: boolean;
  12452. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean);
  12453. private _getWebVRDevices(devices);
  12454. _checkInputs(): void;
  12455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12456. detachControl(element: HTMLElement): void;
  12457. requestVRFullscreen(requestPointerlock: boolean): void;
  12458. getTypeName(): string;
  12459. }
  12460. }
  12461. declare module BABYLON {
  12462. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  12463. camera: ArcRotateCamera;
  12464. gamepad: Gamepad;
  12465. private _gamepads;
  12466. gamepadRotationSensibility: number;
  12467. gamepadMoveSensibility: number;
  12468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12469. detachControl(element: HTMLElement): void;
  12470. checkInputs(): void;
  12471. private _onNewGameConnected(gamepad);
  12472. getTypeName(): string;
  12473. getSimpleName(): string;
  12474. }
  12475. }
  12476. declare module BABYLON {
  12477. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  12478. camera: ArcRotateCamera;
  12479. private _keys;
  12480. private _onKeyDown;
  12481. private _onKeyUp;
  12482. private _onLostFocus;
  12483. keysUp: number[];
  12484. keysDown: number[];
  12485. keysLeft: number[];
  12486. keysRight: number[];
  12487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12488. detachControl(element: HTMLElement): void;
  12489. checkInputs(): void;
  12490. getTypeName(): string;
  12491. getSimpleName(): string;
  12492. }
  12493. }
  12494. declare module BABYLON {
  12495. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  12496. camera: ArcRotateCamera;
  12497. private _wheel;
  12498. private _observer;
  12499. wheelPrecision: number;
  12500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12501. detachControl(element: HTMLElement): void;
  12502. getTypeName(): string;
  12503. getSimpleName(): string;
  12504. }
  12505. }
  12506. declare module BABYLON {
  12507. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  12508. camera: ArcRotateCamera;
  12509. angularSensibilityX: number;
  12510. angularSensibilityY: number;
  12511. pinchPrecision: number;
  12512. panningSensibility: number;
  12513. private _isPanClick;
  12514. private _isCtrlPushed;
  12515. pinchInwards: boolean;
  12516. private _pointerInput;
  12517. private _observer;
  12518. private _onKeyDown;
  12519. private _onKeyUp;
  12520. private _onMouseMove;
  12521. private _onGestureStart;
  12522. private _onGesture;
  12523. private _MSGestureHandler;
  12524. private _onLostFocus;
  12525. private _onContextMenu;
  12526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12527. detachControl(element: HTMLElement): void;
  12528. getTypeName(): string;
  12529. getSimpleName(): string;
  12530. }
  12531. }
  12532. declare module BABYLON {
  12533. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  12534. camera: ArcRotateCamera;
  12535. alphaCorrection: number;
  12536. betaCorrection: number;
  12537. gammaCorrection: number;
  12538. private _alpha;
  12539. private _beta;
  12540. private _gamma;
  12541. private _dirty;
  12542. private _offsetOrientation;
  12543. private _deviceOrientationHandler;
  12544. constructor();
  12545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12546. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  12547. checkInputs(): void;
  12548. detachControl(element: HTMLElement): void;
  12549. getTypeName(): string;
  12550. getSimpleName(): string;
  12551. }
  12552. }
  12553. declare module BABYLON {
  12554. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  12555. private _camera;
  12556. private _screenOrientationAngle;
  12557. private _constantTranform;
  12558. private _screenQuaternion;
  12559. private _alpha;
  12560. private _beta;
  12561. private _gamma;
  12562. constructor();
  12563. camera: FreeCamera;
  12564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12565. private _orientationChanged;
  12566. private _deviceOrientation;
  12567. detachControl(element: HTMLElement): void;
  12568. checkInputs(): void;
  12569. getTypeName(): string;
  12570. getSimpleName(): string;
  12571. }
  12572. }
  12573. declare module BABYLON {
  12574. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  12575. camera: FreeCamera;
  12576. gamepad: Gamepad;
  12577. private _gamepads;
  12578. gamepadAngularSensibility: number;
  12579. gamepadMoveSensibility: number;
  12580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12581. detachControl(element: HTMLElement): void;
  12582. checkInputs(): void;
  12583. private _onNewGameConnected(gamepad);
  12584. getTypeName(): string;
  12585. getSimpleName(): string;
  12586. }
  12587. }
  12588. declare module BABYLON {
  12589. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  12590. camera: FreeCamera;
  12591. private _keys;
  12592. private _onKeyDown;
  12593. private _onKeyUp;
  12594. keysUp: number[];
  12595. keysDown: number[];
  12596. keysLeft: number[];
  12597. keysRight: number[];
  12598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12599. detachControl(element: HTMLElement): void;
  12600. checkInputs(): void;
  12601. getTypeName(): string;
  12602. _onLostFocus(e: FocusEvent): void;
  12603. getSimpleName(): string;
  12604. }
  12605. }
  12606. declare module BABYLON {
  12607. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12608. touchEnabled: boolean;
  12609. camera: FreeCamera;
  12610. angularSensibility: number;
  12611. private _pointerInput;
  12612. private _observer;
  12613. private previousPosition;
  12614. constructor(touchEnabled?: boolean);
  12615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12616. detachControl(element: HTMLElement): void;
  12617. getTypeName(): string;
  12618. getSimpleName(): string;
  12619. }
  12620. }
  12621. declare module BABYLON {
  12622. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12623. camera: FreeCamera;
  12624. private _offsetX;
  12625. private _offsetY;
  12626. private _pointerCount;
  12627. private _pointerPressed;
  12628. private _pointerInput;
  12629. private _observer;
  12630. private _onLostFocus;
  12631. touchAngularSensibility: number;
  12632. touchMoveSensibility: number;
  12633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12634. detachControl(element: HTMLElement): void;
  12635. checkInputs(): void;
  12636. getTypeName(): string;
  12637. getSimpleName(): string;
  12638. }
  12639. }
  12640. declare module BABYLON {
  12641. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  12642. camera: FreeCamera;
  12643. private _leftjoystick;
  12644. private _rightjoystick;
  12645. getLeftJoystick(): VirtualJoystick;
  12646. getRightJoystick(): VirtualJoystick;
  12647. checkInputs(): void;
  12648. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12649. detachControl(element: HTMLElement): void;
  12650. getTypeName(): string;
  12651. getSimpleName(): string;
  12652. }
  12653. }
  12654. declare module BABYLON {
  12655. class FreeCameraVRDeviceOrientationInput implements ICameraInput<FreeCamera> {
  12656. camera: FreeCamera;
  12657. alphaCorrection: number;
  12658. betaCorrection: number;
  12659. gammaCorrection: number;
  12660. private _alpha;
  12661. private _beta;
  12662. private _gamma;
  12663. private _dirty;
  12664. private _offsetOrientation;
  12665. private _deviceOrientationHandler;
  12666. constructor();
  12667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12668. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  12669. checkInputs(): void;
  12670. detachControl(element: HTMLElement): void;
  12671. getTypeName(): string;
  12672. getSimpleName(): string;
  12673. }
  12674. }
  12675. declare module BABYLON {
  12676. interface IOctreeContainer<T> {
  12677. blocks: Array<OctreeBlock<T>>;
  12678. }
  12679. class Octree<T> {
  12680. maxDepth: number;
  12681. blocks: Array<OctreeBlock<T>>;
  12682. dynamicContent: T[];
  12683. private _maxBlockCapacity;
  12684. private _selectionContent;
  12685. private _creationFunc;
  12686. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  12687. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  12688. addMesh(entry: T): void;
  12689. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  12690. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  12691. intersectsRay(ray: Ray): SmartArray<T>;
  12692. 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;
  12693. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  12694. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  12695. }
  12696. }
  12697. declare module BABYLON {
  12698. class OctreeBlock<T> {
  12699. entries: T[];
  12700. blocks: Array<OctreeBlock<T>>;
  12701. private _depth;
  12702. private _maxDepth;
  12703. private _capacity;
  12704. private _minPoint;
  12705. private _maxPoint;
  12706. private _boundingVectors;
  12707. private _creationFunc;
  12708. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  12709. capacity: number;
  12710. minPoint: Vector3;
  12711. maxPoint: Vector3;
  12712. addEntry(entry: T): void;
  12713. addEntries(entries: T[]): void;
  12714. select(frustumPlanes: Plane[], selection: SmartArray<T>, allowDuplicate?: boolean): void;
  12715. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray<T>, allowDuplicate?: boolean): void;
  12716. intersectsRay(ray: Ray, selection: SmartArray<T>): void;
  12717. createInnerBlocks(): void;
  12718. }
  12719. }
  12720. declare module BABYLON {
  12721. class ShadowGenerator {
  12722. private static _FILTER_NONE;
  12723. private static _FILTER_VARIANCESHADOWMAP;
  12724. private static _FILTER_POISSONSAMPLING;
  12725. private static _FILTER_BLURVARIANCESHADOWMAP;
  12726. static FILTER_NONE: number;
  12727. static FILTER_VARIANCESHADOWMAP: number;
  12728. static FILTER_POISSONSAMPLING: number;
  12729. static FILTER_BLURVARIANCESHADOWMAP: number;
  12730. private _filter;
  12731. blurScale: number;
  12732. private _blurBoxOffset;
  12733. private _bias;
  12734. private _lightDirection;
  12735. forceBackFacesOnly: boolean;
  12736. bias: number;
  12737. blurBoxOffset: number;
  12738. filter: number;
  12739. useVarianceShadowMap: boolean;
  12740. usePoissonSampling: boolean;
  12741. useBlurVarianceShadowMap: boolean;
  12742. private _light;
  12743. private _scene;
  12744. private _shadowMap;
  12745. private _shadowMap2;
  12746. private _darkness;
  12747. private _transparencyShadow;
  12748. private _effect;
  12749. private _viewMatrix;
  12750. private _projectionMatrix;
  12751. private _transformMatrix;
  12752. private _worldViewProjection;
  12753. private _cachedPosition;
  12754. private _cachedDirection;
  12755. private _cachedDefines;
  12756. private _currentRenderID;
  12757. private _downSamplePostprocess;
  12758. private _boxBlurPostprocess;
  12759. private _mapSize;
  12760. private _currentFaceIndex;
  12761. private _currentFaceIndexCache;
  12762. constructor(mapSize: number, light: IShadowLight);
  12763. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  12764. getShadowMap(): RenderTargetTexture;
  12765. getShadowMapForRendering(): RenderTargetTexture;
  12766. getLight(): IShadowLight;
  12767. getTransformMatrix(): Matrix;
  12768. getDarkness(): number;
  12769. setDarkness(darkness: number): void;
  12770. setTransparencyShadow(hasShadow: boolean): void;
  12771. private _packHalf(depth);
  12772. dispose(): void;
  12773. serialize(): any;
  12774. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  12775. }
  12776. }
  12777. declare module BABYLON.Internals {
  12778. }
  12779. declare module BABYLON {
  12780. class BaseTexture {
  12781. name: string;
  12782. hasAlpha: boolean;
  12783. getAlphaFromRGB: boolean;
  12784. level: number;
  12785. coordinatesIndex: number;
  12786. coordinatesMode: number;
  12787. wrapU: number;
  12788. wrapV: number;
  12789. anisotropicFilteringLevel: number;
  12790. isCube: boolean;
  12791. isRenderTarget: boolean;
  12792. toString(): string;
  12793. animations: Animation[];
  12794. /**
  12795. * An event triggered when the texture is disposed.
  12796. * @type {BABYLON.Observable}
  12797. */
  12798. onDisposeObservable: Observable<BaseTexture>;
  12799. private _onDisposeObserver;
  12800. onDispose: () => void;
  12801. delayLoadState: number;
  12802. _cachedAnisotropicFilteringLevel: number;
  12803. private _scene;
  12804. _texture: WebGLTexture;
  12805. constructor(scene: Scene);
  12806. getScene(): Scene;
  12807. getTextureMatrix(): Matrix;
  12808. getReflectionTextureMatrix(): Matrix;
  12809. getInternalTexture(): WebGLTexture;
  12810. isReady(): boolean;
  12811. getSize(): ISize;
  12812. getBaseSize(): ISize;
  12813. scale(ratio: number): void;
  12814. canRescale: boolean;
  12815. _removeFromCache(url: string, noMipmap: boolean): void;
  12816. _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture;
  12817. delayLoad(): void;
  12818. clone(): BaseTexture;
  12819. releaseInternalTexture(): void;
  12820. dispose(): void;
  12821. serialize(): any;
  12822. }
  12823. }
  12824. declare module BABYLON {
  12825. /**
  12826. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  12827. * It can help converting any input color in a desired output one. This can then be used to create effects
  12828. * from sepia, black and white to sixties or futuristic rendering...
  12829. *
  12830. * The only supported format is currently 3dl.
  12831. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  12832. */
  12833. class ColorGradingTexture extends BaseTexture {
  12834. /**
  12835. * The current internal texture size.
  12836. */
  12837. private _size;
  12838. /**
  12839. * The current texture matrix. (will always be identity in color grading texture)
  12840. */
  12841. private _textureMatrix;
  12842. /**
  12843. * The texture URL.
  12844. */
  12845. url: string;
  12846. /**
  12847. * Empty line regex stored for GC.
  12848. */
  12849. private static _noneEmptyLineRegex;
  12850. /**
  12851. * Instantiates a ColorGradingTexture from the following parameters.
  12852. *
  12853. * @param url The location of the color gradind data (currently only supporting 3dl)
  12854. * @param scene The scene the texture will be used in
  12855. */
  12856. constructor(url: string, scene: Scene);
  12857. /**
  12858. * Returns the texture matrix used in most of the material.
  12859. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  12860. */
  12861. getTextureMatrix(): Matrix;
  12862. /**
  12863. * Occurs when the file being loaded is a .3dl LUT file.
  12864. */
  12865. private load3dlTexture();
  12866. /**
  12867. * Starts the loading process of the texture.
  12868. */
  12869. private loadTexture();
  12870. /**
  12871. * Clones the color gradind texture.
  12872. */
  12873. clone(): ColorGradingTexture;
  12874. /**
  12875. * Called during delayed load for textures.
  12876. */
  12877. delayLoad(): void;
  12878. /**
  12879. * Parses a color grading texture serialized by Babylon.
  12880. * @param parsedTexture The texture information being parsedTexture
  12881. * @param scene The scene to load the texture in
  12882. * @param rootUrl The root url of the data assets to load
  12883. * @return A color gradind texture
  12884. */
  12885. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): ColorGradingTexture;
  12886. /**
  12887. * Serializes the LUT texture to json format.
  12888. */
  12889. serialize(): any;
  12890. }
  12891. }
  12892. declare module BABYLON {
  12893. class CubeTexture extends BaseTexture {
  12894. url: string;
  12895. coordinatesMode: number;
  12896. private _noMipmap;
  12897. private _files;
  12898. private _extensions;
  12899. private _textureMatrix;
  12900. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  12901. constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean, files?: string[]);
  12902. delayLoad(): void;
  12903. getReflectionTextureMatrix(): Matrix;
  12904. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  12905. clone(): CubeTexture;
  12906. }
  12907. }
  12908. declare module BABYLON {
  12909. class DynamicTexture extends Texture {
  12910. private _generateMipMaps;
  12911. private _canvas;
  12912. private _context;
  12913. constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number);
  12914. canRescale: boolean;
  12915. scale(ratio: number): void;
  12916. getContext(): CanvasRenderingContext2D;
  12917. clear(): void;
  12918. update(invertY?: boolean): void;
  12919. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  12920. clone(): DynamicTexture;
  12921. }
  12922. }
  12923. declare module BABYLON {
  12924. /**
  12925. * This class given information about a given character.
  12926. */
  12927. class CharInfo {
  12928. /**
  12929. * The normalized ([0;1]) top/left position of the character in the texture
  12930. */
  12931. topLeftUV: Vector2;
  12932. /**
  12933. * The normalized ([0;1]) right/bottom position of the character in the texture
  12934. */
  12935. bottomRightUV: Vector2;
  12936. charWidth: number;
  12937. }
  12938. class FontTexture extends Texture {
  12939. private _canvas;
  12940. private _context;
  12941. private _lineHeight;
  12942. private _lineHeightSuper;
  12943. private _offset;
  12944. private _currentFreePosition;
  12945. private _charInfos;
  12946. private _curCharCount;
  12947. private _lastUpdateCharCount;
  12948. private _spaceWidth;
  12949. private _spaceWidthSuper;
  12950. private _usedCounter;
  12951. private _superSample;
  12952. isSuperSampled: boolean;
  12953. spaceWidth: number;
  12954. lineHeight: number;
  12955. static GetCachedFontTexture(scene: Scene, fontName: string, supersample?: boolean): FontTexture;
  12956. static ReleaseCachedFontTexture(scene: Scene, fontName: string, supersample?: boolean): void;
  12957. /**
  12958. * Create a new instance of the FontTexture class
  12959. * @param name the name of the texture
  12960. * @param font the font to use, use the W3C CSS notation
  12961. * @param scene the scene that owns the texture
  12962. * @param maxCharCount the approximative maximum count of characters that could fit in the texture. This is an approximation because most of the fonts are proportional (each char has its own Width). The 'W' character's width is used to compute the size of the texture based on the given maxCharCount
  12963. * @param samplingMode the texture sampling mode
  12964. * @param superSample if true the FontTexture will be created with a font of a size twice bigger than the given one but all properties (lineHeight, charWidth, etc.) will be according to the original size. This is made to improve the text quality.
  12965. */
  12966. constructor(name: string, font: string, scene: Scene, maxCharCount?: number, samplingMode?: number, superSample?: boolean);
  12967. /**
  12968. * Make sure the given char is present in the font map.
  12969. * @param char the character to get or add
  12970. * @return the CharInfo instance corresponding to the given character
  12971. */
  12972. getChar(char: string): CharInfo;
  12973. measureText(text: string, tabulationSize?: number): Size;
  12974. private getSuperSampleFont(font);
  12975. private getFontHeight(font);
  12976. canRescale: boolean;
  12977. getContext(): CanvasRenderingContext2D;
  12978. /**
  12979. * Call this method when you've call getChar() at least one time, this will update the texture if needed.
  12980. * Don't be afraid to call it, if no new character was added, this method simply does nothing.
  12981. */
  12982. update(): void;
  12983. clone(): FontTexture;
  12984. }
  12985. }
  12986. declare module BABYLON {
  12987. /**
  12988. * This represents a texture coming from an HDR input.
  12989. *
  12990. * The only supported format is currently panorama picture stored in RGBE format.
  12991. * Example of such files can be found on HDRLib: http://hdrlib.com/
  12992. */
  12993. class HDRCubeTexture extends BaseTexture {
  12994. private static _facesMapping;
  12995. private _useInGammaSpace;
  12996. private _generateHarmonics;
  12997. private _noMipmap;
  12998. private _extensions;
  12999. private _textureMatrix;
  13000. private _size;
  13001. private _usePMREMGenerator;
  13002. private _isBABYLONPreprocessed;
  13003. /**
  13004. * The texture URL.
  13005. */
  13006. url: string;
  13007. /**
  13008. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  13009. */
  13010. coordinatesMode: number;
  13011. /**
  13012. * The spherical polynomial data extracted from the texture.
  13013. */
  13014. sphericalPolynomial: SphericalPolynomial;
  13015. /**
  13016. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  13017. * This is usefull at run time to apply the good shader.
  13018. */
  13019. isPMREM: boolean;
  13020. /**
  13021. * Instantiates an HDRTexture from the following parameters.
  13022. *
  13023. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  13024. * @param scene The scene the texture will be used in
  13025. * @param size The cubemap desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  13026. * @param noMipmap Forces to not generate the mipmap if true
  13027. * @param generateHarmonics Specifies wether you want to extract the polynomial harmonics during the generation process
  13028. * @param useInGammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  13029. * @param usePMREMGenerator Specifies wether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  13030. */
  13031. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean);
  13032. /**
  13033. * Occurs when the file is a preprocessed .babylon.hdr file.
  13034. */
  13035. private loadBabylonTexture();
  13036. /**
  13037. * Occurs when the file is raw .hdr file.
  13038. */
  13039. private loadHDRTexture();
  13040. /**
  13041. * Starts the loading process of the texture.
  13042. */
  13043. private loadTexture();
  13044. clone(): HDRCubeTexture;
  13045. delayLoad(): void;
  13046. getReflectionTextureMatrix(): Matrix;
  13047. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): HDRCubeTexture;
  13048. serialize(): any;
  13049. /**
  13050. * Saves as a file the data contained in the texture in a binary format.
  13051. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  13052. * as the spherical used in the lighting.
  13053. * @param url The HDR file url.
  13054. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  13055. * @param onError Method called if any error happens during download.
  13056. * @return The packed binary data.
  13057. */
  13058. static generateBabylonHDROnDisk(url: string, size: number, onError?: (() => void)): void;
  13059. /**
  13060. * Serializes the data contained in the texture in a binary format.
  13061. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  13062. * as the spherical used in the lighting.
  13063. * @param url The HDR file url.
  13064. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  13065. * @param onError Method called if any error happens during download.
  13066. * @return The packed binary data.
  13067. */
  13068. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer) => void), onError?: (() => void)): void;
  13069. }
  13070. }
  13071. declare module BABYLON {
  13072. class MapTexture extends Texture {
  13073. private _rectPackingMap;
  13074. private _size;
  13075. private _replacedViewport;
  13076. constructor(name: string, scene: Scene, size: ISize, samplingMode?: number, useMipMap?: boolean);
  13077. /**
  13078. * Allocate a rectangle of a given size in the texture map
  13079. * @param size the size of the rectangle to allocation
  13080. * @return the PackedRect instance corresponding to the allocated rect or null is there was not enough space to allocate it.
  13081. */
  13082. allocateRect(size: Size): PackedRect;
  13083. /**
  13084. * Free a given rectangle from the texture map
  13085. * @param rectInfo the instance corresponding to the rect to free.
  13086. */
  13087. freeRect(rectInfo: PackedRect): void;
  13088. /**
  13089. * Return the available space in the range of [O;1]. 0 being not space left at all, 1 being an empty texture map.
  13090. * This is the cumulated space, not the biggest available surface. Due to fragmentation you may not allocate a rect corresponding to this surface.
  13091. * @returns {}
  13092. */
  13093. freeSpace: number;
  13094. /**
  13095. * Bind the texture to the rendering engine to render in the zone of a given rectangle.
  13096. * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect.
  13097. * Don't forget to call unbindTexture when you're done rendering
  13098. * @param rect the zone to render to
  13099. * @param clear true to clear the portion's color/depth data
  13100. */
  13101. bindTextureForRect(rect: PackedRect, clear: boolean): void;
  13102. /**
  13103. * Bind the texture to the rendering engine to render in the zone of the given size at the given position.
  13104. * Use this method when you want to render into the texture map with a clipspace set to the location and size of the given rect.
  13105. * Don't forget to call unbindTexture when you're done rendering
  13106. * @param pos the position into the texture
  13107. * @param size the portion to fit the clip space to
  13108. * @param clear true to clear the portion's color/depth data
  13109. */
  13110. bindTextureForPosSize(pos: Vector2, size: Size, clear: boolean): void;
  13111. /**
  13112. * Unbind the texture map from the rendering engine.
  13113. * Call this method when you're done rendering. A previous call to bindTextureForRect has to be made.
  13114. * @param dumpForDebug if set to true the content of the texture map will be dumped to a picture file that will be sent to the internet browser.
  13115. */
  13116. unbindTexture(dumpForDebug?: boolean): void;
  13117. canRescale: boolean;
  13118. clone(): MapTexture;
  13119. }
  13120. }
  13121. declare module BABYLON {
  13122. class MirrorTexture extends RenderTargetTexture {
  13123. mirrorPlane: Plane;
  13124. private _transformMatrix;
  13125. private _mirrorMatrix;
  13126. private _savedViewMatrix;
  13127. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  13128. clone(): MirrorTexture;
  13129. serialize(): any;
  13130. }
  13131. }
  13132. declare module BABYLON {
  13133. class RawTexture extends Texture {
  13134. format: number;
  13135. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  13136. update(data: ArrayBufferView): void;
  13137. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13138. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13139. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13140. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13141. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13142. }
  13143. }
  13144. declare module BABYLON {
  13145. /**
  13146. * Creates a refraction texture used by refraction channel of the standard material.
  13147. * @param name the texture name
  13148. * @param size size of the underlying texture
  13149. * @param scene root scene
  13150. */
  13151. class RefractionTexture extends RenderTargetTexture {
  13152. refractionPlane: Plane;
  13153. depth: number;
  13154. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  13155. clone(): RefractionTexture;
  13156. serialize(): any;
  13157. }
  13158. }
  13159. declare module BABYLON {
  13160. class RenderTargetTexture extends Texture {
  13161. isCube: boolean;
  13162. static _REFRESHRATE_RENDER_ONCE: number;
  13163. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  13164. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  13165. static REFRESHRATE_RENDER_ONCE: number;
  13166. static REFRESHRATE_RENDER_ONEVERYFRAME: number;
  13167. static REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  13168. /**
  13169. * Use this predicate to dynamically define the list of mesh you want to render.
  13170. * If set, the renderList property will be overwritten.
  13171. */
  13172. renderListPredicate: (AbstractMesh) => boolean;
  13173. /**
  13174. * Use this list to define the list of mesh you want to render.
  13175. */
  13176. renderList: AbstractMesh[];
  13177. renderParticles: boolean;
  13178. renderSprites: boolean;
  13179. coordinatesMode: number;
  13180. activeCamera: Camera;
  13181. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  13182. useCameraPostProcesses: boolean;
  13183. /**
  13184. * An event triggered when the texture is unbind.
  13185. * @type {BABYLON.Observable}
  13186. */
  13187. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  13188. private _onAfterUnbindObserver;
  13189. onAfterUnbind: () => void;
  13190. /**
  13191. * An event triggered before rendering the texture
  13192. * @type {BABYLON.Observable}
  13193. */
  13194. onBeforeRenderObservable: Observable<number>;
  13195. private _onBeforeRenderObserver;
  13196. onBeforeRender: (faceIndex: number) => void;
  13197. /**
  13198. * An event triggered after rendering the texture
  13199. * @type {BABYLON.Observable}
  13200. */
  13201. onAfterRenderObservable: Observable<number>;
  13202. private _onAfterRenderObserver;
  13203. onAfterRender: (faceIndex: number) => void;
  13204. /**
  13205. * An event triggered after the texture clear
  13206. * @type {BABYLON.Observable}
  13207. */
  13208. onClearObservable: Observable<Engine>;
  13209. private _onClearObserver;
  13210. onClear: (Engine: Engine) => void;
  13211. private _size;
  13212. _generateMipMaps: boolean;
  13213. private _renderingManager;
  13214. _waitingRenderList: string[];
  13215. private _doNotChangeAspectRatio;
  13216. private _currentRefreshId;
  13217. private _refreshRate;
  13218. private _textureMatrix;
  13219. constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number);
  13220. resetRefreshCounter(): void;
  13221. refreshRate: number;
  13222. _shouldRender(): boolean;
  13223. isReady(): boolean;
  13224. getRenderSize(): number;
  13225. canRescale: boolean;
  13226. scale(ratio: number): void;
  13227. getReflectionTextureMatrix(): Matrix;
  13228. resize(size: any, generateMipMaps?: boolean): void;
  13229. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  13230. renderToTarget(faceIndex: number, currentRenderList: AbstractMesh[], useCameraPostProcess: boolean, dumpForDebug: boolean): void;
  13231. clone(): RenderTargetTexture;
  13232. serialize(): any;
  13233. }
  13234. }
  13235. declare module BABYLON {
  13236. class Texture extends BaseTexture {
  13237. static NEAREST_SAMPLINGMODE: number;
  13238. static BILINEAR_SAMPLINGMODE: number;
  13239. static TRILINEAR_SAMPLINGMODE: number;
  13240. static EXPLICIT_MODE: number;
  13241. static SPHERICAL_MODE: number;
  13242. static PLANAR_MODE: number;
  13243. static CUBIC_MODE: number;
  13244. static PROJECTION_MODE: number;
  13245. static SKYBOX_MODE: number;
  13246. static INVCUBIC_MODE: number;
  13247. static EQUIRECTANGULAR_MODE: number;
  13248. static FIXED_EQUIRECTANGULAR_MODE: number;
  13249. static CLAMP_ADDRESSMODE: number;
  13250. static WRAP_ADDRESSMODE: number;
  13251. static MIRROR_ADDRESSMODE: number;
  13252. url: string;
  13253. uOffset: number;
  13254. vOffset: number;
  13255. uScale: number;
  13256. vScale: number;
  13257. uAng: number;
  13258. vAng: number;
  13259. wAng: number;
  13260. noMipmap: boolean;
  13261. private _noMipmap;
  13262. _invertY: boolean;
  13263. private _rowGenerationMatrix;
  13264. private _cachedTextureMatrix;
  13265. private _projectionModeMatrix;
  13266. private _t0;
  13267. private _t1;
  13268. private _t2;
  13269. private _cachedUOffset;
  13270. private _cachedVOffset;
  13271. private _cachedUScale;
  13272. private _cachedVScale;
  13273. private _cachedUAng;
  13274. private _cachedVAng;
  13275. private _cachedWAng;
  13276. private _cachedCoordinatesMode;
  13277. _samplingMode: number;
  13278. private _buffer;
  13279. private _deleteBuffer;
  13280. private _delayedOnLoad;
  13281. private _delayedOnError;
  13282. constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean);
  13283. delayLoad(): void;
  13284. updateSamplingMode(samplingMode: number): void;
  13285. private _prepareRowForTextureGeneration(x, y, z, t);
  13286. getTextureMatrix(): Matrix;
  13287. getReflectionTextureMatrix(): Matrix;
  13288. clone(): Texture;
  13289. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void): Texture;
  13290. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): BaseTexture;
  13291. }
  13292. }
  13293. declare module BABYLON {
  13294. class VideoTexture extends Texture {
  13295. video: HTMLVideoElement;
  13296. private _autoLaunch;
  13297. private _lastUpdate;
  13298. private _generateMipMaps;
  13299. /**
  13300. * Creates a video texture.
  13301. * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing
  13302. * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element.
  13303. * @param {BABYLON.Scene} scene is obviously the current scene.
  13304. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  13305. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  13306. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  13307. */
  13308. constructor(name: string, urlsOrVideo: string[] | HTMLVideoElement, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  13309. private _createTexture();
  13310. update(): boolean;
  13311. }
  13312. }
  13313. declare module BABYLON {
  13314. class CannonJSPlugin implements IPhysicsEnginePlugin {
  13315. private _useDeltaForWorldStep;
  13316. world: any;
  13317. name: string;
  13318. private _physicsMaterials;
  13319. private _fixedTimeStep;
  13320. private _currentCollisionGroup;
  13321. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  13322. setGravity(gravity: Vector3): void;
  13323. setTimeStep(timeStep: number): void;
  13324. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13325. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13326. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13327. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13328. private _processChildMeshes(mainImpostor);
  13329. removePhysicsBody(impostor: PhysicsImpostor): void;
  13330. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  13331. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  13332. private _addMaterial(name, friction, restitution);
  13333. private _checkWithEpsilon(value);
  13334. private _createShape(impostor);
  13335. private _createHeightmap(object, pointDepth?);
  13336. private _minus90X;
  13337. private _plus90X;
  13338. private _tmpPosition;
  13339. private _tmpQuaternion;
  13340. private _tmpDeltaPosition;
  13341. private _tmpDeltaRotation;
  13342. private _tmpUnityRotation;
  13343. private _updatePhysicsBodyTransformation(impostor);
  13344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13346. isSupported(): boolean;
  13347. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  13348. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  13349. getLinearVelocity(impostor: PhysicsImpostor): Vector3;
  13350. getAngularVelocity(impostor: PhysicsImpostor): Vector3;
  13351. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13352. sleepBody(impostor: PhysicsImpostor): void;
  13353. wakeUpBody(impostor: PhysicsImpostor): void;
  13354. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13355. private enableMotor(joint, motorIndex?);
  13356. private disableMotor(joint, motorIndex?);
  13357. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  13358. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  13359. dispose(): void;
  13360. }
  13361. }
  13362. declare module BABYLON {
  13363. class OimoJSPlugin {
  13364. world: any;
  13365. name: string;
  13366. constructor(iterations?: number);
  13367. setGravity(gravity: Vector3): void;
  13368. setTimeStep(timeStep: number): void;
  13369. private _tmpImpostorsArray;
  13370. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13371. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13372. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13373. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13374. private _tmpPositionVector;
  13375. removePhysicsBody(impostor: PhysicsImpostor): void;
  13376. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  13377. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  13378. isSupported(): boolean;
  13379. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13380. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13381. private _getLastShape(body);
  13382. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  13383. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  13384. getLinearVelocity(impostor: PhysicsImpostor): Vector3;
  13385. getAngularVelocity(impostor: PhysicsImpostor): Vector3;
  13386. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13387. sleepBody(impostor: PhysicsImpostor): void;
  13388. wakeUpBody(impostor: PhysicsImpostor): void;
  13389. updateDistanceJoint(joint: IMotorEnabledJoint, maxDistance: number, minDistance?: number): void;
  13390. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13391. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13392. dispose(): void;
  13393. }
  13394. }
  13395. declare module BABYLON {
  13396. class PostProcessRenderEffect {
  13397. private _engine;
  13398. private _postProcesses;
  13399. private _getPostProcess;
  13400. private _singleInstance;
  13401. private _cameras;
  13402. private _indicesForCamera;
  13403. private _renderPasses;
  13404. private _renderEffectAsPasses;
  13405. _name: string;
  13406. applyParameters: (postProcess: PostProcess) => void;
  13407. constructor(engine: Engine, name: string, getPostProcess: () => PostProcess, singleInstance?: boolean);
  13408. isSupported: boolean;
  13409. _update(): void;
  13410. addPass(renderPass: PostProcessRenderPass): void;
  13411. removePass(renderPass: PostProcessRenderPass): void;
  13412. addRenderEffectAsPass(renderEffect: PostProcessRenderEffect): void;
  13413. getPass(passName: string): void;
  13414. emptyPasses(): void;
  13415. _attachCameras(cameras: Camera): any;
  13416. _attachCameras(cameras: Camera[]): any;
  13417. _detachCameras(cameras: Camera): any;
  13418. _detachCameras(cameras: Camera[]): any;
  13419. _enable(cameras: Camera): any;
  13420. _enable(cameras: Camera[]): any;
  13421. _disable(cameras: Camera): any;
  13422. _disable(cameras: Camera[]): any;
  13423. getPostProcess(camera?: Camera): PostProcess;
  13424. private _linkParameters();
  13425. private _linkTextures(effect);
  13426. }
  13427. }
  13428. declare module BABYLON {
  13429. class PostProcessRenderPass {
  13430. private _enabled;
  13431. private _renderList;
  13432. private _renderTexture;
  13433. private _scene;
  13434. private _refCount;
  13435. _name: string;
  13436. constructor(scene: Scene, name: string, size: number, renderList: Mesh[], beforeRender: () => void, afterRender: () => void);
  13437. _incRefCount(): number;
  13438. _decRefCount(): number;
  13439. _update(): void;
  13440. setRenderList(renderList: Mesh[]): void;
  13441. getRenderTexture(): RenderTargetTexture;
  13442. }
  13443. }
  13444. declare module BABYLON {
  13445. class PostProcessRenderPipeline {
  13446. private _engine;
  13447. private _renderEffects;
  13448. private _renderEffectsForIsolatedPass;
  13449. private _cameras;
  13450. _name: string;
  13451. private static PASS_EFFECT_NAME;
  13452. private static PASS_SAMPLER_NAME;
  13453. constructor(engine: Engine, name: string);
  13454. isSupported: boolean;
  13455. addEffect(renderEffect: PostProcessRenderEffect): void;
  13456. _enableEffect(renderEffectName: string, cameras: Camera): any;
  13457. _enableEffect(renderEffectName: string, cameras: Camera[]): any;
  13458. _disableEffect(renderEffectName: string, cameras: Camera): any;
  13459. _disableEffect(renderEffectName: string, cameras: Camera[]): any;
  13460. _attachCameras(cameras: Camera, unique: boolean): any;
  13461. _attachCameras(cameras: Camera[], unique: boolean): any;
  13462. _detachCameras(cameras: Camera): any;
  13463. _detachCameras(cameras: Camera[]): any;
  13464. _enableDisplayOnlyPass(passName: any, cameras: Camera): any;
  13465. _enableDisplayOnlyPass(passName: any, cameras: Camera[]): any;
  13466. _disableDisplayOnlyPass(cameras: Camera): any;
  13467. _disableDisplayOnlyPass(cameras: Camera[]): any;
  13468. _update(): void;
  13469. dispose(): void;
  13470. }
  13471. }
  13472. declare module BABYLON {
  13473. class PostProcessRenderPipelineManager {
  13474. private _renderPipelines;
  13475. constructor();
  13476. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  13477. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): any;
  13478. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): any;
  13479. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): any;
  13480. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): any;
  13481. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  13482. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  13483. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  13484. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  13485. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera): any;
  13486. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera[]): any;
  13487. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera): any;
  13488. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera[]): any;
  13489. update(): void;
  13490. }
  13491. }
  13492. declare module BABYLON.Internals {
  13493. /**
  13494. * Helper class dealing with the extraction of spherical polynomial dataArray
  13495. * from a cube map.
  13496. */
  13497. class CubeMapToSphericalPolynomialTools {
  13498. private static FileFaces;
  13499. /**
  13500. * Converts a cubemap to the according Spherical Polynomial data.
  13501. * This extracts the first 3 orders only as they are the only one used in the lighting.
  13502. *
  13503. * @param cubeInfo The Cube map to extract the information from.
  13504. * @return The Spherical Polynomial data.
  13505. */
  13506. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  13507. }
  13508. }
  13509. declare module BABYLON.Internals {
  13510. /**
  13511. * Header information of HDR texture files.
  13512. */
  13513. interface HDRInfo {
  13514. /**
  13515. * The height of the texture in pixels.
  13516. */
  13517. height: number;
  13518. /**
  13519. * The width of the texture in pixels.
  13520. */
  13521. width: number;
  13522. /**
  13523. * The index of the beginning of the data in the binary file.
  13524. */
  13525. dataPosition: number;
  13526. }
  13527. /**
  13528. * This groups tools to convert HDR texture to native colors array.
  13529. */
  13530. class HDRTools {
  13531. private static Ldexp(mantissa, exponent);
  13532. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  13533. private static readStringLine(uint8array, startIndex);
  13534. /**
  13535. * Reads header information from an RGBE texture stored in a native array.
  13536. * More information on this format are available here:
  13537. * https://en.wikipedia.org/wiki/RGBE_image_format
  13538. *
  13539. * @param uint8array The binary file stored in native array.
  13540. * @return The header information.
  13541. */
  13542. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  13543. /**
  13544. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  13545. * This RGBE texture needs to store the information as a panorama.
  13546. *
  13547. * More information on this format are available here:
  13548. * https://en.wikipedia.org/wiki/RGBE_image_format
  13549. *
  13550. * @param buffer The binary file stored in an array buffer.
  13551. * @param size The expected size of the extracted cubemap.
  13552. * @return The Cube Map information.
  13553. */
  13554. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  13555. /**
  13556. * Returns the pixels data extracted from an RGBE texture.
  13557. * This pixels will be stored left to right up to down in the R G B order in one array.
  13558. *
  13559. * More information on this format are available here:
  13560. * https://en.wikipedia.org/wiki/RGBE_image_format
  13561. *
  13562. * @param uint8array The binary file stored in an array buffer.
  13563. * @param hdrInfo The header information of the file.
  13564. * @return The pixels data in RGB right to left up to down order.
  13565. */
  13566. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  13567. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  13568. }
  13569. }
  13570. declare module BABYLON.Internals {
  13571. /**
  13572. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  13573. */
  13574. interface CubeMapInfo {
  13575. /**
  13576. * The pixel array for the front face.
  13577. * This is stored in RGB, left to right, up to down format.
  13578. */
  13579. front: Float32Array;
  13580. /**
  13581. * The pixel array for the back face.
  13582. * This is stored in RGB, left to right, up to down format.
  13583. */
  13584. back: Float32Array;
  13585. /**
  13586. * The pixel array for the left face.
  13587. * This is stored in RGB, left to right, up to down format.
  13588. */
  13589. left: Float32Array;
  13590. /**
  13591. * The pixel array for the right face.
  13592. * This is stored in RGB, left to right, up to down format.
  13593. */
  13594. right: Float32Array;
  13595. /**
  13596. * The pixel array for the up face.
  13597. * This is stored in RGB, left to right, up to down format.
  13598. */
  13599. up: Float32Array;
  13600. /**
  13601. * The pixel array for the down face.
  13602. * This is stored in RGB, left to right, up to down format.
  13603. */
  13604. down: Float32Array;
  13605. /**
  13606. * The size of the cubemap stored.
  13607. *
  13608. * Each faces will be size * size pixels.
  13609. */
  13610. size: number;
  13611. }
  13612. /**
  13613. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  13614. */
  13615. class PanoramaToCubeMapTools {
  13616. private static FACE_FRONT;
  13617. private static FACE_BACK;
  13618. private static FACE_RIGHT;
  13619. private static FACE_LEFT;
  13620. private static FACE_DOWN;
  13621. private static FACE_UP;
  13622. /**
  13623. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  13624. *
  13625. * @param float32Array The source data.
  13626. * @param inputWidth The width of the input panorama.
  13627. * @param inputhHeight The height of the input panorama.
  13628. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  13629. * @return The cubemap data
  13630. */
  13631. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  13632. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  13633. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  13634. }
  13635. }
  13636. declare namespace BABYLON.Internals {
  13637. /**
  13638. * Helper class to PreProcess a cubemap in order to generate mipmap according to the level of blur
  13639. * required by the glossinees of a material.
  13640. *
  13641. * This only supports the cosine drop power as well as Warp fixup generation method.
  13642. *
  13643. * This is using the process from CubeMapGen described here:
  13644. * https://seblagarde.wordpress.com/2012/06/10/amd-cubemapgen-for-physically-based-rendering/
  13645. */
  13646. class PMREMGenerator {
  13647. input: ArrayBufferView[];
  13648. inputSize: number;
  13649. outputSize: number;
  13650. maxNumMipLevels: number;
  13651. numChannels: number;
  13652. isFloat: boolean;
  13653. specularPower: number;
  13654. cosinePowerDropPerMip: number;
  13655. excludeBase: boolean;
  13656. fixup: boolean;
  13657. private static CP_MAX_MIPLEVELS;
  13658. private static CP_UDIR;
  13659. private static CP_VDIR;
  13660. private static CP_FACEAXIS;
  13661. private static CP_FACE_X_POS;
  13662. private static CP_FACE_X_NEG;
  13663. private static CP_FACE_Y_POS;
  13664. private static CP_FACE_Y_NEG;
  13665. private static CP_FACE_Z_POS;
  13666. private static CP_FACE_Z_NEG;
  13667. private static CP_EDGE_LEFT;
  13668. private static CP_EDGE_RIGHT;
  13669. private static CP_EDGE_TOP;
  13670. private static CP_EDGE_BOTTOM;
  13671. private static CP_CORNER_NNN;
  13672. private static CP_CORNER_NNP;
  13673. private static CP_CORNER_NPN;
  13674. private static CP_CORNER_NPP;
  13675. private static CP_CORNER_PNN;
  13676. private static CP_CORNER_PNP;
  13677. private static CP_CORNER_PPN;
  13678. private static CP_CORNER_PPP;
  13679. private static _vectorTemp;
  13680. private static _sgFace2DMapping;
  13681. private static _sgCubeNgh;
  13682. private static _sgCubeEdgeList;
  13683. private static _sgCubeCornerList;
  13684. private _outputSurface;
  13685. private _normCubeMap;
  13686. private _filterLUT;
  13687. private _numMipLevels;
  13688. /**
  13689. * Constructor of the generator.
  13690. *
  13691. * @param input The different faces data from the original cubemap in the order X+ X- Y+ Y- Z+ Z-
  13692. * @param inputSize The size of the cubemap faces
  13693. * @param outputSize The size of the output cubemap faces
  13694. * @param maxNumMipLevels The max number of mip map to generate (0 means all)
  13695. * @param numChannels The number of channels stored in the cubemap (3 for RBGE for instance)
  13696. * @param isFloat Specifies if the input texture is in float or int (hdr is usually in float)
  13697. * @param specularPower The max specular level of the desired cubemap
  13698. * @param cosinePowerDropPerMip The amount of drop the specular power will follow on each mip
  13699. * @param excludeBase Specifies wether to process the level 0 (original level) or not
  13700. * @param fixup Specifies wether to apply the edge fixup algorythm or not
  13701. */
  13702. constructor(input: ArrayBufferView[], inputSize: number, outputSize: number, maxNumMipLevels: number, numChannels: number, isFloat: boolean, specularPower: number, cosinePowerDropPerMip: number, excludeBase: boolean, fixup: boolean);
  13703. /**
  13704. * Launches the filter process and return the result.
  13705. *
  13706. * @return the filter cubemap in the form mip0 [faces1..6] .. mipN [faces1..6]
  13707. */
  13708. filterCubeMap(): ArrayBufferView[][];
  13709. private init();
  13710. private filterCubeMapMipChain();
  13711. private getBaseFilterAngle(cosinePower);
  13712. private precomputeFilterLookupTables(srcCubeMapWidth);
  13713. private buildNormalizerSolidAngleCubemap(size);
  13714. private texelCoordToVect(faceIdx, u, v, size, fixup);
  13715. private vectToTexelCoord(x, y, z, size);
  13716. private areaElement(x, y);
  13717. private texelCoordSolidAngle(faceIdx, u, v, size);
  13718. private filterCubeSurfaces(srcCubeMap, srcSize, dstCubeMap, dstSize, filterConeAngle, specularPower);
  13719. private clearFilterExtents(filterExtents);
  13720. private determineFilterExtents(centerTapDir, srcSize, bboxSize, filterExtents);
  13721. private processFilterExtents(centerTapDir, dotProdThresh, filterExtents, srcCubeMap, srcSize, specularPower);
  13722. private fixupCubeEdges(cubeMap, cubeMapSize);
  13723. }
  13724. }
  13725. declare module BABYLON {
  13726. class CustomProceduralTexture extends ProceduralTexture {
  13727. private _animate;
  13728. private _time;
  13729. private _config;
  13730. private _texturePath;
  13731. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  13732. private loadJson(jsonUrl);
  13733. isReady(): boolean;
  13734. render(useCameraPostProcess?: boolean): void;
  13735. updateTextures(): void;
  13736. updateShaderUniforms(): void;
  13737. animate: boolean;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. class ProceduralTexture extends Texture {
  13742. isCube: boolean;
  13743. private _size;
  13744. _generateMipMaps: boolean;
  13745. isEnabled: boolean;
  13746. private _doNotChangeAspectRatio;
  13747. private _currentRefreshId;
  13748. private _refreshRate;
  13749. onGenerated: () => void;
  13750. private _vertexBuffers;
  13751. private _indexBuffer;
  13752. private _effect;
  13753. private _uniforms;
  13754. private _samplers;
  13755. private _fragment;
  13756. _textures: Texture[];
  13757. private _floats;
  13758. private _floatsArrays;
  13759. private _colors3;
  13760. private _colors4;
  13761. private _vectors2;
  13762. private _vectors3;
  13763. private _matrices;
  13764. private _fallbackTexture;
  13765. private _fallbackTextureUsed;
  13766. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean, isCube?: boolean);
  13767. reset(): void;
  13768. isReady(): boolean;
  13769. resetRefreshCounter(): void;
  13770. setFragment(fragment: any): void;
  13771. refreshRate: number;
  13772. _shouldRender(): boolean;
  13773. getRenderSize(): number;
  13774. resize(size: any, generateMipMaps: any): void;
  13775. private _checkUniform(uniformName);
  13776. setTexture(name: string, texture: Texture): ProceduralTexture;
  13777. setFloat(name: string, value: number): ProceduralTexture;
  13778. setFloats(name: string, value: number[]): ProceduralTexture;
  13779. setColor3(name: string, value: Color3): ProceduralTexture;
  13780. setColor4(name: string, value: Color4): ProceduralTexture;
  13781. setVector2(name: string, value: Vector2): ProceduralTexture;
  13782. setVector3(name: string, value: Vector3): ProceduralTexture;
  13783. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13784. render(useCameraPostProcess?: boolean): void;
  13785. clone(): ProceduralTexture;
  13786. dispose(): void;
  13787. }
  13788. }