babylon.d.ts 2.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * @see http://doc.babylonjs.com/babylon101/materials
  105. */
  106. materials: Material[];
  107. /**
  108. * The list of morph target managers added to the scene
  109. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110. */
  111. morphTargetManagers: MorphTargetManager[];
  112. /**
  113. * The list of geometries used in the scene.
  114. */
  115. geometries: Geometry[];
  116. /**
  117. * All of the tranform nodes added to this scene
  118. * @see http://doc.babylonjs.com/how_to/transformnode
  119. */
  120. transformNodes: TransformNode[];
  121. /**
  122. * ActionManagers available on the scene.
  123. */
  124. actionManagers: ActionManager[];
  125. /**
  126. * Textures to keep.
  127. */
  128. textures: BaseTexture[];
  129. }
  130. }
  131. declare module BABYLON {
  132. /**
  133. * Set of assets to keep when moving a scene into an asset container.
  134. */
  135. class KeepAssets extends AbstractScene {
  136. }
  137. /**
  138. * Container with a set of assets that can be added or removed from a scene.
  139. */
  140. class AssetContainer extends AbstractScene {
  141. /**
  142. * The scene the AssetContainer belongs to.
  143. */
  144. scene: Scene;
  145. /**
  146. * Instantiates an AssetContainer.
  147. * @param scene The scene the AssetContainer belongs to.
  148. */
  149. constructor(scene: Scene);
  150. /**
  151. * Adds all the assets from the container to the scene.
  152. */
  153. addAllToScene(): void;
  154. /**
  155. * Removes all the assets in the container from the scene
  156. */
  157. removeAllFromScene(): void;
  158. private _moveAssets;
  159. /**
  160. * Removes all the assets contained in the scene and adds them to the container.
  161. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  162. */
  163. moveAllFromScene(keepAssets?: KeepAssets): void;
  164. /**
  165. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  166. * @returns the root mesh
  167. */
  168. createRootMesh(): Mesh;
  169. }
  170. }
  171. interface Window {
  172. mozIndexedDB: IDBFactory;
  173. webkitIndexedDB: IDBFactory;
  174. msIndexedDB: IDBFactory;
  175. webkitURL: typeof URL;
  176. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  177. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  178. WebGLRenderingContext: WebGLRenderingContext;
  179. MSGesture: MSGesture;
  180. CANNON: any;
  181. AudioContext: AudioContext;
  182. webkitAudioContext: AudioContext;
  183. PointerEvent: any;
  184. Math: Math;
  185. Uint8Array: Uint8ArrayConstructor;
  186. Float32Array: Float32ArrayConstructor;
  187. mozURL: typeof URL;
  188. msURL: typeof URL;
  189. VRFrameData: any;
  190. DracoDecoderModule: any;
  191. setImmediate(handler: (...args: any[]) => void): number;
  192. }
  193. interface WebGLRenderingContext {
  194. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  195. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  196. vertexAttribDivisor(index: number, divisor: number): void;
  197. createVertexArray(): any;
  198. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  199. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  200. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  201. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  202. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  203. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  204. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  205. createQuery(): WebGLQuery;
  206. deleteQuery(query: WebGLQuery): void;
  207. beginQuery(target: number, query: WebGLQuery): void;
  208. endQuery(target: number): void;
  209. getQueryParameter(query: WebGLQuery, pname: number): any;
  210. getQuery(target: number, pname: number): any;
  211. MAX_SAMPLES: number;
  212. RGBA8: number;
  213. READ_FRAMEBUFFER: number;
  214. DRAW_FRAMEBUFFER: number;
  215. UNIFORM_BUFFER: number;
  216. HALF_FLOAT_OES: number;
  217. RGBA16F: number;
  218. RGBA32F: number;
  219. R32F: number;
  220. RG32F: number;
  221. RGB32F: number;
  222. R16F: number;
  223. RG16F: number;
  224. RGB16F: number;
  225. RED: number;
  226. RG: number;
  227. R8: number;
  228. RG8: number;
  229. UNSIGNED_INT_24_8: number;
  230. DEPTH24_STENCIL8: number;
  231. drawBuffers(buffers: number[]): void;
  232. readBuffer(src: number): void;
  233. readonly COLOR_ATTACHMENT0: number;
  234. readonly COLOR_ATTACHMENT1: number;
  235. readonly COLOR_ATTACHMENT2: number;
  236. readonly COLOR_ATTACHMENT3: number;
  237. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  238. ANY_SAMPLES_PASSED: number;
  239. QUERY_RESULT_AVAILABLE: number;
  240. QUERY_RESULT: number;
  241. }
  242. interface Document {
  243. mozCancelFullScreen(): void;
  244. msCancelFullScreen(): void;
  245. webkitCancelFullScreen(): void;
  246. requestPointerLock(): void;
  247. exitPointerLock(): void;
  248. fullscreen: boolean;
  249. mozFullScreen: boolean;
  250. msIsFullScreen: boolean;
  251. readonly webkitIsFullScreen: boolean;
  252. readonly pointerLockElement: Element;
  253. mozPointerLockElement: HTMLElement;
  254. msPointerLockElement: HTMLElement;
  255. webkitPointerLockElement: HTMLElement;
  256. }
  257. interface HTMLCanvasElement {
  258. requestPointerLock(): void;
  259. msRequestPointerLock?(): void;
  260. mozRequestPointerLock?(): void;
  261. webkitRequestPointerLock?(): void;
  262. }
  263. interface CanvasRenderingContext2D {
  264. msImageSmoothingEnabled: boolean;
  265. }
  266. interface WebGLBuffer {
  267. references: number;
  268. capacity: number;
  269. is32Bits: boolean;
  270. }
  271. interface WebGLProgram {
  272. transformFeedback?: WebGLTransformFeedback | null;
  273. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  274. }
  275. interface MouseEvent {
  276. mozMovementX: number;
  277. mozMovementY: number;
  278. webkitMovementX: number;
  279. webkitMovementY: number;
  280. msMovementX: number;
  281. msMovementY: number;
  282. }
  283. interface Navigator {
  284. mozGetVRDevices: (any: any) => any;
  285. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  286. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  287. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  288. webkitGetGamepads(): Gamepad[];
  289. msGetGamepads(): Gamepad[];
  290. webkitGamepads(): Gamepad[];
  291. }
  292. interface HTMLVideoElement {
  293. mozSrcObject: any;
  294. }
  295. interface Element {
  296. webkitRequestFullScreen: () => void;
  297. }
  298. interface Screen {
  299. readonly orientation: string;
  300. readonly mozOrientation: string;
  301. }
  302. interface Math {
  303. fround(x: number): number;
  304. imul(a: number, b: number): number;
  305. }
  306. interface EXT_disjoint_timer_query {
  307. QUERY_COUNTER_BITS_EXT: number;
  308. TIME_ELAPSED_EXT: number;
  309. TIMESTAMP_EXT: number;
  310. GPU_DISJOINT_EXT: number;
  311. QUERY_RESULT_EXT: number;
  312. QUERY_RESULT_AVAILABLE_EXT: number;
  313. queryCounterEXT(query: WebGLQuery, target: number): void;
  314. createQueryEXT(): WebGLQuery;
  315. beginQueryEXT(target: number, query: WebGLQuery): void;
  316. endQueryEXT(target: number): void;
  317. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  318. deleteQueryEXT(query: WebGLQuery): void;
  319. }
  320. interface WebGLUniformLocation {
  321. _currentState: any;
  322. }
  323. declare module BABYLON {
  324. /**
  325. * Defines how a node can be built from a string name.
  326. */
  327. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  328. /**
  329. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  330. */
  331. class Node implements IBehaviorAware<Node> {
  332. private static _NodeConstructors;
  333. /**
  334. * Add a new node constructor
  335. * @param type defines the type name of the node to construct
  336. * @param constructorFunc defines the constructor function
  337. */
  338. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  339. /**
  340. * Returns a node constructor based on type name
  341. * @param type defines the type name
  342. * @param name defines the new node name
  343. * @param scene defines the hosting scene
  344. * @param options defines optional options to transmit to constructors
  345. * @returns the new constructor or null
  346. */
  347. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  348. /**
  349. * Gets or sets the name of the node
  350. */
  351. name: string;
  352. /**
  353. * Gets or sets the id of the node
  354. */
  355. id: string;
  356. /**
  357. * Gets or sets the unique id of the node
  358. */
  359. uniqueId: number;
  360. /**
  361. * Gets or sets a string used to store user defined state for the node
  362. */
  363. state: string;
  364. /**
  365. * Gets or sets an object used to store user defined information for the node
  366. */
  367. metadata: any;
  368. /**
  369. * Gets or sets a boolean used to define if the node must be serialized
  370. */
  371. doNotSerialize: boolean;
  372. /** @hidden */
  373. _isDisposed: boolean;
  374. /**
  375. * Gets a list of Animations associated with the node
  376. */
  377. animations: Animation[];
  378. protected _ranges: {
  379. [name: string]: Nullable<AnimationRange>;
  380. };
  381. /**
  382. * Callback raised when the node is ready to be used
  383. */
  384. onReady: (node: Node) => void;
  385. private _isEnabled;
  386. private _isParentEnabled;
  387. private _isReady;
  388. /** @hidden */
  389. _currentRenderId: number;
  390. private _parentRenderId;
  391. protected _childRenderId: number;
  392. /** @hidden */
  393. _waitingParentId: Nullable<string>;
  394. /** @hidden */
  395. _scene: Scene;
  396. /** @hidden */
  397. _cache: any;
  398. private _parentNode;
  399. private _children;
  400. /** @hidden */
  401. _worldMatrix: Matrix;
  402. /** @hidden */
  403. _worldMatrixDeterminant: number;
  404. /** @hidden */
  405. private _sceneRootNodesIndex;
  406. /**
  407. * Gets a boolean indicating if the node has been disposed
  408. * @returns true if the node was disposed
  409. */
  410. isDisposed(): boolean;
  411. /**
  412. * Gets or sets the parent of the node
  413. */
  414. parent: Nullable<Node>;
  415. private addToSceneRootNodes;
  416. private removeFromSceneRootNodes;
  417. private _animationPropertiesOverride;
  418. /**
  419. * Gets or sets the animation properties override
  420. */
  421. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  422. /**
  423. * Gets a string idenfifying the name of the class
  424. * @returns "Node" string
  425. */
  426. getClassName(): string;
  427. /**
  428. * An event triggered when the mesh is disposed
  429. */
  430. onDisposeObservable: Observable<Node>;
  431. private _onDisposeObserver;
  432. /**
  433. * Sets a callback that will be raised when the node will be disposed
  434. */
  435. onDispose: () => void;
  436. /**
  437. * Creates a new Node
  438. * @param name the name and id to be given to this node
  439. * @param scene the scene this node will be added to
  440. */
  441. constructor(name: string, scene?: Nullable<Scene>);
  442. /**
  443. * Gets the scene of the node
  444. * @returns a scene
  445. */
  446. getScene(): Scene;
  447. /**
  448. * Gets the engine of the node
  449. * @returns a Engine
  450. */
  451. getEngine(): Engine;
  452. private _behaviors;
  453. /**
  454. * Attach a behavior to the node
  455. * @see http://doc.babylonjs.com/features/behaviour
  456. * @param behavior defines the behavior to attach
  457. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  458. * @returns the current Node
  459. */
  460. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  461. /**
  462. * Remove an attached behavior
  463. * @see http://doc.babylonjs.com/features/behaviour
  464. * @param behavior defines the behavior to attach
  465. * @returns the current Node
  466. */
  467. removeBehavior(behavior: Behavior<Node>): Node;
  468. /**
  469. * Gets the list of attached behaviors
  470. * @see http://doc.babylonjs.com/features/behaviour
  471. */
  472. readonly behaviors: Behavior<Node>[];
  473. /**
  474. * Gets an attached behavior by name
  475. * @param name defines the name of the behavior to look for
  476. * @see http://doc.babylonjs.com/features/behaviour
  477. * @returns null if behavior was not found else the requested behavior
  478. */
  479. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  480. /**
  481. * Returns the latest update of the World matrix
  482. * @returns a Matrix
  483. */
  484. getWorldMatrix(): Matrix;
  485. /** @hidden */
  486. _getWorldMatrixDeterminant(): number;
  487. /**
  488. * Returns directly the latest state of the mesh World matrix.
  489. * A Matrix is returned.
  490. */
  491. readonly worldMatrixFromCache: Matrix;
  492. /** @hidden */
  493. _initCache(): void;
  494. /** @hidden */
  495. updateCache(force?: boolean): void;
  496. /** @hidden */
  497. _updateCache(ignoreParentClass?: boolean): void;
  498. /** @hidden */
  499. _isSynchronized(): boolean;
  500. /** @hidden */
  501. _markSyncedWithParent(): void;
  502. /** @hidden */
  503. isSynchronizedWithParent(): boolean;
  504. /** @hidden */
  505. isSynchronized(): boolean;
  506. /**
  507. * Is this node ready to be used/rendered
  508. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  509. * @return true if the node is ready
  510. */
  511. isReady(completeCheck?: boolean): boolean;
  512. /**
  513. * Is this node enabled?
  514. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  515. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  516. * @return whether this node (and its parent) is enabled
  517. */
  518. isEnabled(checkAncestors?: boolean): boolean;
  519. /** @hidden */
  520. protected _syncParentEnabledState(): void;
  521. /**
  522. * Set the enabled state of this node
  523. * @param value defines the new enabled state
  524. */
  525. setEnabled(value: boolean): void;
  526. /**
  527. * Is this node a descendant of the given node?
  528. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  529. * @param ancestor defines the parent node to inspect
  530. * @returns a boolean indicating if this node is a descendant of the given node
  531. */
  532. isDescendantOf(ancestor: Node): boolean;
  533. /** @hidden */
  534. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  535. /**
  536. * Will return all nodes that have this node as ascendant
  537. * @param directDescendantsOnly defines 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
  538. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  539. * @return all children nodes of all types
  540. */
  541. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  542. /**
  543. * Get all child-meshes of this node
  544. * @param directDescendantsOnly defines 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
  545. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  546. * @returns an array of AbstractMesh
  547. */
  548. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  549. /**
  550. * Get all child-transformNodes of this node
  551. * @param directDescendantsOnly defines 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
  552. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  553. * @returns an array of TransformNode
  554. */
  555. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  556. /**
  557. * Get all direct children of this node
  558. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  559. * @returns an array of Node
  560. */
  561. getChildren(predicate?: (node: Node) => boolean): Node[];
  562. /** @hidden */
  563. _setReady(state: boolean): void;
  564. /**
  565. * Get an animation by name
  566. * @param name defines the name of the animation to look for
  567. * @returns null if not found else the requested animation
  568. */
  569. getAnimationByName(name: string): Nullable<Animation>;
  570. /**
  571. * Creates an animation range for this node
  572. * @param name defines the name of the range
  573. * @param from defines the starting key
  574. * @param to defines the end key
  575. */
  576. createAnimationRange(name: string, from: number, to: number): void;
  577. /**
  578. * Delete a specific animation range
  579. * @param name defines the name of the range to delete
  580. * @param deleteFrames defines if animation frames from the range must be deleted as well
  581. */
  582. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  583. /**
  584. * Get an animation range by name
  585. * @param name defines the name of the animation range to look for
  586. * @returns null if not found else the requested animation range
  587. */
  588. getAnimationRange(name: string): Nullable<AnimationRange>;
  589. /**
  590. * Will start the animation sequence
  591. * @param name defines the range frames for animation sequence
  592. * @param loop defines if the animation should loop (false by default)
  593. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  594. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  595. * @returns the object created for this animation. If range does not exist, it will return null
  596. */
  597. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  598. /**
  599. * Serialize animation ranges into a JSON compatible object
  600. * @returns serialization object
  601. */
  602. serializeAnimationRanges(): any;
  603. /**
  604. * Computes the world matrix of the node
  605. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  606. * @returns the world matrix
  607. */
  608. computeWorldMatrix(force?: boolean): Matrix;
  609. /**
  610. * Releases resources associated with this node.
  611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  613. */
  614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  615. /**
  616. * Parse animation range data from a serialization object and store them into a given node
  617. * @param node defines where to store the animation ranges
  618. * @param parsedNode defines the serialization object to read data from
  619. * @param scene defines the hosting scene
  620. */
  621. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  622. }
  623. }
  624. declare module BABYLON {
  625. /**
  626. * Define an interface for all classes that will hold resources
  627. */
  628. interface IDisposable {
  629. /**
  630. * Releases all held resources
  631. */
  632. dispose(): void;
  633. }
  634. /**
  635. * This class is used by the onRenderingGroupObservable
  636. */
  637. class RenderingGroupInfo {
  638. /**
  639. * The Scene that being rendered
  640. */
  641. scene: Scene;
  642. /**
  643. * The camera currently used for the rendering pass
  644. */
  645. camera: Nullable<Camera>;
  646. /**
  647. * The ID of the renderingGroup being processed
  648. */
  649. renderingGroupId: number;
  650. }
  651. /**
  652. * Represents a scene to be rendered by the engine.
  653. * @see http://doc.babylonjs.com/features/scene
  654. */
  655. class Scene extends AbstractScene implements IAnimatable {
  656. private static _uniqueIdCounter;
  657. /** The fog is deactivated */
  658. static readonly FOGMODE_NONE: number;
  659. /** The fog density is following an exponential function */
  660. static readonly FOGMODE_EXP: number;
  661. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  662. static readonly FOGMODE_EXP2: number;
  663. /** The fog density is following a linear function. */
  664. static readonly FOGMODE_LINEAR: number;
  665. /**
  666. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  667. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  668. */
  669. static MinDeltaTime: number;
  670. /**
  671. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  672. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  673. */
  674. static MaxDeltaTime: number;
  675. /**
  676. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  677. */
  678. autoClear: boolean;
  679. /**
  680. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  681. */
  682. autoClearDepthAndStencil: boolean;
  683. /**
  684. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  685. */
  686. clearColor: Color4;
  687. /**
  688. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  689. */
  690. ambientColor: Color3;
  691. /** @hidden */
  692. _environmentBRDFTexture: BaseTexture;
  693. /** @hidden */
  694. protected _environmentTexture: BaseTexture;
  695. /**
  696. * Texture used in all pbr material as the reflection texture.
  697. * As in the majority of the scene they are the same (exception for multi room and so on),
  698. * this is easier to reference from here than from all the materials.
  699. */
  700. /**
  701. * Texture used in all pbr material as the reflection texture.
  702. * As in the majority of the scene they are the same (exception for multi room and so on),
  703. * this is easier to set here than in all the materials.
  704. */
  705. environmentTexture: BaseTexture;
  706. /** @hidden */
  707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  708. /**
  709. * Default image processing configuration used either in the rendering
  710. * Forward main pass or through the imageProcessingPostProcess if present.
  711. * As in the majority of the scene they are the same (exception for multi camera),
  712. * this is easier to reference from here than from all the materials and post process.
  713. *
  714. * No setter as we it is a shared configuration, you can set the values instead.
  715. */
  716. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  717. private _forceWireframe;
  718. /**
  719. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  720. */
  721. forceWireframe: boolean;
  722. private _forcePointsCloud;
  723. /**
  724. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  725. */
  726. forcePointsCloud: boolean;
  727. /**
  728. * Gets or sets the active clipplane 1
  729. */
  730. clipPlane: Nullable<Plane>;
  731. /**
  732. * Gets or sets the active clipplane 2
  733. */
  734. clipPlane2: Nullable<Plane>;
  735. /**
  736. * Gets or sets the active clipplane 3
  737. */
  738. clipPlane3: Nullable<Plane>;
  739. /**
  740. * Gets or sets the active clipplane 4
  741. */
  742. clipPlane4: Nullable<Plane>;
  743. /**
  744. * Gets or sets a boolean indicating if animations are enabled
  745. */
  746. animationsEnabled: boolean;
  747. private _animationPropertiesOverride;
  748. /**
  749. * Gets or sets the animation properties override
  750. */
  751. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  752. /**
  753. * Gets or sets a boolean indicating if a constant deltatime has to be used
  754. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  755. */
  756. useConstantAnimationDeltaTime: boolean;
  757. /**
  758. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  759. * Please note that it requires to run a ray cast through the scene on every frame
  760. */
  761. constantlyUpdateMeshUnderPointer: boolean;
  762. /**
  763. * Defines the HTML cursor to use when hovering over interactive elements
  764. */
  765. hoverCursor: string;
  766. /**
  767. * Defines the HTML default cursor to use (empty by default)
  768. */
  769. defaultCursor: string;
  770. /**
  771. * This is used to call preventDefault() on pointer down
  772. * in order to block unwanted artifacts like system double clicks
  773. */
  774. preventDefaultOnPointerDown: boolean;
  775. /**
  776. * Gets or sets user defined metadata
  777. */
  778. metadata: any;
  779. /**
  780. * Gets the name of the plugin used to load this scene (null by default)
  781. */
  782. loadingPluginName: string;
  783. /**
  784. * Use this array to add regular expressions used to disable offline support for specific urls
  785. */
  786. disableOfflineSupportExceptionRules: RegExp[];
  787. /**
  788. * An event triggered when the scene is disposed.
  789. */
  790. onDisposeObservable: Observable<Scene>;
  791. private _onDisposeObserver;
  792. /** Sets a function to be executed when this scene is disposed. */
  793. onDispose: () => void;
  794. /**
  795. * An event triggered before rendering the scene (right after animations and physics)
  796. */
  797. onBeforeRenderObservable: Observable<Scene>;
  798. private _onBeforeRenderObserver;
  799. /** Sets a function to be executed before rendering this scene */
  800. beforeRender: Nullable<() => void>;
  801. /**
  802. * An event triggered after rendering the scene
  803. */
  804. onAfterRenderObservable: Observable<Scene>;
  805. private _onAfterRenderObserver;
  806. /** Sets a function to be executed after rendering this scene */
  807. afterRender: Nullable<() => void>;
  808. /**
  809. * An event triggered before animating the scene
  810. */
  811. onBeforeAnimationsObservable: Observable<Scene>;
  812. /**
  813. * An event triggered after animations processing
  814. */
  815. onAfterAnimationsObservable: Observable<Scene>;
  816. /**
  817. * An event triggered before draw calls are ready to be sent
  818. */
  819. onBeforeDrawPhaseObservable: Observable<Scene>;
  820. /**
  821. * An event triggered after draw calls have been sent
  822. */
  823. onAfterDrawPhaseObservable: Observable<Scene>;
  824. /**
  825. * An event triggered when the scene is ready
  826. */
  827. onReadyObservable: Observable<Scene>;
  828. /**
  829. * An event triggered before rendering a camera
  830. */
  831. onBeforeCameraRenderObservable: Observable<Camera>;
  832. private _onBeforeCameraRenderObserver;
  833. /** Sets a function to be executed before rendering a camera*/
  834. beforeCameraRender: () => void;
  835. /**
  836. * An event triggered after rendering a camera
  837. */
  838. onAfterCameraRenderObservable: Observable<Camera>;
  839. private _onAfterCameraRenderObserver;
  840. /** Sets a function to be executed after rendering a camera*/
  841. afterCameraRender: () => void;
  842. /**
  843. * An event triggered when active meshes evaluation is about to start
  844. */
  845. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  846. /**
  847. * An event triggered when active meshes evaluation is done
  848. */
  849. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  850. /**
  851. * An event triggered when particles rendering is about to start
  852. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  853. */
  854. onBeforeParticlesRenderingObservable: Observable<Scene>;
  855. /**
  856. * An event triggered when particles rendering is done
  857. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  858. */
  859. onAfterParticlesRenderingObservable: Observable<Scene>;
  860. /**
  861. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  862. */
  863. onDataLoadedObservable: Observable<Scene>;
  864. /**
  865. * An event triggered when a camera is created
  866. */
  867. onNewCameraAddedObservable: Observable<Camera>;
  868. /**
  869. * An event triggered when a camera is removed
  870. */
  871. onCameraRemovedObservable: Observable<Camera>;
  872. /**
  873. * An event triggered when a light is created
  874. */
  875. onNewLightAddedObservable: Observable<Light>;
  876. /**
  877. * An event triggered when a light is removed
  878. */
  879. onLightRemovedObservable: Observable<Light>;
  880. /**
  881. * An event triggered when a geometry is created
  882. */
  883. onNewGeometryAddedObservable: Observable<Geometry>;
  884. /**
  885. * An event triggered when a geometry is removed
  886. */
  887. onGeometryRemovedObservable: Observable<Geometry>;
  888. /**
  889. * An event triggered when a transform node is created
  890. */
  891. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  892. /**
  893. * An event triggered when a transform node is removed
  894. */
  895. onTransformNodeRemovedObservable: Observable<TransformNode>;
  896. /**
  897. * An event triggered when a mesh is created
  898. */
  899. onNewMeshAddedObservable: Observable<AbstractMesh>;
  900. /**
  901. * An event triggered when a mesh is removed
  902. */
  903. onMeshRemovedObservable: Observable<AbstractMesh>;
  904. /**
  905. * An event triggered when a material is created
  906. */
  907. onNewMaterialAddedObservable: Observable<Material>;
  908. /**
  909. * An event triggered when a material is removed
  910. */
  911. onMaterialRemovedObservable: Observable<Material>;
  912. /**
  913. * An event triggered when a texture is created
  914. */
  915. onNewTextureAddedObservable: Observable<BaseTexture>;
  916. /**
  917. * An event triggered when a texture is removed
  918. */
  919. onTextureRemovedObservable: Observable<BaseTexture>;
  920. /**
  921. * An event triggered when render targets are about to be rendered
  922. * Can happen multiple times per frame.
  923. */
  924. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  925. /**
  926. * An event triggered when render targets were rendered.
  927. * Can happen multiple times per frame.
  928. */
  929. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  930. /**
  931. * An event triggered before calculating deterministic simulation step
  932. */
  933. onBeforeStepObservable: Observable<Scene>;
  934. /**
  935. * An event triggered after calculating deterministic simulation step
  936. */
  937. onAfterStepObservable: Observable<Scene>;
  938. /**
  939. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  940. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  941. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  942. */
  943. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  944. /**
  945. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  946. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  947. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  948. */
  949. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  950. /**
  951. * This Observable will when a mesh has been imported into the scene.
  952. */
  953. onMeshImportedObservable: Observable<AbstractMesh>;
  954. private _registeredForLateAnimationBindings;
  955. /**
  956. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  957. */
  958. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  959. /**
  960. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  961. */
  962. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  963. /**
  964. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  965. */
  966. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  967. private _onPointerMove;
  968. private _onPointerDown;
  969. private _onPointerUp;
  970. /** Deprecated. Use onPointerObservable instead */
  971. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  972. /** Deprecated. Use onPointerObservable instead */
  973. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  974. /** Deprecated. Use onPointerObservable instead */
  975. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  976. /** Deprecated. Use onPointerObservable instead */
  977. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  978. /**
  979. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  980. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  981. */
  982. onPrePointerObservable: Observable<PointerInfoPre>;
  983. /**
  984. * Observable event triggered each time an input event is received from the rendering canvas
  985. */
  986. onPointerObservable: Observable<PointerInfo>;
  987. /**
  988. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  989. */
  990. readonly unTranslatedPointer: Vector2;
  991. /** The distance in pixel that you have to move to prevent some events */
  992. static DragMovementThreshold: number;
  993. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  994. static LongPressDelay: number;
  995. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  996. static DoubleClickDelay: number;
  997. /** If you need to check double click without raising a single click at first click, enable this flag */
  998. static ExclusiveDoubleClickMode: boolean;
  999. private _initClickEvent;
  1000. private _initActionManager;
  1001. private _delayedSimpleClick;
  1002. private _delayedSimpleClickTimeout;
  1003. private _previousDelayedSimpleClickTimeout;
  1004. private _meshPickProceed;
  1005. private _previousButtonPressed;
  1006. private _currentPickResult;
  1007. private _previousPickResult;
  1008. private _totalPointersPressed;
  1009. private _doubleClickOccured;
  1010. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1011. cameraToUseForPointers: Nullable<Camera>;
  1012. private _pointerX;
  1013. private _pointerY;
  1014. private _unTranslatedPointerX;
  1015. private _unTranslatedPointerY;
  1016. private _startingPointerPosition;
  1017. private _previousStartingPointerPosition;
  1018. private _startingPointerTime;
  1019. private _previousStartingPointerTime;
  1020. private _pointerCaptures;
  1021. private _timeAccumulator;
  1022. private _currentStepId;
  1023. private _currentInternalStep;
  1024. /** @hidden */
  1025. _mirroredCameraPosition: Nullable<Vector3>;
  1026. /**
  1027. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1028. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1029. */
  1030. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1031. /**
  1032. * Observable event triggered each time an keyboard event is received from the hosting window
  1033. */
  1034. onKeyboardObservable: Observable<KeyboardInfo>;
  1035. private _onKeyDown;
  1036. private _onKeyUp;
  1037. private _onCanvasFocusObserver;
  1038. private _onCanvasBlurObserver;
  1039. private _useRightHandedSystem;
  1040. /**
  1041. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1042. */
  1043. useRightHandedSystem: boolean;
  1044. /**
  1045. * Sets the step Id used by deterministic lock step
  1046. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1047. * @param newStepId defines the step Id
  1048. */
  1049. setStepId(newStepId: number): void;
  1050. /**
  1051. * Gets the step Id used by deterministic lock step
  1052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1053. * @returns the step Id
  1054. */
  1055. getStepId(): number;
  1056. /**
  1057. * Gets the internal step used by deterministic lock step
  1058. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1059. * @returns the internal step
  1060. */
  1061. getInternalStep(): number;
  1062. private _fogEnabled;
  1063. /**
  1064. * Gets or sets a boolean indicating if fog is enabled on this scene
  1065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1066. * (Default is true)
  1067. */
  1068. fogEnabled: boolean;
  1069. private _fogMode;
  1070. /**
  1071. * Gets or sets the fog mode to use
  1072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1073. * | mode | value |
  1074. * | --- | --- |
  1075. * | FOGMODE_NONE | 0 |
  1076. * | FOGMODE_EXP | 1 |
  1077. * | FOGMODE_EXP2 | 2 |
  1078. * | FOGMODE_LINEAR | 3 |
  1079. */
  1080. fogMode: number;
  1081. /**
  1082. * Gets or sets the fog color to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. * (Default is Color3(0.2, 0.2, 0.3))
  1085. */
  1086. fogColor: Color3;
  1087. /**
  1088. * Gets or sets the fog density to use
  1089. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1090. * (Default is 0.1)
  1091. */
  1092. fogDensity: number;
  1093. /**
  1094. * Gets or sets the fog start distance to use
  1095. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1096. * (Default is 0)
  1097. */
  1098. fogStart: number;
  1099. /**
  1100. * Gets or sets the fog end distance to use
  1101. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1102. * (Default is 1000)
  1103. */
  1104. fogEnd: number;
  1105. private _shadowsEnabled;
  1106. /**
  1107. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1108. */
  1109. shadowsEnabled: boolean;
  1110. private _lightsEnabled;
  1111. /**
  1112. * Gets or sets a boolean indicating if lights are enabled on this scene
  1113. */
  1114. lightsEnabled: boolean;
  1115. /** All of the active cameras added to this scene. */
  1116. activeCameras: Camera[];
  1117. /** The current active camera */
  1118. activeCamera: Nullable<Camera>;
  1119. private _defaultMaterial;
  1120. /** The default material used on meshes when no material is affected */
  1121. /** The default material used on meshes when no material is affected */
  1122. defaultMaterial: Material;
  1123. private _texturesEnabled;
  1124. /**
  1125. * Gets or sets a boolean indicating if textures are enabled on this scene
  1126. */
  1127. texturesEnabled: boolean;
  1128. /**
  1129. * Gets or sets a boolean indicating if particles are enabled on this scene
  1130. */
  1131. particlesEnabled: boolean;
  1132. /**
  1133. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1134. */
  1135. spritesEnabled: boolean;
  1136. private _skeletonsEnabled;
  1137. /**
  1138. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1139. */
  1140. skeletonsEnabled: boolean;
  1141. /**
  1142. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1143. */
  1144. lensFlaresEnabled: boolean;
  1145. /**
  1146. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1148. */
  1149. collisionsEnabled: boolean;
  1150. private _workerCollisions;
  1151. /** @hidden */
  1152. collisionCoordinator: ICollisionCoordinator;
  1153. /**
  1154. * Defines the gravity applied to this scene (used only for collisions)
  1155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1156. */
  1157. gravity: Vector3;
  1158. /**
  1159. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1160. */
  1161. postProcessesEnabled: boolean;
  1162. /**
  1163. * The list of postprocesses added to the scene
  1164. */
  1165. postProcesses: PostProcess[];
  1166. /**
  1167. * Gets the current postprocess manager
  1168. */
  1169. postProcessManager: PostProcessManager;
  1170. /**
  1171. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1172. */
  1173. renderTargetsEnabled: boolean;
  1174. /**
  1175. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1176. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1177. */
  1178. dumpNextRenderTargets: boolean;
  1179. /**
  1180. * The list of user defined render targets added to the scene
  1181. */
  1182. customRenderTargets: RenderTargetTexture[];
  1183. /**
  1184. * Defines if texture loading must be delayed
  1185. * If true, textures will only be loaded when they need to be rendered
  1186. */
  1187. useDelayedTextureLoading: boolean;
  1188. /**
  1189. * Gets the list of meshes imported to the scene through SceneLoader
  1190. */
  1191. importedMeshesFiles: String[];
  1192. /**
  1193. * Gets or sets a boolean indicating if probes are enabled on this scene
  1194. */
  1195. probesEnabled: boolean;
  1196. /**
  1197. * @hidden
  1198. */
  1199. database: Database;
  1200. /**
  1201. * Gets or sets the action manager associated with the scene
  1202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1203. */
  1204. actionManager: ActionManager;
  1205. private _meshesForIntersections;
  1206. /**
  1207. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1208. */
  1209. proceduralTexturesEnabled: boolean;
  1210. private _engine;
  1211. private _totalVertices;
  1212. /** @hidden */
  1213. _activeIndices: PerfCounter;
  1214. /** @hidden */
  1215. _activeParticles: PerfCounter;
  1216. /** @hidden */
  1217. _activeBones: PerfCounter;
  1218. private _animationRatio;
  1219. private _animationTimeLast;
  1220. private _animationTime;
  1221. /**
  1222. * Gets or sets a general scale for animation speed
  1223. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1224. */
  1225. animationTimeScale: number;
  1226. /** @hidden */
  1227. _cachedMaterial: Nullable<Material>;
  1228. /** @hidden */
  1229. _cachedEffect: Nullable<Effect>;
  1230. /** @hidden */
  1231. _cachedVisibility: Nullable<number>;
  1232. private _renderId;
  1233. private _frameId;
  1234. private _executeWhenReadyTimeoutId;
  1235. private _intermediateRendering;
  1236. private _viewUpdateFlag;
  1237. private _projectionUpdateFlag;
  1238. private _alternateViewUpdateFlag;
  1239. private _alternateProjectionUpdateFlag;
  1240. /** @hidden */
  1241. _toBeDisposed: Nullable<IDisposable>[];
  1242. private _activeRequests;
  1243. private _pendingData;
  1244. private _isDisposed;
  1245. /**
  1246. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1247. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1248. */
  1249. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1250. private _activeMeshes;
  1251. private _processedMaterials;
  1252. private _renderTargets;
  1253. /** @hidden */
  1254. _activeParticleSystems: SmartArray<IParticleSystem>;
  1255. private _activeSkeletons;
  1256. private _softwareSkinnedMeshes;
  1257. private _renderingManager;
  1258. /** @hidden */
  1259. _activeAnimatables: Animatable[];
  1260. private _transformMatrix;
  1261. private _sceneUbo;
  1262. private _alternateSceneUbo;
  1263. private _pickWithRayInverseMatrix;
  1264. private _viewMatrix;
  1265. private _projectionMatrix;
  1266. private _alternateViewMatrix;
  1267. private _alternateProjectionMatrix;
  1268. private _alternateTransformMatrix;
  1269. private _useAlternateCameraConfiguration;
  1270. private _alternateRendering;
  1271. /** @hidden */
  1272. _forcedViewPosition: Nullable<Vector3>;
  1273. /** @hidden */
  1274. readonly _isAlternateRenderingEnabled: boolean;
  1275. private _frustumPlanes;
  1276. /**
  1277. * Gets the list of frustum planes (built from the active camera)
  1278. */
  1279. readonly frustumPlanes: Plane[];
  1280. /**
  1281. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1282. * This is useful if there are more lights that the maximum simulteanous authorized
  1283. */
  1284. requireLightSorting: boolean;
  1285. private _pointerOverMesh;
  1286. private _pickedDownMesh;
  1287. private _pickedUpMesh;
  1288. private _externalData;
  1289. private _uid;
  1290. /**
  1291. * @hidden
  1292. * Backing store of defined scene components.
  1293. */
  1294. _components: ISceneComponent[];
  1295. /**
  1296. * @hidden
  1297. * Backing store of defined scene components.
  1298. */
  1299. _serializableComponents: ISceneSerializableComponent[];
  1300. /**
  1301. * List of components to register on the next registration step.
  1302. */
  1303. private _transientComponents;
  1304. /**
  1305. * Registers the transient components if needed.
  1306. */
  1307. private _registerTransientComponents;
  1308. /**
  1309. * @hidden
  1310. * Add a component to the scene.
  1311. * Note that the ccomponent could be registered on th next frame if this is called after
  1312. * the register component stage.
  1313. * @param component Defines the component to add to the scene
  1314. */
  1315. _addComponent(component: ISceneComponent): void;
  1316. /**
  1317. * @hidden
  1318. * Gets a component from the scene.
  1319. * @param name defines the name of the component to retrieve
  1320. * @returns the component or null if not present
  1321. */
  1322. _getComponent(name: string): Nullable<ISceneComponent>;
  1323. /**
  1324. * @hidden
  1325. * Defines the actions happening before camera updates.
  1326. */
  1327. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1328. /**
  1329. * @hidden
  1330. * Defines the actions happening before clear the canvas.
  1331. */
  1332. _beforeClearStage: Stage<SimpleStageAction>;
  1333. /**
  1334. * @hidden
  1335. * Defines the actions when collecting render targets for the frame.
  1336. */
  1337. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening for one camera in the frame.
  1341. */
  1342. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1343. /**
  1344. * @hidden
  1345. * Defines the actions happening during the per mesh ready checks.
  1346. */
  1347. _isReadyForMeshStage: Stage<MeshStageAction>;
  1348. /**
  1349. * @hidden
  1350. * Defines the actions happening before evaluate active mesh checks.
  1351. */
  1352. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1353. /**
  1354. * @hidden
  1355. * Defines the actions happening during the evaluate sub mesh checks.
  1356. */
  1357. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1358. /**
  1359. * @hidden
  1360. * Defines the actions happening during the active mesh stage.
  1361. */
  1362. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1363. /**
  1364. * @hidden
  1365. * Defines the actions happening during the per camera render target step.
  1366. */
  1367. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1368. /**
  1369. * @hidden
  1370. * Defines the actions happening just before the active camera is drawing.
  1371. */
  1372. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1373. /**
  1374. * @hidden
  1375. * Defines the actions happening just before a rendering group is drawing.
  1376. */
  1377. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1378. /**
  1379. * @hidden
  1380. * Defines the actions happening just before a mesh is drawing.
  1381. */
  1382. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1383. /**
  1384. * @hidden
  1385. * Defines the actions happening just after a mesh has been drawn.
  1386. */
  1387. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1388. /**
  1389. * @hidden
  1390. * Defines the actions happening just after a rendering group has been drawn.
  1391. */
  1392. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1393. /**
  1394. * @hidden
  1395. * Defines the actions happening just after the active camera has been drawn.
  1396. */
  1397. _afterCameraDrawStage: Stage<CameraStageAction>;
  1398. /**
  1399. * @hidden
  1400. * Defines the actions happening just after rendering all cameras and computing intersections.
  1401. */
  1402. _afterRenderStage: Stage<SimpleStageAction>;
  1403. /**
  1404. * @hidden
  1405. * Defines the actions happening when a pointer move event happens.
  1406. */
  1407. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1408. /**
  1409. * @hidden
  1410. * Defines the actions happening when a pointer down event happens.
  1411. */
  1412. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1413. /**
  1414. * @hidden
  1415. * Defines the actions happening when a pointer up event happens.
  1416. */
  1417. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1418. /**
  1419. * Creates a new Scene
  1420. * @param engine defines the engine to use to render this scene
  1421. */
  1422. constructor(engine: Engine);
  1423. private _defaultMeshCandidates;
  1424. /**
  1425. * @hidden
  1426. */
  1427. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1428. private _defaultSubMeshCandidates;
  1429. /**
  1430. * @hidden
  1431. */
  1432. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1433. /**
  1434. * Sets the default candidate providers for the scene.
  1435. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1436. * and getCollidingSubMeshCandidates to their default function
  1437. */
  1438. setDefaultCandidateProviders(): void;
  1439. /**
  1440. * Gets a boolean indicating if collisions are processed on a web worker
  1441. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1442. */
  1443. workerCollisions: boolean;
  1444. /**
  1445. * Gets the mesh that is currently under the pointer
  1446. */
  1447. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1448. /**
  1449. * Gets the current on-screen X position of the pointer
  1450. */
  1451. readonly pointerX: number;
  1452. /**
  1453. * Gets the current on-screen Y position of the pointer
  1454. */
  1455. readonly pointerY: number;
  1456. /**
  1457. * Gets the cached material (ie. the latest rendered one)
  1458. * @returns the cached material
  1459. */
  1460. getCachedMaterial(): Nullable<Material>;
  1461. /**
  1462. * Gets the cached effect (ie. the latest rendered one)
  1463. * @returns the cached effect
  1464. */
  1465. getCachedEffect(): Nullable<Effect>;
  1466. /**
  1467. * Gets the cached visibility state (ie. the latest rendered one)
  1468. * @returns the cached visibility state
  1469. */
  1470. getCachedVisibility(): Nullable<number>;
  1471. /**
  1472. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1473. * @param material defines the current material
  1474. * @param effect defines the current effect
  1475. * @param visibility defines the current visibility state
  1476. * @returns true if one parameter is not cached
  1477. */
  1478. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1479. /**
  1480. * Gets the engine associated with the scene
  1481. * @returns an Engine
  1482. */
  1483. getEngine(): Engine;
  1484. /**
  1485. * Gets the total number of vertices rendered per frame
  1486. * @returns the total number of vertices rendered per frame
  1487. */
  1488. getTotalVertices(): number;
  1489. /**
  1490. * Gets the performance counter for total vertices
  1491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1492. */
  1493. readonly totalVerticesPerfCounter: PerfCounter;
  1494. /**
  1495. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1496. * @returns the total number of active indices rendered per frame
  1497. */
  1498. getActiveIndices(): number;
  1499. /**
  1500. * Gets the performance counter for active indices
  1501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1502. */
  1503. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1504. /**
  1505. * Gets the total number of active particles rendered per frame
  1506. * @returns the total number of active particles rendered per frame
  1507. */
  1508. getActiveParticles(): number;
  1509. /**
  1510. * Gets the performance counter for active particles
  1511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1512. */
  1513. readonly activeParticlesPerfCounter: PerfCounter;
  1514. /**
  1515. * Gets the total number of active bones rendered per frame
  1516. * @returns the total number of active bones rendered per frame
  1517. */
  1518. getActiveBones(): number;
  1519. /**
  1520. * Gets the performance counter for active bones
  1521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1522. */
  1523. readonly activeBonesPerfCounter: PerfCounter;
  1524. /** @hidden */
  1525. getInterFramePerfCounter(): number;
  1526. /** @hidden */
  1527. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1528. /** @hidden */
  1529. getLastFrameDuration(): number;
  1530. /** @hidden */
  1531. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1532. /** @hidden */
  1533. getEvaluateActiveMeshesDuration(): number;
  1534. /** @hidden */
  1535. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1536. /**
  1537. * Gets the array of active meshes
  1538. * @returns an array of AbstractMesh
  1539. */
  1540. getActiveMeshes(): SmartArray<AbstractMesh>;
  1541. /** @hidden */
  1542. getRenderTargetsDuration(): number;
  1543. /** @hidden */
  1544. getRenderDuration(): number;
  1545. /** @hidden */
  1546. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1547. /** @hidden */
  1548. getParticlesDuration(): number;
  1549. /** @hidden */
  1550. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1551. /** @hidden */
  1552. getSpritesDuration(): number;
  1553. /** @hidden */
  1554. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1555. /**
  1556. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1557. * @returns a number
  1558. */
  1559. getAnimationRatio(): number;
  1560. /**
  1561. * Gets an unique Id for the current render phase
  1562. * @returns a number
  1563. */
  1564. getRenderId(): number;
  1565. /**
  1566. * Gets an unique Id for the current frame
  1567. * @returns a number
  1568. */
  1569. getFrameId(): number;
  1570. /** Call this function if you want to manually increment the render Id*/
  1571. incrementRenderId(): void;
  1572. private _updatePointerPosition;
  1573. private _createUbo;
  1574. private _createAlternateUbo;
  1575. private _setRayOnPointerInfo;
  1576. /**
  1577. * Use this method to simulate a pointer move on a mesh
  1578. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1579. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1580. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1581. * @returns the current scene
  1582. */
  1583. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1584. private _processPointerMove;
  1585. private _checkPrePointerObservable;
  1586. /**
  1587. * Use this method to simulate a pointer down on a mesh
  1588. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1589. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1590. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1591. * @returns the current scene
  1592. */
  1593. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1594. private _processPointerDown;
  1595. /**
  1596. * Use this method to simulate a pointer up on a mesh
  1597. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1598. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1599. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1600. * @returns the current scene
  1601. */
  1602. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1603. private _processPointerUp;
  1604. /**
  1605. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1606. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1607. * @returns true if the pointer was captured
  1608. */
  1609. isPointerCaptured(pointerId?: number): boolean;
  1610. /** @hidden */
  1611. _isPointerSwiping(): boolean;
  1612. /**
  1613. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1614. * @param attachUp defines if you want to attach events to pointerup
  1615. * @param attachDown defines if you want to attach events to pointerdown
  1616. * @param attachMove defines if you want to attach events to pointermove
  1617. */
  1618. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1619. /** Detaches all event handlers*/
  1620. detachControl(): void;
  1621. /**
  1622. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1623. * Delay loaded resources are not taking in account
  1624. * @return true if all required resources are ready
  1625. */
  1626. isReady(): boolean;
  1627. /** Resets all cached information relative to material (including effect and visibility) */
  1628. resetCachedMaterial(): void;
  1629. /**
  1630. * Registers a function to be called before every frame render
  1631. * @param func defines the function to register
  1632. */
  1633. registerBeforeRender(func: () => void): void;
  1634. /**
  1635. * Unregisters a function called before every frame render
  1636. * @param func defines the function to unregister
  1637. */
  1638. unregisterBeforeRender(func: () => void): void;
  1639. /**
  1640. * Registers a function to be called after every frame render
  1641. * @param func defines the function to register
  1642. */
  1643. registerAfterRender(func: () => void): void;
  1644. /**
  1645. * Unregisters a function called after every frame render
  1646. * @param func defines the function to unregister
  1647. */
  1648. unregisterAfterRender(func: () => void): void;
  1649. private _executeOnceBeforeRender;
  1650. /**
  1651. * The provided function will run before render once and will be disposed afterwards.
  1652. * A timeout delay can be provided so that the function will be executed in N ms.
  1653. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1654. * @param func The function to be executed.
  1655. * @param timeout optional delay in ms
  1656. */
  1657. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1658. /** @hidden */
  1659. _addPendingData(data: any): void;
  1660. /** @hidden */
  1661. _removePendingData(data: any): void;
  1662. /**
  1663. * Returns the number of items waiting to be loaded
  1664. * @returns the number of items waiting to be loaded
  1665. */
  1666. getWaitingItemsCount(): number;
  1667. /**
  1668. * Returns a boolean indicating if the scene is still loading data
  1669. */
  1670. readonly isLoading: boolean;
  1671. /**
  1672. * Registers a function to be executed when the scene is ready
  1673. * @param {Function} func - the function to be executed
  1674. */
  1675. executeWhenReady(func: () => void): void;
  1676. /**
  1677. * Returns a promise that resolves when the scene is ready
  1678. * @returns A promise that resolves when the scene is ready
  1679. */
  1680. whenReadyAsync(): Promise<void>;
  1681. /** @hidden */
  1682. _checkIsReady(): void;
  1683. /**
  1684. * Will start the animation sequence of a given target
  1685. * @param target defines the target
  1686. * @param from defines from which frame should animation start
  1687. * @param to defines until which frame should animation run.
  1688. * @param weight defines the weight to apply to the animation (1.0 by default)
  1689. * @param loop defines if the animation loops
  1690. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1691. * @param onAnimationEnd defines the function to be executed when the animation ends
  1692. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1693. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1694. * @returns the animatable object created for this animation
  1695. */
  1696. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1697. /**
  1698. * Will start the animation sequence of a given target
  1699. * @param target defines the target
  1700. * @param from defines from which frame should animation start
  1701. * @param to defines until which frame should animation run.
  1702. * @param loop defines if the animation loops
  1703. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1704. * @param onAnimationEnd defines the function to be executed when the animation ends
  1705. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1706. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1707. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1708. * @returns the animatable object created for this animation
  1709. */
  1710. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1711. /**
  1712. * Begin a new animation on a given node
  1713. * @param target defines the target where the animation will take place
  1714. * @param animations defines the list of animations to start
  1715. * @param from defines the initial value
  1716. * @param to defines the final value
  1717. * @param loop defines if you want animation to loop (off by default)
  1718. * @param speedRatio defines the speed ratio to apply to all animations
  1719. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1720. * @returns the list of created animatables
  1721. */
  1722. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1723. /**
  1724. * Begin a new animation on a given node and its hierarchy
  1725. * @param target defines the root node where the animation will take place
  1726. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1727. * @param animations defines the list of animations to start
  1728. * @param from defines the initial value
  1729. * @param to defines the final value
  1730. * @param loop defines if you want animation to loop (off by default)
  1731. * @param speedRatio defines the speed ratio to apply to all animations
  1732. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1733. * @returns the list of animatables created for all nodes
  1734. */
  1735. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1736. /**
  1737. * Gets the animatable associated with a specific target
  1738. * @param target defines the target of the animatable
  1739. * @returns the required animatable if found
  1740. */
  1741. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1742. /**
  1743. * Gets all animatables associated with a given target
  1744. * @param target defines the target to look animatables for
  1745. * @returns an array of Animatables
  1746. */
  1747. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1748. /**
  1749. * Gets all animatable attached to the scene
  1750. */
  1751. readonly animatables: Animatable[];
  1752. /**
  1753. * Will stop the animation of the given target
  1754. * @param target - the target
  1755. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1756. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1757. */
  1758. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1759. /**
  1760. * Stops and removes all animations that have been applied to the scene
  1761. */
  1762. stopAllAnimations(): void;
  1763. private _animate;
  1764. /** @hidden */
  1765. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1766. private _processLateAnimationBindingsForMatrices;
  1767. private _processLateAnimationBindingsForQuaternions;
  1768. private _processLateAnimationBindings;
  1769. /** @hidden */
  1770. _switchToAlternateCameraConfiguration(active: boolean): void;
  1771. /**
  1772. * Gets the current view matrix
  1773. * @returns a Matrix
  1774. */
  1775. getViewMatrix(): Matrix;
  1776. /**
  1777. * Gets the current projection matrix
  1778. * @returns a Matrix
  1779. */
  1780. getProjectionMatrix(): Matrix;
  1781. /**
  1782. * Gets the current transform matrix
  1783. * @returns a Matrix made of View * Projection
  1784. */
  1785. getTransformMatrix(): Matrix;
  1786. /**
  1787. * Sets the current transform matrix
  1788. * @param view defines the View matrix to use
  1789. * @param projection defines the Projection matrix to use
  1790. */
  1791. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1792. /** @hidden */
  1793. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1794. /**
  1795. * Gets the uniform buffer used to store scene data
  1796. * @returns a UniformBuffer
  1797. */
  1798. getSceneUniformBuffer(): UniformBuffer;
  1799. /**
  1800. * Gets an unique (relatively to the current scene) Id
  1801. * @returns an unique number for the scene
  1802. */
  1803. getUniqueId(): number;
  1804. /**
  1805. * Add a mesh to the list of scene's meshes
  1806. * @param newMesh defines the mesh to add
  1807. * @param recursive if all child meshes should also be added to the scene
  1808. */
  1809. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1810. /**
  1811. * Remove a mesh for the list of scene's meshes
  1812. * @param toRemove defines the mesh to remove
  1813. * @param recursive if all child meshes should also be removed from the scene
  1814. * @returns the index where the mesh was in the mesh list
  1815. */
  1816. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1817. /**
  1818. * Add a transform node to the list of scene's transform nodes
  1819. * @param newTransformNode defines the transform node to add
  1820. */
  1821. addTransformNode(newTransformNode: TransformNode): void;
  1822. /**
  1823. * Remove a transform node for the list of scene's transform nodes
  1824. * @param toRemove defines the transform node to remove
  1825. * @returns the index where the transform node was in the transform node list
  1826. */
  1827. removeTransformNode(toRemove: TransformNode): number;
  1828. /**
  1829. * Remove a skeleton for the list of scene's skeletons
  1830. * @param toRemove defines the skeleton to remove
  1831. * @returns the index where the skeleton was in the skeleton list
  1832. */
  1833. removeSkeleton(toRemove: Skeleton): number;
  1834. /**
  1835. * Remove a morph target for the list of scene's morph targets
  1836. * @param toRemove defines the morph target to remove
  1837. * @returns the index where the morph target was in the morph target list
  1838. */
  1839. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1840. /**
  1841. * Remove a light for the list of scene's lights
  1842. * @param toRemove defines the light to remove
  1843. * @returns the index where the light was in the light list
  1844. */
  1845. removeLight(toRemove: Light): number;
  1846. /**
  1847. * Remove a camera for the list of scene's cameras
  1848. * @param toRemove defines the camera to remove
  1849. * @returns the index where the camera was in the camera list
  1850. */
  1851. removeCamera(toRemove: Camera): number;
  1852. /**
  1853. * Remove a particle system for the list of scene's particle systems
  1854. * @param toRemove defines the particle system to remove
  1855. * @returns the index where the particle system was in the particle system list
  1856. */
  1857. removeParticleSystem(toRemove: IParticleSystem): number;
  1858. /**
  1859. * Remove a animation for the list of scene's animations
  1860. * @param toRemove defines the animation to remove
  1861. * @returns the index where the animation was in the animation list
  1862. */
  1863. removeAnimation(toRemove: Animation): number;
  1864. /**
  1865. * Removes the given animation group from this scene.
  1866. * @param toRemove The animation group to remove
  1867. * @returns The index of the removed animation group
  1868. */
  1869. removeAnimationGroup(toRemove: AnimationGroup): number;
  1870. /**
  1871. * Removes the given multi-material from this scene.
  1872. * @param toRemove The multi-material to remove
  1873. * @returns The index of the removed multi-material
  1874. */
  1875. removeMultiMaterial(toRemove: MultiMaterial): number;
  1876. /**
  1877. * Removes the given material from this scene.
  1878. * @param toRemove The material to remove
  1879. * @returns The index of the removed material
  1880. */
  1881. removeMaterial(toRemove: Material): number;
  1882. /**
  1883. * Removes the given action manager from this scene.
  1884. * @param toRemove The action manager to remove
  1885. * @returns The index of the removed action manager
  1886. */
  1887. removeActionManager(toRemove: ActionManager): number;
  1888. /**
  1889. * Removes the given texture from this scene.
  1890. * @param toRemove The texture to remove
  1891. * @returns The index of the removed texture
  1892. */
  1893. removeTexture(toRemove: BaseTexture): number;
  1894. /**
  1895. * Adds the given light to this scene
  1896. * @param newLight The light to add
  1897. */
  1898. addLight(newLight: Light): void;
  1899. /**
  1900. * Sorts the list list based on light priorities
  1901. */
  1902. sortLightsByPriority(): void;
  1903. /**
  1904. * Adds the given camera to this scene
  1905. * @param newCamera The camera to add
  1906. */
  1907. addCamera(newCamera: Camera): void;
  1908. /**
  1909. * Adds the given skeleton to this scene
  1910. * @param newSkeleton The skeleton to add
  1911. */
  1912. addSkeleton(newSkeleton: Skeleton): void;
  1913. /**
  1914. * Adds the given particle system to this scene
  1915. * @param newParticleSystem The particle system to add
  1916. */
  1917. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1918. /**
  1919. * Adds the given animation to this scene
  1920. * @param newAnimation The animation to add
  1921. */
  1922. addAnimation(newAnimation: Animation): void;
  1923. /**
  1924. * Adds the given animation group to this scene.
  1925. * @param newAnimationGroup The animation group to add
  1926. */
  1927. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1928. /**
  1929. * Adds the given multi-material to this scene
  1930. * @param newMultiMaterial The multi-material to add
  1931. */
  1932. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1933. /**
  1934. * Adds the given material to this scene
  1935. * @param newMaterial The material to add
  1936. */
  1937. addMaterial(newMaterial: Material): void;
  1938. /**
  1939. * Adds the given morph target to this scene
  1940. * @param newMorphTargetManager The morph target to add
  1941. */
  1942. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1943. /**
  1944. * Adds the given geometry to this scene
  1945. * @param newGeometry The geometry to add
  1946. */
  1947. addGeometry(newGeometry: Geometry): void;
  1948. /**
  1949. * Adds the given action manager to this scene
  1950. * @param newActionManager The action manager to add
  1951. */
  1952. addActionManager(newActionManager: ActionManager): void;
  1953. /**
  1954. * Adds the given texture to this scene.
  1955. * @param newTexture The texture to add
  1956. */
  1957. addTexture(newTexture: BaseTexture): void;
  1958. /**
  1959. * Switch active camera
  1960. * @param newCamera defines the new active camera
  1961. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1962. */
  1963. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1964. /**
  1965. * sets the active camera of the scene using its ID
  1966. * @param id defines the camera's ID
  1967. * @return the new active camera or null if none found.
  1968. */
  1969. setActiveCameraByID(id: string): Nullable<Camera>;
  1970. /**
  1971. * sets the active camera of the scene using its name
  1972. * @param name defines the camera's name
  1973. * @returns the new active camera or null if none found.
  1974. */
  1975. setActiveCameraByName(name: string): Nullable<Camera>;
  1976. /**
  1977. * get an animation group using its name
  1978. * @param name defines the material's name
  1979. * @return the animation group or null if none found.
  1980. */
  1981. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1982. /**
  1983. * get a material using its id
  1984. * @param id defines the material's ID
  1985. * @return the material or null if none found.
  1986. */
  1987. getMaterialByID(id: string): Nullable<Material>;
  1988. /**
  1989. * Gets a material using its name
  1990. * @param name defines the material's name
  1991. * @return the material or null if none found.
  1992. */
  1993. getMaterialByName(name: string): Nullable<Material>;
  1994. /**
  1995. * Gets a camera using its id
  1996. * @param id defines the id to look for
  1997. * @returns the camera or null if not found
  1998. */
  1999. getCameraByID(id: string): Nullable<Camera>;
  2000. /**
  2001. * Gets a camera using its unique id
  2002. * @param uniqueId defines the unique id to look for
  2003. * @returns the camera or null if not found
  2004. */
  2005. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2006. /**
  2007. * Gets a camera using its name
  2008. * @param name defines the camera's name
  2009. * @return the camera or null if none found.
  2010. */
  2011. getCameraByName(name: string): Nullable<Camera>;
  2012. /**
  2013. * Gets a bone using its id
  2014. * @param id defines the bone's id
  2015. * @return the bone or null if not found
  2016. */
  2017. getBoneByID(id: string): Nullable<Bone>;
  2018. /**
  2019. * Gets a bone using its id
  2020. * @param name defines the bone's name
  2021. * @return the bone or null if not found
  2022. */
  2023. getBoneByName(name: string): Nullable<Bone>;
  2024. /**
  2025. * Gets a light node using its name
  2026. * @param name defines the the light's name
  2027. * @return the light or null if none found.
  2028. */
  2029. getLightByName(name: string): Nullable<Light>;
  2030. /**
  2031. * Gets a light node using its id
  2032. * @param id defines the light's id
  2033. * @return the light or null if none found.
  2034. */
  2035. getLightByID(id: string): Nullable<Light>;
  2036. /**
  2037. * Gets a light node using its scene-generated unique ID
  2038. * @param uniqueId defines the light's unique id
  2039. * @return the light or null if none found.
  2040. */
  2041. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2042. /**
  2043. * Gets a particle system by id
  2044. * @param id defines the particle system id
  2045. * @return the corresponding system or null if none found
  2046. */
  2047. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2048. /**
  2049. * Gets a geometry using its ID
  2050. * @param id defines the geometry's id
  2051. * @return the geometry or null if none found.
  2052. */
  2053. getGeometryByID(id: string): Nullable<Geometry>;
  2054. /**
  2055. * Add a new geometry to this scene
  2056. * @param geometry defines the geometry to be added to the scene.
  2057. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2058. * @return a boolean defining if the geometry was added or not
  2059. */
  2060. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2061. /**
  2062. * Removes an existing geometry
  2063. * @param geometry defines the geometry to be removed from the scene
  2064. * @return a boolean defining if the geometry was removed or not
  2065. */
  2066. removeGeometry(geometry: Geometry): boolean;
  2067. /**
  2068. * Gets the list of geometries attached to the scene
  2069. * @returns an array of Geometry
  2070. */
  2071. getGeometries(): Geometry[];
  2072. /**
  2073. * Gets the first added mesh found of a given ID
  2074. * @param id defines the id to search for
  2075. * @return the mesh found or null if not found at all
  2076. */
  2077. getMeshByID(id: string): Nullable<AbstractMesh>;
  2078. /**
  2079. * Gets a list of meshes using their id
  2080. * @param id defines the id to search for
  2081. * @returns a list of meshes
  2082. */
  2083. getMeshesByID(id: string): Array<AbstractMesh>;
  2084. /**
  2085. * Gets the first added transform node found of a given ID
  2086. * @param id defines the id to search for
  2087. * @return the found transform node or null if not found at all.
  2088. */
  2089. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2090. /**
  2091. * Gets a list of transform nodes using their id
  2092. * @param id defines the id to search for
  2093. * @returns a list of transform nodes
  2094. */
  2095. getTransformNodesByID(id: string): Array<TransformNode>;
  2096. /**
  2097. * Gets a mesh with its auto-generated unique id
  2098. * @param uniqueId defines the unique id to search for
  2099. * @return the found mesh or null if not found at all.
  2100. */
  2101. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2102. /**
  2103. * Gets a the last added mesh using a given id
  2104. * @param id defines the id to search for
  2105. * @return the found mesh or null if not found at all.
  2106. */
  2107. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2108. /**
  2109. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2110. * @param id defines the id to search for
  2111. * @return the found node or null if not found at all
  2112. */
  2113. getLastEntryByID(id: string): Nullable<Node>;
  2114. /**
  2115. * Gets a node (Mesh, Camera, Light) using a given id
  2116. * @param id defines the id to search for
  2117. * @return the found node or null if not found at all
  2118. */
  2119. getNodeByID(id: string): Nullable<Node>;
  2120. /**
  2121. * Gets a node (Mesh, Camera, Light) using a given name
  2122. * @param name defines the name to search for
  2123. * @return the found node or null if not found at all.
  2124. */
  2125. getNodeByName(name: string): Nullable<Node>;
  2126. /**
  2127. * Gets a mesh using a given name
  2128. * @param name defines the name to search for
  2129. * @return the found mesh or null if not found at all.
  2130. */
  2131. getMeshByName(name: string): Nullable<AbstractMesh>;
  2132. /**
  2133. * Gets a transform node using a given name
  2134. * @param name defines the name to search for
  2135. * @return the found transform node or null if not found at all.
  2136. */
  2137. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2138. /**
  2139. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2140. * @param id defines the id to search for
  2141. * @return the found skeleton or null if not found at all.
  2142. */
  2143. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2144. /**
  2145. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2146. * @param id defines the id to search for
  2147. * @return the found skeleton or null if not found at all.
  2148. */
  2149. getSkeletonById(id: string): Nullable<Skeleton>;
  2150. /**
  2151. * Gets a skeleton using a given name
  2152. * @param name defines the name to search for
  2153. * @return the found skeleton or null if not found at all.
  2154. */
  2155. getSkeletonByName(name: string): Nullable<Skeleton>;
  2156. /**
  2157. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2158. * @param id defines the id to search for
  2159. * @return the found morph target manager or null if not found at all.
  2160. */
  2161. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2162. /**
  2163. * Gets a boolean indicating if the given mesh is active
  2164. * @param mesh defines the mesh to look for
  2165. * @returns true if the mesh is in the active list
  2166. */
  2167. isActiveMesh(mesh: AbstractMesh): boolean;
  2168. /**
  2169. * Return a unique id as a string which can serve as an identifier for the scene
  2170. */
  2171. readonly uid: string;
  2172. /**
  2173. * Add an externaly attached data from its key.
  2174. * This method call will fail and return false, if such key already exists.
  2175. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2176. * @param key the unique key that identifies the data
  2177. * @param data the data object to associate to the key for this Engine instance
  2178. * @return true if no such key were already present and the data was added successfully, false otherwise
  2179. */
  2180. addExternalData<T>(key: string, data: T): boolean;
  2181. /**
  2182. * Get an externaly attached data from its key
  2183. * @param key the unique key that identifies the data
  2184. * @return the associated data, if present (can be null), or undefined if not present
  2185. */
  2186. getExternalData<T>(key: string): Nullable<T>;
  2187. /**
  2188. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2189. * @param key the unique key that identifies the data
  2190. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2191. * @return the associated data, can be null if the factory returned null.
  2192. */
  2193. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2194. /**
  2195. * Remove an externaly attached data from the Engine instance
  2196. * @param key the unique key that identifies the data
  2197. * @return true if the data was successfully removed, false if it doesn't exist
  2198. */
  2199. removeExternalData(key: string): boolean;
  2200. private _evaluateSubMesh;
  2201. /**
  2202. * Clear the processed materials smart array preventing retention point in material dispose.
  2203. */
  2204. freeProcessedMaterials(): void;
  2205. /**
  2206. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2207. */
  2208. freeActiveMeshes(): void;
  2209. /**
  2210. * Clear the info related to rendering groups preventing retention points during dispose.
  2211. */
  2212. freeRenderingGroups(): void;
  2213. /** @hidden */
  2214. _isInIntermediateRendering(): boolean;
  2215. /**
  2216. * Lambda returning the list of potentially active meshes.
  2217. */
  2218. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2219. /**
  2220. * Lambda returning the list of potentially active sub meshes.
  2221. */
  2222. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2223. /**
  2224. * Lambda returning the list of potentially intersecting sub meshes.
  2225. */
  2226. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2227. /**
  2228. * Lambda returning the list of potentially colliding sub meshes.
  2229. */
  2230. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2231. private _activeMeshesFrozen;
  2232. /**
  2233. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2234. * @returns the current scene
  2235. */
  2236. freezeActiveMeshes(): Scene;
  2237. /**
  2238. * Use this function to restart evaluating active meshes on every frame
  2239. * @returns the current scene
  2240. */
  2241. unfreezeActiveMeshes(): Scene;
  2242. private _evaluateActiveMeshes;
  2243. private _activeMesh;
  2244. /**
  2245. * Update the transform matrix to update from the current active camera
  2246. * @param force defines a boolean used to force the update even if cache is up to date
  2247. */
  2248. updateTransformMatrix(force?: boolean): void;
  2249. /**
  2250. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2251. * @param alternateCamera defines the camera to use
  2252. */
  2253. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2254. /** @hidden */
  2255. _allowPostProcessClearColor: boolean;
  2256. private _renderForCamera;
  2257. private _processSubCameras;
  2258. private _checkIntersections;
  2259. /** @hidden */
  2260. _advancePhysicsEngineStep(step: number): void;
  2261. /**
  2262. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2263. */
  2264. getDeterministicFrameTime: () => number;
  2265. /**
  2266. * Render the scene
  2267. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2268. */
  2269. render(updateCameras?: boolean): void;
  2270. /**
  2271. * Freeze all materials
  2272. * A frozen material will not be updatable but should be faster to render
  2273. */
  2274. freezeMaterials(): void;
  2275. /**
  2276. * Unfreeze all materials
  2277. * A frozen material will not be updatable but should be faster to render
  2278. */
  2279. unfreezeMaterials(): void;
  2280. /**
  2281. * Releases all held ressources
  2282. */
  2283. dispose(): void;
  2284. /**
  2285. * Gets if the scene is already disposed
  2286. */
  2287. readonly isDisposed: boolean;
  2288. /**
  2289. * Call this function to reduce memory footprint of the scene.
  2290. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2291. */
  2292. clearCachedVertexData(): void;
  2293. /**
  2294. * This function will remove the local cached buffer data from texture.
  2295. * It will save memory but will prevent the texture from being rebuilt
  2296. */
  2297. cleanCachedTextureBuffer(): void;
  2298. /**
  2299. * Get the world extend vectors with an optional filter
  2300. *
  2301. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2302. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2303. */
  2304. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2305. min: Vector3;
  2306. max: Vector3;
  2307. };
  2308. /**
  2309. * Creates a ray that can be used to pick in the scene
  2310. * @param x defines the x coordinate of the origin (on-screen)
  2311. * @param y defines the y coordinate of the origin (on-screen)
  2312. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2313. * @param camera defines the camera to use for the picking
  2314. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2315. * @returns a Ray
  2316. */
  2317. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2318. /**
  2319. * Creates a ray that can be used to pick in the scene
  2320. * @param x defines the x coordinate of the origin (on-screen)
  2321. * @param y defines the y coordinate of the origin (on-screen)
  2322. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2323. * @param result defines the ray where to store the picking ray
  2324. * @param camera defines the camera to use for the picking
  2325. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2326. * @returns the current scene
  2327. */
  2328. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2329. /**
  2330. * Creates a ray that can be used to pick in the scene
  2331. * @param x defines the x coordinate of the origin (on-screen)
  2332. * @param y defines the y coordinate of the origin (on-screen)
  2333. * @param camera defines the camera to use for the picking
  2334. * @returns a Ray
  2335. */
  2336. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2337. /**
  2338. * Creates a ray that can be used to pick in the scene
  2339. * @param x defines the x coordinate of the origin (on-screen)
  2340. * @param y defines the y coordinate of the origin (on-screen)
  2341. * @param result defines the ray where to store the picking ray
  2342. * @param camera defines the camera to use for the picking
  2343. * @returns the current scene
  2344. */
  2345. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2346. private _internalPick;
  2347. private _internalMultiPick;
  2348. private _tempPickingRay;
  2349. /** Launch a ray to try to pick a mesh in the scene
  2350. * @param x position on screen
  2351. * @param y position on screen
  2352. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2353. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2354. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2355. * @returns a PickingInfo
  2356. */
  2357. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2358. private _cachedRayForTransform;
  2359. /** Use the given ray to pick a mesh in the scene
  2360. * @param ray The ray to use to pick meshes
  2361. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2362. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2363. * @returns a PickingInfo
  2364. */
  2365. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2366. /**
  2367. * Launch a ray to try to pick a mesh in the scene
  2368. * @param x X position on screen
  2369. * @param y Y position on screen
  2370. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2371. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2372. * @returns an array of PickingInfo
  2373. */
  2374. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2375. /**
  2376. * Launch a ray to try to pick a mesh in the scene
  2377. * @param ray Ray to use
  2378. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2379. * @returns an array of PickingInfo
  2380. */
  2381. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2382. /**
  2383. * Force the value of meshUnderPointer
  2384. * @param mesh defines the mesh to use
  2385. */
  2386. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2387. /**
  2388. * Gets the mesh under the pointer
  2389. * @returns a Mesh or null if no mesh is under the pointer
  2390. */
  2391. getPointerOverMesh(): Nullable<AbstractMesh>;
  2392. /** @hidden */
  2393. _rebuildGeometries(): void;
  2394. /** @hidden */
  2395. _rebuildTextures(): void;
  2396. private _getByTags;
  2397. /**
  2398. * Get a list of meshes by tags
  2399. * @param tagsQuery defines the tags query to use
  2400. * @param forEach defines a predicate used to filter results
  2401. * @returns an array of Mesh
  2402. */
  2403. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2404. /**
  2405. * Get a list of cameras by tags
  2406. * @param tagsQuery defines the tags query to use
  2407. * @param forEach defines a predicate used to filter results
  2408. * @returns an array of Camera
  2409. */
  2410. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2411. /**
  2412. * Get a list of lights by tags
  2413. * @param tagsQuery defines the tags query to use
  2414. * @param forEach defines a predicate used to filter results
  2415. * @returns an array of Light
  2416. */
  2417. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2418. /**
  2419. * Get a list of materials by tags
  2420. * @param tagsQuery defines the tags query to use
  2421. * @param forEach defines a predicate used to filter results
  2422. * @returns an array of Material
  2423. */
  2424. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2425. /**
  2426. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2427. * This allowed control for front to back rendering or reversly depending of the special needs.
  2428. *
  2429. * @param renderingGroupId The rendering group id corresponding to its index
  2430. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2431. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2432. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2433. */
  2434. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2435. /**
  2436. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2437. *
  2438. * @param renderingGroupId The rendering group id corresponding to its index
  2439. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2440. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2441. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2442. */
  2443. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2444. /**
  2445. * Gets the current auto clear configuration for one rendering group of the rendering
  2446. * manager.
  2447. * @param index the rendering group index to get the information for
  2448. * @returns The auto clear setup for the requested rendering group
  2449. */
  2450. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2451. private _blockMaterialDirtyMechanism;
  2452. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2453. blockMaterialDirtyMechanism: boolean;
  2454. /**
  2455. * Will flag all materials as dirty to trigger new shader compilation
  2456. * @param flag defines the flag used to specify which material part must be marked as dirty
  2457. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2458. */
  2459. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2460. /** @hidden */
  2461. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2462. /** @hidden */
  2463. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2464. }
  2465. }
  2466. declare module BABYLON {
  2467. /**
  2468. * Groups all the scene component constants in one place to ease maintenance.
  2469. * @hidden
  2470. */
  2471. class SceneComponentConstants {
  2472. static readonly NAME_EFFECTLAYER: string;
  2473. static readonly NAME_LAYER: string;
  2474. static readonly NAME_LENSFLARESYSTEM: string;
  2475. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2476. static readonly NAME_PARTICLESYSTEM: string;
  2477. static readonly NAME_GAMEPAD: string;
  2478. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2479. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2480. static readonly NAME_DEPTHRENDERER: string;
  2481. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2482. static readonly NAME_SPRITE: string;
  2483. static readonly NAME_OUTLINERENDERER: string;
  2484. static readonly NAME_PROCEDURALTEXTURE: string;
  2485. static readonly NAME_SHADOWGENERATOR: string;
  2486. static readonly NAME_OCTREE: string;
  2487. static readonly NAME_PHYSICSENGINE: string;
  2488. static readonly NAME_AUDIO: string;
  2489. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2490. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2491. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2492. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2493. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2494. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2495. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2496. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2497. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2498. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2499. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2500. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2501. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2502. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2503. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2504. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2505. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2506. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2507. static readonly STEP_AFTERRENDER_AUDIO: number;
  2508. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2509. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2510. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2511. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2512. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2513. static readonly STEP_POINTERMOVE_SPRITE: number;
  2514. static readonly STEP_POINTERDOWN_SPRITE: number;
  2515. static readonly STEP_POINTERUP_SPRITE: number;
  2516. }
  2517. /**
  2518. * This represents a scene component.
  2519. *
  2520. * This is used to decouple the dependency the scene is having on the different workloads like
  2521. * layers, post processes...
  2522. */
  2523. interface ISceneComponent {
  2524. /**
  2525. * The name of the component. Each component must have a unique name.
  2526. */
  2527. name: string;
  2528. /**
  2529. * The scene the component belongs to.
  2530. */
  2531. scene: Scene;
  2532. /**
  2533. * Register the component to one instance of a scene.
  2534. */
  2535. register(): void;
  2536. /**
  2537. * Rebuilds the elements related to this component in case of
  2538. * context lost for instance.
  2539. */
  2540. rebuild(): void;
  2541. /**
  2542. * Disposes the component and the associated ressources.
  2543. */
  2544. dispose(): void;
  2545. }
  2546. /**
  2547. * This represents a SERIALIZABLE scene component.
  2548. *
  2549. * This extends Scene Component to add Serialization methods on top.
  2550. */
  2551. interface ISceneSerializableComponent extends ISceneComponent {
  2552. /**
  2553. * Adds all the element from the container to the scene
  2554. * @param container the container holding the elements
  2555. */
  2556. addFromContainer(container: AbstractScene): void;
  2557. /**
  2558. * Removes all the elements in the container from the scene
  2559. * @param container contains the elements to remove
  2560. */
  2561. removeFromContainer(container: AbstractScene): void;
  2562. /**
  2563. * Serializes the component data to the specified json object
  2564. * @param serializationObject The object to serialize to
  2565. */
  2566. serialize(serializationObject: any): void;
  2567. }
  2568. /**
  2569. * Strong typing of a Mesh related stage step action
  2570. */
  2571. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2572. /**
  2573. * Strong typing of a Evaluate Sub Mesh related stage step action
  2574. */
  2575. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2576. /**
  2577. * Strong typing of a Active Mesh related stage step action
  2578. */
  2579. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2580. /**
  2581. * Strong typing of a Camera related stage step action
  2582. */
  2583. type CameraStageAction = (camera: Camera) => void;
  2584. /**
  2585. * Strong typing of a RenderingGroup related stage step action
  2586. */
  2587. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2588. /**
  2589. * Strong typing of a Mesh Render related stage step action
  2590. */
  2591. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2592. /**
  2593. * Strong typing of a simple stage step action
  2594. */
  2595. type SimpleStageAction = () => void;
  2596. /**
  2597. * Strong typing of a render target action.
  2598. */
  2599. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2600. /**
  2601. * Strong typing of a pointer move action.
  2602. */
  2603. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2604. /**
  2605. * Strong typing of a pointer up/down action.
  2606. */
  2607. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2608. /**
  2609. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2610. * @hidden
  2611. */
  2612. class Stage<T extends Function> extends Array<{
  2613. index: number;
  2614. component: ISceneComponent;
  2615. action: T;
  2616. }> {
  2617. /**
  2618. * Hide ctor from the rest of the world.
  2619. * @param items The items to add.
  2620. */
  2621. private constructor();
  2622. /**
  2623. * Creates a new Stage.
  2624. * @returns A new instance of a Stage
  2625. */
  2626. static Create<T extends Function>(): Stage<T>;
  2627. /**
  2628. * Registers a step in an ordered way in the targeted stage.
  2629. * @param index Defines the position to register the step in
  2630. * @param component Defines the component attached to the step
  2631. * @param action Defines the action to launch during the step
  2632. */
  2633. registerStep(index: number, component: ISceneComponent, action: T): void;
  2634. /**
  2635. * Clears all the steps from the stage.
  2636. */
  2637. clear(): void;
  2638. }
  2639. }
  2640. declare module BABYLON {
  2641. /** Alias type for value that can be null */
  2642. type Nullable<T> = T | null;
  2643. /**
  2644. * Alias type for number that are floats
  2645. * @ignorenaming
  2646. */
  2647. type float = number;
  2648. /**
  2649. * Alias type for number that are doubles.
  2650. * @ignorenaming
  2651. */
  2652. type double = number;
  2653. /**
  2654. * Alias type for number that are integer
  2655. * @ignorenaming
  2656. */
  2657. type int = number;
  2658. /** Alias type for number array or Float32Array */
  2659. type FloatArray = number[] | Float32Array;
  2660. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2661. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2662. /**
  2663. * Alias for types that can be used by a Buffer or VertexBuffer.
  2664. */
  2665. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2666. }
  2667. declare module BABYLON {
  2668. /**
  2669. * The action to be carried out following a trigger
  2670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2671. */
  2672. class Action {
  2673. /** the trigger, with or without parameters, for the action */
  2674. triggerOptions: any;
  2675. /**
  2676. * Trigger for the action
  2677. */
  2678. trigger: number;
  2679. /**
  2680. * Internal only - manager for action
  2681. * @hidden
  2682. */
  2683. _actionManager: ActionManager;
  2684. private _nextActiveAction;
  2685. private _child;
  2686. private _condition?;
  2687. private _triggerParameter;
  2688. /**
  2689. * An event triggered prior to action being executed.
  2690. */
  2691. onBeforeExecuteObservable: Observable<Action>;
  2692. /**
  2693. * Creates a new Action
  2694. * @param triggerOptions the trigger, with or without parameters, for the action
  2695. * @param condition an optional determinant of action
  2696. */
  2697. constructor(
  2698. /** the trigger, with or without parameters, for the action */
  2699. triggerOptions: any, condition?: Condition);
  2700. /**
  2701. * Internal only
  2702. * @hidden
  2703. */
  2704. _prepare(): void;
  2705. /**
  2706. * Gets the trigger parameters
  2707. * @returns the trigger parameters
  2708. */
  2709. getTriggerParameter(): any;
  2710. /**
  2711. * Internal only - executes current action event
  2712. * @hidden
  2713. */
  2714. _executeCurrent(evt?: ActionEvent): void;
  2715. /**
  2716. * Execute placeholder for child classes
  2717. * @param evt optional action event
  2718. */
  2719. execute(evt?: ActionEvent): void;
  2720. /**
  2721. * Skips to next active action
  2722. */
  2723. skipToNextActiveAction(): void;
  2724. /**
  2725. * Adds action to chain of actions, may be a DoNothingAction
  2726. * @param action defines the next action to execute
  2727. * @returns The action passed in
  2728. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2729. */
  2730. then(action: Action): Action;
  2731. /**
  2732. * Internal only
  2733. * @hidden
  2734. */
  2735. _getProperty(propertyPath: string): string;
  2736. /**
  2737. * Internal only
  2738. * @hidden
  2739. */
  2740. _getEffectiveTarget(target: any, propertyPath: string): any;
  2741. /**
  2742. * Serialize placeholder for child classes
  2743. * @param parent of child
  2744. * @returns the serialized object
  2745. */
  2746. serialize(parent: any): any;
  2747. /**
  2748. * Internal only called by serialize
  2749. * @hidden
  2750. */
  2751. protected _serialize(serializedAction: any, parent?: any): any;
  2752. /**
  2753. * Internal only
  2754. * @hidden
  2755. */
  2756. static _SerializeValueAsString: (value: any) => string;
  2757. /**
  2758. * Internal only
  2759. * @hidden
  2760. */
  2761. static _GetTargetProperty: (target: Scene | Node) => {
  2762. name: string;
  2763. targetType: string;
  2764. value: string;
  2765. };
  2766. }
  2767. }
  2768. declare module BABYLON {
  2769. /**
  2770. * ActionEvent is the event being sent when an action is triggered.
  2771. */
  2772. class ActionEvent {
  2773. /** The mesh or sprite that triggered the action */
  2774. source: any;
  2775. /** The X mouse cursor position at the time of the event */
  2776. pointerX: number;
  2777. /** The Y mouse cursor position at the time of the event */
  2778. pointerY: number;
  2779. /** The mesh that is currently pointed at (can be null) */
  2780. meshUnderPointer: Nullable<AbstractMesh>;
  2781. /** the original (browser) event that triggered the ActionEvent */
  2782. sourceEvent?: any;
  2783. /** additional data for the event */
  2784. additionalData?: any;
  2785. /**
  2786. * Creates a new ActionEvent
  2787. * @param source The mesh or sprite that triggered the action
  2788. * @param pointerX The X mouse cursor position at the time of the event
  2789. * @param pointerY The Y mouse cursor position at the time of the event
  2790. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2791. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2792. * @param additionalData additional data for the event
  2793. */
  2794. constructor(
  2795. /** The mesh or sprite that triggered the action */
  2796. source: any,
  2797. /** The X mouse cursor position at the time of the event */
  2798. pointerX: number,
  2799. /** The Y mouse cursor position at the time of the event */
  2800. pointerY: number,
  2801. /** The mesh that is currently pointed at (can be null) */
  2802. meshUnderPointer: Nullable<AbstractMesh>,
  2803. /** the original (browser) event that triggered the ActionEvent */
  2804. sourceEvent?: any,
  2805. /** additional data for the event */
  2806. additionalData?: any);
  2807. /**
  2808. * Helper function to auto-create an ActionEvent from a source mesh.
  2809. * @param source The source mesh that triggered the event
  2810. * @param evt The original (browser) event
  2811. * @param additionalData additional data for the event
  2812. * @returns the new ActionEvent
  2813. */
  2814. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2815. /**
  2816. * Helper function to auto-create an ActionEvent from a source sprite
  2817. * @param source The source sprite that triggered the event
  2818. * @param scene Scene associated with the sprite
  2819. * @param evt The original (browser) event
  2820. * @param additionalData additional data for the event
  2821. * @returns the new ActionEvent
  2822. */
  2823. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2824. /**
  2825. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2826. * @param scene the scene where the event occurred
  2827. * @param evt The original (browser) event
  2828. * @returns the new ActionEvent
  2829. */
  2830. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2831. /**
  2832. * Helper function to auto-create an ActionEvent from a primitive
  2833. * @param prim defines the target primitive
  2834. * @param pointerPos defines the pointer position
  2835. * @param evt The original (browser) event
  2836. * @param additionalData additional data for the event
  2837. * @returns the new ActionEvent
  2838. */
  2839. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2840. }
  2841. /**
  2842. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2843. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2845. */
  2846. class ActionManager {
  2847. /**
  2848. * Nothing
  2849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2850. */
  2851. static readonly NothingTrigger: number;
  2852. /**
  2853. * On pick
  2854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2855. */
  2856. static readonly OnPickTrigger: number;
  2857. /**
  2858. * On left pick
  2859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2860. */
  2861. static readonly OnLeftPickTrigger: number;
  2862. /**
  2863. * On right pick
  2864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2865. */
  2866. static readonly OnRightPickTrigger: number;
  2867. /**
  2868. * On center pick
  2869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2870. */
  2871. static readonly OnCenterPickTrigger: number;
  2872. /**
  2873. * On pick down
  2874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2875. */
  2876. static readonly OnPickDownTrigger: number;
  2877. /**
  2878. * On double pick
  2879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2880. */
  2881. static readonly OnDoublePickTrigger: number;
  2882. /**
  2883. * On pick up
  2884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2885. */
  2886. static readonly OnPickUpTrigger: number;
  2887. /**
  2888. * On pick out.
  2889. * This trigger will only be raised if you also declared a OnPickDown
  2890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2891. */
  2892. static readonly OnPickOutTrigger: number;
  2893. /**
  2894. * On long press
  2895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2896. */
  2897. static readonly OnLongPressTrigger: number;
  2898. /**
  2899. * On pointer over
  2900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2901. */
  2902. static readonly OnPointerOverTrigger: number;
  2903. /**
  2904. * On pointer out
  2905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2906. */
  2907. static readonly OnPointerOutTrigger: number;
  2908. /**
  2909. * On every frame
  2910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2911. */
  2912. static readonly OnEveryFrameTrigger: number;
  2913. /**
  2914. * On intersection enter
  2915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2916. */
  2917. static readonly OnIntersectionEnterTrigger: number;
  2918. /**
  2919. * On intersection exit
  2920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2921. */
  2922. static readonly OnIntersectionExitTrigger: number;
  2923. /**
  2924. * On key down
  2925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2926. */
  2927. static readonly OnKeyDownTrigger: number;
  2928. /**
  2929. * On key up
  2930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2931. */
  2932. static readonly OnKeyUpTrigger: number;
  2933. /** Gets the list of active triggers */
  2934. static Triggers: {
  2935. [key: string]: number;
  2936. };
  2937. /** Gets the list of actions */
  2938. actions: Action[];
  2939. /** Gets the cursor to use when hovering items */
  2940. hoverCursor: string;
  2941. private _scene;
  2942. /**
  2943. * Creates a new action manager
  2944. * @param scene defines the hosting scene
  2945. */
  2946. constructor(scene: Scene);
  2947. /**
  2948. * Releases all associated resources
  2949. */
  2950. dispose(): void;
  2951. /**
  2952. * Gets hosting scene
  2953. * @returns the hosting scene
  2954. */
  2955. getScene(): Scene;
  2956. /**
  2957. * Does this action manager handles actions of any of the given triggers
  2958. * @param triggers defines the triggers to be tested
  2959. * @return a boolean indicating whether one (or more) of the triggers is handled
  2960. */
  2961. hasSpecificTriggers(triggers: number[]): boolean;
  2962. /**
  2963. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2964. * speed.
  2965. * @param triggerA defines the trigger to be tested
  2966. * @param triggerB defines the trigger to be tested
  2967. * @return a boolean indicating whether one (or more) of the triggers is handled
  2968. */
  2969. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2970. /**
  2971. * Does this action manager handles actions of a given trigger
  2972. * @param trigger defines the trigger to be tested
  2973. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2974. * @return whether the trigger is handled
  2975. */
  2976. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2977. /**
  2978. * Does this action manager has pointer triggers
  2979. */
  2980. readonly hasPointerTriggers: boolean;
  2981. /**
  2982. * Does this action manager has pick triggers
  2983. */
  2984. readonly hasPickTriggers: boolean;
  2985. /**
  2986. * Does exist one action manager with at least one trigger
  2987. **/
  2988. static readonly HasTriggers: boolean;
  2989. /**
  2990. * Does exist one action manager with at least one pick trigger
  2991. **/
  2992. static readonly HasPickTriggers: boolean;
  2993. /**
  2994. * Does exist one action manager that handles actions of a given trigger
  2995. * @param trigger defines the trigger to be tested
  2996. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2997. **/
  2998. static HasSpecificTrigger(trigger: number): boolean;
  2999. /**
  3000. * Registers an action to this action manager
  3001. * @param action defines the action to be registered
  3002. * @return the action amended (prepared) after registration
  3003. */
  3004. registerAction(action: Action): Nullable<Action>;
  3005. /**
  3006. * Unregisters an action to this action manager
  3007. * @param action defines the action to be unregistered
  3008. * @return a boolean indicating whether the action has been unregistered
  3009. */
  3010. unregisterAction(action: Action): Boolean;
  3011. /**
  3012. * Process a specific trigger
  3013. * @param trigger defines the trigger to process
  3014. * @param evt defines the event details to be processed
  3015. */
  3016. processTrigger(trigger: number, evt?: ActionEvent): void;
  3017. /** @hidden */
  3018. _getEffectiveTarget(target: any, propertyPath: string): any;
  3019. /** @hidden */
  3020. _getProperty(propertyPath: string): string;
  3021. /**
  3022. * Serialize this manager to a JSON object
  3023. * @param name defines the property name to store this manager
  3024. * @returns a JSON representation of this manager
  3025. */
  3026. serialize(name: string): any;
  3027. /**
  3028. * Creates a new ActionManager from a JSON data
  3029. * @param parsedActions defines the JSON data to read from
  3030. * @param object defines the hosting mesh
  3031. * @param scene defines the hosting scene
  3032. */
  3033. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3034. /**
  3035. * Get a trigger name by index
  3036. * @param trigger defines the trigger index
  3037. * @returns a trigger name
  3038. */
  3039. static GetTriggerName(trigger: number): string;
  3040. }
  3041. }
  3042. declare module BABYLON {
  3043. /**
  3044. * A Condition applied to an Action
  3045. */
  3046. class Condition {
  3047. /**
  3048. * Internal only - manager for action
  3049. * @hidden
  3050. */
  3051. _actionManager: ActionManager;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _evaluationId: number;
  3057. /**
  3058. * Internal only
  3059. * @hidden
  3060. */
  3061. _currentResult: boolean;
  3062. /**
  3063. * Creates a new Condition
  3064. * @param actionManager the manager of the action the condition is applied to
  3065. */
  3066. constructor(actionManager: ActionManager);
  3067. /**
  3068. * Check if the current condition is valid
  3069. * @returns a boolean
  3070. */
  3071. isValid(): boolean;
  3072. /**
  3073. * Internal only
  3074. * @hidden
  3075. */
  3076. _getProperty(propertyPath: string): string;
  3077. /**
  3078. * Internal only
  3079. * @hidden
  3080. */
  3081. _getEffectiveTarget(target: any, propertyPath: string): any;
  3082. /**
  3083. * Serialize placeholder for child classes
  3084. * @returns the serialized object
  3085. */
  3086. serialize(): any;
  3087. /**
  3088. * Internal only
  3089. * @hidden
  3090. */
  3091. protected _serialize(serializedCondition: any): any;
  3092. }
  3093. /**
  3094. * Defines specific conditional operators as extensions of Condition
  3095. */
  3096. class ValueCondition extends Condition {
  3097. /** path to specify the property of the target the conditional operator uses */
  3098. propertyPath: string;
  3099. /** the value compared by the conditional operator against the current value of the property */
  3100. value: any;
  3101. /** the conditional operator, default ValueCondition.IsEqual */
  3102. operator: number;
  3103. /**
  3104. * Internal only
  3105. * @hidden
  3106. */
  3107. private static _IsEqual;
  3108. /**
  3109. * Internal only
  3110. * @hidden
  3111. */
  3112. private static _IsDifferent;
  3113. /**
  3114. * Internal only
  3115. * @hidden
  3116. */
  3117. private static _IsGreater;
  3118. /**
  3119. * Internal only
  3120. * @hidden
  3121. */
  3122. private static _IsLesser;
  3123. /**
  3124. * returns the number for IsEqual
  3125. */
  3126. static readonly IsEqual: number;
  3127. /**
  3128. * Returns the number for IsDifferent
  3129. */
  3130. static readonly IsDifferent: number;
  3131. /**
  3132. * Returns the number for IsGreater
  3133. */
  3134. static readonly IsGreater: number;
  3135. /**
  3136. * Returns the number for IsLesser
  3137. */
  3138. static readonly IsLesser: number;
  3139. /**
  3140. * Internal only The action manager for the condition
  3141. * @hidden
  3142. */
  3143. _actionManager: ActionManager;
  3144. /**
  3145. * Internal only
  3146. * @hidden
  3147. */
  3148. private _target;
  3149. /**
  3150. * Internal only
  3151. * @hidden
  3152. */
  3153. private _effectiveTarget;
  3154. /**
  3155. * Internal only
  3156. * @hidden
  3157. */
  3158. private _property;
  3159. /**
  3160. * Creates a new ValueCondition
  3161. * @param actionManager manager for the action the condition applies to
  3162. * @param target for the action
  3163. * @param propertyPath path to specify the property of the target the conditional operator uses
  3164. * @param value the value compared by the conditional operator against the current value of the property
  3165. * @param operator the conditional operator, default ValueCondition.IsEqual
  3166. */
  3167. constructor(actionManager: ActionManager, target: any,
  3168. /** path to specify the property of the target the conditional operator uses */
  3169. propertyPath: string,
  3170. /** the value compared by the conditional operator against the current value of the property */
  3171. value: any,
  3172. /** the conditional operator, default ValueCondition.IsEqual */
  3173. operator?: number);
  3174. /**
  3175. * Compares the given value with the property value for the specified conditional operator
  3176. * @returns the result of the comparison
  3177. */
  3178. isValid(): boolean;
  3179. /**
  3180. * Serialize the ValueCondition into a JSON compatible object
  3181. * @returns serialization object
  3182. */
  3183. serialize(): any;
  3184. /**
  3185. * Gets the name of the conditional operator for the ValueCondition
  3186. * @param operator the conditional operator
  3187. * @returns the name
  3188. */
  3189. static GetOperatorName(operator: number): string;
  3190. }
  3191. /**
  3192. * Defines a predicate condition as an extension of Condition
  3193. */
  3194. class PredicateCondition extends Condition {
  3195. /** defines the predicate function used to validate the condition */
  3196. predicate: () => boolean;
  3197. /**
  3198. * Internal only - manager for action
  3199. * @hidden
  3200. */
  3201. _actionManager: ActionManager;
  3202. /**
  3203. * Creates a new PredicateCondition
  3204. * @param actionManager manager for the action the condition applies to
  3205. * @param predicate defines the predicate function used to validate the condition
  3206. */
  3207. constructor(actionManager: ActionManager,
  3208. /** defines the predicate function used to validate the condition */
  3209. predicate: () => boolean);
  3210. /**
  3211. * @returns the validity of the predicate condition
  3212. */
  3213. isValid(): boolean;
  3214. }
  3215. /**
  3216. * Defines a state condition as an extension of Condition
  3217. */
  3218. class StateCondition extends Condition {
  3219. /** Value to compare with target state */
  3220. value: string;
  3221. /**
  3222. * Internal only - manager for action
  3223. * @hidden
  3224. */
  3225. _actionManager: ActionManager;
  3226. /**
  3227. * Internal only
  3228. * @hidden
  3229. */
  3230. private _target;
  3231. /**
  3232. * Creates a new StateCondition
  3233. * @param actionManager manager for the action the condition applies to
  3234. * @param target of the condition
  3235. * @param value to compare with target state
  3236. */
  3237. constructor(actionManager: ActionManager, target: any,
  3238. /** Value to compare with target state */
  3239. value: string);
  3240. /**
  3241. * Gets a boolean indicating if the current condition is met
  3242. * @returns the validity of the state
  3243. */
  3244. isValid(): boolean;
  3245. /**
  3246. * Serialize the StateCondition into a JSON compatible object
  3247. * @returns serialization object
  3248. */
  3249. serialize(): any;
  3250. }
  3251. }
  3252. declare module BABYLON {
  3253. /**
  3254. * This defines an action responsible to toggle a boolean once triggered.
  3255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3256. */
  3257. class SwitchBooleanAction extends Action {
  3258. /**
  3259. * The path to the boolean property in the target object
  3260. */
  3261. propertyPath: string;
  3262. private _target;
  3263. private _effectiveTarget;
  3264. private _property;
  3265. /**
  3266. * Instantiate the action
  3267. * @param triggerOptions defines the trigger options
  3268. * @param target defines the object containing the boolean
  3269. * @param propertyPath defines the path to the boolean property in the target object
  3270. * @param condition defines the trigger related conditions
  3271. */
  3272. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3273. /** @hidden */
  3274. _prepare(): void;
  3275. /**
  3276. * Execute the action toggle the boolean value.
  3277. */
  3278. execute(): void;
  3279. /**
  3280. * Serializes the actions and its related information.
  3281. * @param parent defines the object to serialize in
  3282. * @returns the serialized object
  3283. */
  3284. serialize(parent: any): any;
  3285. }
  3286. /**
  3287. * This defines an action responsible to set a the state field of the target
  3288. * to a desired value once triggered.
  3289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3290. */
  3291. class SetStateAction extends Action {
  3292. /**
  3293. * The value to store in the state field.
  3294. */
  3295. value: string;
  3296. private _target;
  3297. /**
  3298. * Instantiate the action
  3299. * @param triggerOptions defines the trigger options
  3300. * @param target defines the object containing the state property
  3301. * @param value defines the value to store in the state field
  3302. * @param condition defines the trigger related conditions
  3303. */
  3304. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3305. /**
  3306. * Execute the action and store the value on the target state property.
  3307. */
  3308. execute(): void;
  3309. /**
  3310. * Serializes the actions and its related information.
  3311. * @param parent defines the object to serialize in
  3312. * @returns the serialized object
  3313. */
  3314. serialize(parent: any): any;
  3315. }
  3316. /**
  3317. * This defines an action responsible to set a property of the target
  3318. * to a desired value once triggered.
  3319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3320. */
  3321. class SetValueAction extends Action {
  3322. /**
  3323. * The path of the property to set in the target.
  3324. */
  3325. propertyPath: string;
  3326. /**
  3327. * The value to set in the property
  3328. */
  3329. value: any;
  3330. private _target;
  3331. private _effectiveTarget;
  3332. private _property;
  3333. /**
  3334. * Instantiate the action
  3335. * @param triggerOptions defines the trigger options
  3336. * @param target defines the object containing the property
  3337. * @param propertyPath defines the path of the property to set in the target
  3338. * @param value defines the value to set in the property
  3339. * @param condition defines the trigger related conditions
  3340. */
  3341. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3342. /** @hidden */
  3343. _prepare(): void;
  3344. /**
  3345. * Execute the action and set the targetted property to the desired value.
  3346. */
  3347. execute(): void;
  3348. /**
  3349. * Serializes the actions and its related information.
  3350. * @param parent defines the object to serialize in
  3351. * @returns the serialized object
  3352. */
  3353. serialize(parent: any): any;
  3354. }
  3355. /**
  3356. * This defines an action responsible to increment the target value
  3357. * to a desired value once triggered.
  3358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3359. */
  3360. class IncrementValueAction extends Action {
  3361. /**
  3362. * The path of the property to increment in the target.
  3363. */
  3364. propertyPath: string;
  3365. /**
  3366. * The value we should increment the property by.
  3367. */
  3368. value: any;
  3369. private _target;
  3370. private _effectiveTarget;
  3371. private _property;
  3372. /**
  3373. * Instantiate the action
  3374. * @param triggerOptions defines the trigger options
  3375. * @param target defines the object containing the property
  3376. * @param propertyPath defines the path of the property to increment in the target
  3377. * @param value defines the value value we should increment the property by
  3378. * @param condition defines the trigger related conditions
  3379. */
  3380. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3381. /** @hidden */
  3382. _prepare(): void;
  3383. /**
  3384. * Execute the action and increment the target of the value amount.
  3385. */
  3386. execute(): void;
  3387. /**
  3388. * Serializes the actions and its related information.
  3389. * @param parent defines the object to serialize in
  3390. * @returns the serialized object
  3391. */
  3392. serialize(parent: any): any;
  3393. }
  3394. /**
  3395. * This defines an action responsible to start an animation once triggered.
  3396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3397. */
  3398. class PlayAnimationAction extends Action {
  3399. /**
  3400. * Where the animation should start (animation frame)
  3401. */
  3402. from: number;
  3403. /**
  3404. * Where the animation should stop (animation frame)
  3405. */
  3406. to: number;
  3407. /**
  3408. * Define if the animation should loop or stop after the first play.
  3409. */
  3410. loop?: boolean;
  3411. private _target;
  3412. /**
  3413. * Instantiate the action
  3414. * @param triggerOptions defines the trigger options
  3415. * @param target defines the target animation or animation name
  3416. * @param from defines from where the animation should start (animation frame)
  3417. * @param end defines where the animation should stop (animation frame)
  3418. * @param loop defines if the animation should loop or stop after the first play
  3419. * @param condition defines the trigger related conditions
  3420. */
  3421. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3422. /** @hidden */
  3423. _prepare(): void;
  3424. /**
  3425. * Execute the action and play the animation.
  3426. */
  3427. execute(): void;
  3428. /**
  3429. * Serializes the actions and its related information.
  3430. * @param parent defines the object to serialize in
  3431. * @returns the serialized object
  3432. */
  3433. serialize(parent: any): any;
  3434. }
  3435. /**
  3436. * This defines an action responsible to stop an animation once triggered.
  3437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3438. */
  3439. class StopAnimationAction extends Action {
  3440. private _target;
  3441. /**
  3442. * Instantiate the action
  3443. * @param triggerOptions defines the trigger options
  3444. * @param target defines the target animation or animation name
  3445. * @param condition defines the trigger related conditions
  3446. */
  3447. constructor(triggerOptions: any, target: any, condition?: Condition);
  3448. /** @hidden */
  3449. _prepare(): void;
  3450. /**
  3451. * Execute the action and stop the animation.
  3452. */
  3453. execute(): void;
  3454. /**
  3455. * Serializes the actions and its related information.
  3456. * @param parent defines the object to serialize in
  3457. * @returns the serialized object
  3458. */
  3459. serialize(parent: any): any;
  3460. }
  3461. /**
  3462. * This defines an action responsible that does nothing once triggered.
  3463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3464. */
  3465. class DoNothingAction extends Action {
  3466. /**
  3467. * Instantiate the action
  3468. * @param triggerOptions defines the trigger options
  3469. * @param condition defines the trigger related conditions
  3470. */
  3471. constructor(triggerOptions?: any, condition?: Condition);
  3472. /**
  3473. * Execute the action and do nothing.
  3474. */
  3475. execute(): void;
  3476. /**
  3477. * Serializes the actions and its related information.
  3478. * @param parent defines the object to serialize in
  3479. * @returns the serialized object
  3480. */
  3481. serialize(parent: any): any;
  3482. }
  3483. /**
  3484. * This defines an action responsible to trigger several actions once triggered.
  3485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3486. */
  3487. class CombineAction extends Action {
  3488. /**
  3489. * The list of aggregated animations to run.
  3490. */
  3491. children: Action[];
  3492. /**
  3493. * Instantiate the action
  3494. * @param triggerOptions defines the trigger options
  3495. * @param children defines the list of aggregated animations to run
  3496. * @param condition defines the trigger related conditions
  3497. */
  3498. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3499. /** @hidden */
  3500. _prepare(): void;
  3501. /**
  3502. * Execute the action and executes all the aggregated actions.
  3503. */
  3504. execute(evt: ActionEvent): void;
  3505. /**
  3506. * Serializes the actions and its related information.
  3507. * @param parent defines the object to serialize in
  3508. * @returns the serialized object
  3509. */
  3510. serialize(parent: any): any;
  3511. }
  3512. /**
  3513. * This defines an action responsible to run code (external event) once triggered.
  3514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3515. */
  3516. class ExecuteCodeAction extends Action {
  3517. /**
  3518. * The callback function to run.
  3519. */
  3520. func: (evt: ActionEvent) => void;
  3521. /**
  3522. * Instantiate the action
  3523. * @param triggerOptions defines the trigger options
  3524. * @param func defines the callback function to run
  3525. * @param condition defines the trigger related conditions
  3526. */
  3527. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3528. /**
  3529. * Execute the action and run the attached code.
  3530. */
  3531. execute(evt: ActionEvent): void;
  3532. }
  3533. /**
  3534. * This defines an action responsible to set the parent property of the target once triggered.
  3535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3536. */
  3537. class SetParentAction extends Action {
  3538. private _parent;
  3539. private _target;
  3540. /**
  3541. * Instantiate the action
  3542. * @param triggerOptions defines the trigger options
  3543. * @param target defines the target containing the parent property
  3544. * @param parent defines from where the animation should start (animation frame)
  3545. * @param condition defines the trigger related conditions
  3546. */
  3547. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3548. /** @hidden */
  3549. _prepare(): void;
  3550. /**
  3551. * Execute the action and set the parent property.
  3552. */
  3553. execute(): void;
  3554. /**
  3555. * Serializes the actions and its related information.
  3556. * @param parent defines the object to serialize in
  3557. * @returns the serialized object
  3558. */
  3559. serialize(parent: any): any;
  3560. }
  3561. }
  3562. declare module BABYLON {
  3563. /**
  3564. * This defines an action helpful to play a defined sound on a triggered action.
  3565. */
  3566. class PlaySoundAction extends Action {
  3567. private _sound;
  3568. /**
  3569. * Instantiate the action
  3570. * @param triggerOptions defines the trigger options
  3571. * @param sound defines the sound to play
  3572. * @param condition defines the trigger related conditions
  3573. */
  3574. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3575. /** @hidden */
  3576. _prepare(): void;
  3577. /**
  3578. * Execute the action and play the sound.
  3579. */
  3580. execute(): void;
  3581. /**
  3582. * Serializes the actions and its related information.
  3583. * @param parent defines the object to serialize in
  3584. * @returns the serialized object
  3585. */
  3586. serialize(parent: any): any;
  3587. }
  3588. /**
  3589. * This defines an action helpful to stop a defined sound on a triggered action.
  3590. */
  3591. class StopSoundAction extends Action {
  3592. private _sound;
  3593. /**
  3594. * Instantiate the action
  3595. * @param triggerOptions defines the trigger options
  3596. * @param sound defines the sound to stop
  3597. * @param condition defines the trigger related conditions
  3598. */
  3599. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3600. /** @hidden */
  3601. _prepare(): void;
  3602. /**
  3603. * Execute the action and stop the sound.
  3604. */
  3605. execute(): void;
  3606. /**
  3607. * Serializes the actions and its related information.
  3608. * @param parent defines the object to serialize in
  3609. * @returns the serialized object
  3610. */
  3611. serialize(parent: any): any;
  3612. }
  3613. }
  3614. declare module BABYLON {
  3615. /**
  3616. * This defines an action responsible to change the value of a property
  3617. * by interpolating between its current value and the newly set one once triggered.
  3618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3619. */
  3620. class InterpolateValueAction extends Action {
  3621. /**
  3622. * Defines the path of the property where the value should be interpolated
  3623. */
  3624. propertyPath: string;
  3625. /**
  3626. * Defines the target value at the end of the interpolation.
  3627. */
  3628. value: any;
  3629. /**
  3630. * Defines the time it will take for the property to interpolate to the value.
  3631. */
  3632. duration: number;
  3633. /**
  3634. * Defines if the other scene animations should be stopped when the action has been triggered
  3635. */
  3636. stopOtherAnimations?: boolean;
  3637. /**
  3638. * Defines a callback raised once the interpolation animation has been done.
  3639. */
  3640. onInterpolationDone?: () => void;
  3641. /**
  3642. * Observable triggered once the interpolation animation has been done.
  3643. */
  3644. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3645. private _target;
  3646. private _effectiveTarget;
  3647. private _property;
  3648. /**
  3649. * Instantiate the action
  3650. * @param triggerOptions defines the trigger options
  3651. * @param target defines the object containing the value to interpolate
  3652. * @param propertyPath defines the path to the property in the target object
  3653. * @param value defines the target value at the end of the interpolation
  3654. * @param duration deines the time it will take for the property to interpolate to the value.
  3655. * @param condition defines the trigger related conditions
  3656. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3657. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3658. */
  3659. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3660. /** @hidden */
  3661. _prepare(): void;
  3662. /**
  3663. * Execute the action starts the value interpolation.
  3664. */
  3665. execute(): void;
  3666. /**
  3667. * Serializes the actions and its related information.
  3668. * @param parent defines the object to serialize in
  3669. * @returns the serialized object
  3670. */
  3671. serialize(parent: any): any;
  3672. }
  3673. }
  3674. declare module BABYLON {
  3675. /**
  3676. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3678. */
  3679. class Analyser {
  3680. /**
  3681. * Gets or sets the smoothing
  3682. * @ignorenaming
  3683. */
  3684. SMOOTHING: number;
  3685. /**
  3686. * Gets or sets the FFT table size
  3687. * @ignorenaming
  3688. */
  3689. FFT_SIZE: number;
  3690. /**
  3691. * Gets or sets the bar graph amplitude
  3692. * @ignorenaming
  3693. */
  3694. BARGRAPHAMPLITUDE: number;
  3695. /**
  3696. * Gets or sets the position of the debug canvas
  3697. * @ignorenaming
  3698. */
  3699. DEBUGCANVASPOS: {
  3700. x: number;
  3701. y: number;
  3702. };
  3703. /**
  3704. * Gets or sets the debug canvas size
  3705. * @ignorenaming
  3706. */
  3707. DEBUGCANVASSIZE: {
  3708. width: number;
  3709. height: number;
  3710. };
  3711. private _byteFreqs;
  3712. private _byteTime;
  3713. private _floatFreqs;
  3714. private _webAudioAnalyser;
  3715. private _debugCanvas;
  3716. private _debugCanvasContext;
  3717. private _scene;
  3718. private _registerFunc;
  3719. private _audioEngine;
  3720. /**
  3721. * Creates a new analyser
  3722. * @param scene defines hosting scene
  3723. */
  3724. constructor(scene: Scene);
  3725. /**
  3726. * Get the number of data values you will have to play with for the visualization
  3727. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3728. * @returns a number
  3729. */
  3730. getFrequencyBinCount(): number;
  3731. /**
  3732. * Gets the current frequency data as a byte array
  3733. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3734. * @returns a Uint8Array
  3735. */
  3736. getByteFrequencyData(): Uint8Array;
  3737. /**
  3738. * Gets the current waveform as a byte array
  3739. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3740. * @returns a Uint8Array
  3741. */
  3742. getByteTimeDomainData(): Uint8Array;
  3743. /**
  3744. * Gets the current frequency data as a float array
  3745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3746. * @returns a Float32Array
  3747. */
  3748. getFloatFrequencyData(): Float32Array;
  3749. /**
  3750. * Renders the debug canvas
  3751. */
  3752. drawDebugCanvas(): void;
  3753. /**
  3754. * Stops rendering the debug canvas and removes it
  3755. */
  3756. stopDebugCanvas(): void;
  3757. /**
  3758. * Connects two audio nodes
  3759. * @param inputAudioNode defines first node to connect
  3760. * @param outputAudioNode defines second node to connect
  3761. */
  3762. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3763. /**
  3764. * Releases all associated resources
  3765. */
  3766. dispose(): void;
  3767. }
  3768. }
  3769. declare module BABYLON {
  3770. /**
  3771. * This represents an audio engine and it is responsible
  3772. * to play, synchronize and analyse sounds throughout the application.
  3773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3774. */
  3775. interface IAudioEngine extends IDisposable {
  3776. /**
  3777. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  3778. */
  3779. readonly canUseWebAudio: boolean;
  3780. /**
  3781. * Gets the current AudioContext if available.
  3782. */
  3783. readonly audioContext: Nullable<AudioContext>;
  3784. /**
  3785. * The master gain node defines the global audio volume of your audio engine.
  3786. */
  3787. readonly masterGain: GainNode;
  3788. /**
  3789. * Gets whether or not mp3 are supported by your browser.
  3790. */
  3791. readonly isMP3supported: boolean;
  3792. /**
  3793. * Gets whether or not ogg are supported by your browser.
  3794. */
  3795. readonly isOGGsupported: boolean;
  3796. /**
  3797. * Defines if Babylon should emit a warning if WebAudio is not supported.
  3798. * @ignoreNaming
  3799. */
  3800. WarnedWebAudioUnsupported: boolean;
  3801. /**
  3802. * Defines if the audio engine relies on a custom unlocked button.
  3803. * In this case, the embedded button will not be displayed.
  3804. */
  3805. useCustomUnlockedButton: boolean;
  3806. /**
  3807. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  3808. */
  3809. readonly unlocked: boolean;
  3810. /**
  3811. * Event raised when audio has been unlocked on the browser.
  3812. */
  3813. onAudioUnlockedObservable: Observable<AudioEngine>;
  3814. /**
  3815. * Event raised when audio has been locked on the browser.
  3816. */
  3817. onAudioLockedObservable: Observable<AudioEngine>;
  3818. /**
  3819. * Flags the audio engine in Locked state.
  3820. * This happens due to new browser policies preventing audio to autoplay.
  3821. */
  3822. lock(): void;
  3823. /**
  3824. * Unlocks the audio engine once a user action has been done on the dom.
  3825. * This is helpful to resume play once browser policies have been satisfied.
  3826. */
  3827. unlock(): void;
  3828. }
  3829. /**
  3830. * This represents the default audio engine used in babylon.
  3831. * It is responsible to play, synchronize and analyse sounds throughout the application.
  3832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3833. */
  3834. class AudioEngine implements IAudioEngine {
  3835. private _audioContext;
  3836. private _audioContextInitialized;
  3837. private _muteButton;
  3838. private _hostElement;
  3839. /**
  3840. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  3841. */
  3842. canUseWebAudio: boolean;
  3843. /**
  3844. * The master gain node defines the global audio volume of your audio engine.
  3845. */
  3846. masterGain: GainNode;
  3847. /**
  3848. * Defines if Babylon should emit a warning if WebAudio is not supported.
  3849. * @ignoreNaming
  3850. */
  3851. WarnedWebAudioUnsupported: boolean;
  3852. /**
  3853. * Gets whether or not mp3 are supported by your browser.
  3854. */
  3855. isMP3supported: boolean;
  3856. /**
  3857. * Gets whether or not ogg are supported by your browser.
  3858. */
  3859. isOGGsupported: boolean;
  3860. /**
  3861. * Gets whether audio has been unlocked on the device.
  3862. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  3863. * a user interaction has happened.
  3864. */
  3865. unlocked: boolean;
  3866. /**
  3867. * Defines if the audio engine relies on a custom unlocked button.
  3868. * In this case, the embedded button will not be displayed.
  3869. */
  3870. useCustomUnlockedButton: boolean;
  3871. /**
  3872. * Event raised when audio has been unlocked on the browser.
  3873. */
  3874. onAudioUnlockedObservable: Observable<AudioEngine>;
  3875. /**
  3876. * Event raised when audio has been locked on the browser.
  3877. */
  3878. onAudioLockedObservable: Observable<AudioEngine>;
  3879. /**
  3880. * Gets the current AudioContext if available.
  3881. */
  3882. readonly audioContext: Nullable<AudioContext>;
  3883. private _connectedAnalyser;
  3884. /**
  3885. * Instantiates a new audio engine.
  3886. *
  3887. * There should be only one per page as some browsers restrict the number
  3888. * of audio contexts you can create.
  3889. * @param hostElement defines the host element where to display the mute icon if necessary
  3890. */
  3891. constructor(hostElement?: Nullable<HTMLElement>);
  3892. /**
  3893. * Flags the audio engine in Locked state.
  3894. * This happens due to new browser policies preventing audio to autoplay.
  3895. */
  3896. lock(): void;
  3897. /**
  3898. * Unlocks the audio engine once a user action has been done on the dom.
  3899. * This is helpful to resume play once browser policies have been satisfied.
  3900. */
  3901. unlock(): void;
  3902. private _resumeAudioContext;
  3903. private _initializeAudioContext;
  3904. private _tryToRun;
  3905. private _triggerRunningState;
  3906. private _triggerSuspendedState;
  3907. private _displayMuteButton;
  3908. private _moveButtonToTopLeft;
  3909. private _onResize;
  3910. private _hideMuteButton;
  3911. /**
  3912. * Destroy and release the resources associated with the audio ccontext.
  3913. */
  3914. dispose(): void;
  3915. /**
  3916. * Gets the global volume sets on the master gain.
  3917. * @returns the global volume if set or -1 otherwise
  3918. */
  3919. getGlobalVolume(): number;
  3920. /**
  3921. * Sets the global volume of your experience (sets on the master gain).
  3922. * @param newVolume Defines the new global volume of the application
  3923. */
  3924. setGlobalVolume(newVolume: number): void;
  3925. /**
  3926. * Connect the audio engine to an audio analyser allowing some amazing
  3927. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  3928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  3929. * @param analyser The analyser to connect to the engine
  3930. */
  3931. connectToAnalyser(analyser: Analyser): void;
  3932. }
  3933. }
  3934. declare module BABYLON {
  3935. interface AbstractScene {
  3936. /**
  3937. * The list of sounds used in the scene.
  3938. */
  3939. sounds: Nullable<Array<Sound>>;
  3940. }
  3941. interface Scene {
  3942. /**
  3943. * @hidden
  3944. * Backing field
  3945. */
  3946. _mainSoundTrack: SoundTrack;
  3947. /**
  3948. * The main sound track played by the scene.
  3949. * It cotains your primary collection of sounds.
  3950. */
  3951. mainSoundTrack: SoundTrack;
  3952. /**
  3953. * The list of sound tracks added to the scene
  3954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3955. */
  3956. soundTracks: Nullable<Array<SoundTrack>>;
  3957. /**
  3958. * Gets a sound using a given name
  3959. * @param name defines the name to search for
  3960. * @return the found sound or null if not found at all.
  3961. */
  3962. getSoundByName(name: string): Nullable<Sound>;
  3963. /**
  3964. * Gets or sets if audio support is enabled
  3965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3966. */
  3967. audioEnabled: boolean;
  3968. /**
  3969. * Gets or sets if audio will be output to headphones
  3970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3971. */
  3972. headphone: boolean;
  3973. }
  3974. /**
  3975. * Defines the sound scene component responsible to manage any sounds
  3976. * in a given scene.
  3977. */
  3978. class AudioSceneComponent implements ISceneSerializableComponent {
  3979. /**
  3980. * The component name helpfull to identify the component in the list of scene components.
  3981. */
  3982. readonly name: string;
  3983. /**
  3984. * The scene the component belongs to.
  3985. */
  3986. scene: Scene;
  3987. private _audioEnabled;
  3988. /**
  3989. * Gets whether audio is enabled or not.
  3990. * Please use related enable/disable method to switch state.
  3991. */
  3992. readonly audioEnabled: boolean;
  3993. private _headphone;
  3994. /**
  3995. * Gets whether audio is outputing to headphone or not.
  3996. * Please use the according Switch methods to change output.
  3997. */
  3998. readonly headphone: boolean;
  3999. /**
  4000. * Creates a new instance of the component for the given scene
  4001. * @param scene Defines the scene to register the component in
  4002. */
  4003. constructor(scene: Scene);
  4004. /**
  4005. * Registers the component in a given scene
  4006. */
  4007. register(): void;
  4008. /**
  4009. * Rebuilds the elements related to this component in case of
  4010. * context lost for instance.
  4011. */
  4012. rebuild(): void;
  4013. /**
  4014. * Serializes the component data to the specified json object
  4015. * @param serializationObject The object to serialize to
  4016. */
  4017. serialize(serializationObject: any): void;
  4018. /**
  4019. * Adds all the element from the container to the scene
  4020. * @param container the container holding the elements
  4021. */
  4022. addFromContainer(container: AbstractScene): void;
  4023. /**
  4024. * Removes all the elements in the container from the scene
  4025. * @param container contains the elements to remove
  4026. */
  4027. removeFromContainer(container: AbstractScene): void;
  4028. /**
  4029. * Disposes the component and the associated ressources.
  4030. */
  4031. dispose(): void;
  4032. /**
  4033. * Disables audio in the associated scene.
  4034. */
  4035. disableAudio(): void;
  4036. /**
  4037. * Enables audio in the associated scene.
  4038. */
  4039. enableAudio(): void;
  4040. /**
  4041. * Switch audio to headphone output.
  4042. */
  4043. switchAudioModeForHeadphones(): void;
  4044. /**
  4045. * Switch audio to normal speakers.
  4046. */
  4047. switchAudioModeForNormalSpeakers(): void;
  4048. private _afterRender;
  4049. }
  4050. }
  4051. declare module BABYLON {
  4052. /**
  4053. * Defines a sound that can be played in the application.
  4054. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  4055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4056. */
  4057. class Sound {
  4058. /**
  4059. * The name of the sound in the scene.
  4060. */
  4061. name: string;
  4062. /**
  4063. * Does the sound autoplay once loaded.
  4064. */
  4065. autoplay: boolean;
  4066. /**
  4067. * Does the sound loop after it finishes playing once.
  4068. */
  4069. loop: boolean;
  4070. /**
  4071. * Does the sound use a custom attenuation curve to simulate the falloff
  4072. * happening when the source gets further away from the camera.
  4073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4074. */
  4075. useCustomAttenuation: boolean;
  4076. /**
  4077. * The sound track id this sound belongs to.
  4078. */
  4079. soundTrackId: number;
  4080. /**
  4081. * Is this sound currently played.
  4082. */
  4083. isPlaying: boolean;
  4084. /**
  4085. * Is this sound currently paused.
  4086. */
  4087. isPaused: boolean;
  4088. /**
  4089. * Does this sound enables spatial sound.
  4090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4091. */
  4092. spatialSound: boolean;
  4093. /**
  4094. * Define the reference distance the sound should be heard perfectly.
  4095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4096. */
  4097. refDistance: number;
  4098. /**
  4099. * Define the roll off factor of spatial sounds.
  4100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4101. */
  4102. rolloffFactor: number;
  4103. /**
  4104. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  4105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4106. */
  4107. maxDistance: number;
  4108. /**
  4109. * Define the distance attenuation model the sound will follow.
  4110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4111. */
  4112. distanceModel: string;
  4113. /**
  4114. * @hidden
  4115. * Back Compat
  4116. **/
  4117. onended: () => any;
  4118. /**
  4119. * Observable event when the current playing sound finishes.
  4120. */
  4121. onEndedObservable: Observable<Sound>;
  4122. private _panningModel;
  4123. private _playbackRate;
  4124. private _streaming;
  4125. private _startTime;
  4126. private _startOffset;
  4127. private _position;
  4128. /** @hidden */
  4129. _positionInEmitterSpace: boolean;
  4130. private _localDirection;
  4131. private _volume;
  4132. private _isReadyToPlay;
  4133. private _isDirectional;
  4134. private _readyToPlayCallback;
  4135. private _audioBuffer;
  4136. private _soundSource;
  4137. private _streamingSource;
  4138. private _soundPanner;
  4139. private _soundGain;
  4140. private _inputAudioNode;
  4141. private _outputAudioNode;
  4142. private _coneInnerAngle;
  4143. private _coneOuterAngle;
  4144. private _coneOuterGain;
  4145. private _scene;
  4146. private _connectedMesh;
  4147. private _customAttenuationFunction;
  4148. private _registerFunc;
  4149. private _isOutputConnected;
  4150. private _htmlAudioElement;
  4151. private _urlType;
  4152. /**
  4153. * Create a sound and attach it to a scene
  4154. * @param name Name of your sound
  4155. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4156. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4157. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4158. */
  4159. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4160. /**
  4161. * Release the sound and its associated resources
  4162. */
  4163. dispose(): void;
  4164. /**
  4165. * Gets if the sounds is ready to be played or not.
  4166. * @returns true if ready, otherwise false
  4167. */
  4168. isReady(): boolean;
  4169. private _soundLoaded;
  4170. /**
  4171. * Sets the data of the sound from an audiobuffer
  4172. * @param audioBuffer The audioBuffer containing the data
  4173. */
  4174. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4175. /**
  4176. * Updates the current sounds options such as maxdistance, loop...
  4177. * @param options A JSON object containing values named as the object properties
  4178. */
  4179. updateOptions(options: any): void;
  4180. private _createSpatialParameters;
  4181. private _updateSpatialParameters;
  4182. /**
  4183. * Switch the panning model to HRTF:
  4184. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4186. */
  4187. switchPanningModelToHRTF(): void;
  4188. /**
  4189. * Switch the panning model to Equal Power:
  4190. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4192. */
  4193. switchPanningModelToEqualPower(): void;
  4194. private _switchPanningModel;
  4195. /**
  4196. * Connect this sound to a sound track audio node like gain...
  4197. * @param soundTrackAudioNode the sound track audio node to connect to
  4198. */
  4199. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4200. /**
  4201. * Transform this sound into a directional source
  4202. * @param coneInnerAngle Size of the inner cone in degree
  4203. * @param coneOuterAngle Size of the outer cone in degree
  4204. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4205. */
  4206. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4207. /**
  4208. * Gets or sets the inner angle for the directional cone.
  4209. */
  4210. /**
  4211. * Gets or sets the inner angle for the directional cone.
  4212. */
  4213. directionalConeInnerAngle: number;
  4214. /**
  4215. * Gets or sets the outer angle for the directional cone.
  4216. */
  4217. /**
  4218. * Gets or sets the outer angle for the directional cone.
  4219. */
  4220. directionalConeOuterAngle: number;
  4221. /**
  4222. * Sets the position of the emitter if spatial sound is enabled
  4223. * @param newPosition Defines the new posisiton
  4224. */
  4225. setPosition(newPosition: Vector3): void;
  4226. /**
  4227. * Sets the local direction of the emitter if spatial sound is enabled
  4228. * @param newLocalDirection Defines the new local direction
  4229. */
  4230. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4231. private _updateDirection;
  4232. /** @hidden */
  4233. updateDistanceFromListener(): void;
  4234. /**
  4235. * Sets a new custom attenuation function for the sound.
  4236. * @param callback Defines the function used for the attenuation
  4237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4238. */
  4239. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4240. /**
  4241. * Play the sound
  4242. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4243. * @param offset (optional) Start the sound setting it at a specific time
  4244. */
  4245. play(time?: number, offset?: number): void;
  4246. private _onended;
  4247. /**
  4248. * Stop the sound
  4249. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4250. */
  4251. stop(time?: number): void;
  4252. /**
  4253. * Put the sound in pause
  4254. */
  4255. pause(): void;
  4256. /**
  4257. * Sets a dedicated volume for this sounds
  4258. * @param newVolume Define the new volume of the sound
  4259. * @param time Define in how long the sound should be at this value
  4260. */
  4261. setVolume(newVolume: number, time?: number): void;
  4262. /**
  4263. * Set the sound play back rate
  4264. * @param newPlaybackRate Define the playback rate the sound should be played at
  4265. */
  4266. setPlaybackRate(newPlaybackRate: number): void;
  4267. /**
  4268. * Gets the volume of the sound.
  4269. * @returns the volume of the sound
  4270. */
  4271. getVolume(): number;
  4272. /**
  4273. * Attach the sound to a dedicated mesh
  4274. * @param meshToConnectTo The mesh to connect the sound with
  4275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4276. */
  4277. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4278. /**
  4279. * Detach the sound from the previously attached mesh
  4280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4281. */
  4282. detachFromMesh(): void;
  4283. private _onRegisterAfterWorldMatrixUpdate;
  4284. /**
  4285. * Clone the current sound in the scene.
  4286. * @returns the new sound clone
  4287. */
  4288. clone(): Nullable<Sound>;
  4289. /**
  4290. * Gets the current underlying audio buffer containing the data
  4291. * @returns the audio buffer
  4292. */
  4293. getAudioBuffer(): Nullable<AudioBuffer>;
  4294. /**
  4295. * Serializes the Sound in a JSON representation
  4296. * @returns the JSON representation of the sound
  4297. */
  4298. serialize(): any;
  4299. /**
  4300. * Parse a JSON representation of a sound to innstantiate in a given scene
  4301. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  4302. * @param scene Define the scene the new parsed sound should be created in
  4303. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  4304. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  4305. * @returns the newly parsed sound
  4306. */
  4307. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4308. }
  4309. }
  4310. declare module BABYLON {
  4311. /**
  4312. * Options allowed during the creation of a sound track.
  4313. */
  4314. interface ISoundTrackOptions {
  4315. /**
  4316. * The volume the sound track should take during creation
  4317. */
  4318. volume?: number;
  4319. /**
  4320. * Define if the sound track is the main sound track of the scene
  4321. */
  4322. mainTrack?: boolean;
  4323. }
  4324. /**
  4325. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  4326. * It will be also used in a future release to apply effects on a specific track.
  4327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4328. */
  4329. class SoundTrack {
  4330. /**
  4331. * The unique identifier of the sound track in the scene.
  4332. */
  4333. id: number;
  4334. /**
  4335. * The list of sounds included in the sound track.
  4336. */
  4337. soundCollection: Array<Sound>;
  4338. private _outputAudioNode;
  4339. private _scene;
  4340. private _isMainTrack;
  4341. private _connectedAnalyser;
  4342. private _options;
  4343. private _isInitialized;
  4344. /**
  4345. * Creates a new sound track.
  4346. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4347. * @param scene Define the scene the sound track belongs to
  4348. * @param options
  4349. */
  4350. constructor(scene: Scene, options?: ISoundTrackOptions);
  4351. private _initializeSoundTrackAudioGraph;
  4352. /**
  4353. * Release the sound track and its associated resources
  4354. */
  4355. dispose(): void;
  4356. /**
  4357. * Adds a sound to this sound track
  4358. * @param sound define the cound to add
  4359. * @ignoreNaming
  4360. */
  4361. AddSound(sound: Sound): void;
  4362. /**
  4363. * Removes a sound to this sound track
  4364. * @param sound define the cound to remove
  4365. * @ignoreNaming
  4366. */
  4367. RemoveSound(sound: Sound): void;
  4368. /**
  4369. * Set a global volume for the full sound track.
  4370. * @param newVolume Define the new volume of the sound track
  4371. */
  4372. setVolume(newVolume: number): void;
  4373. /**
  4374. * Switch the panning model to HRTF:
  4375. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4377. */
  4378. switchPanningModelToHRTF(): void;
  4379. /**
  4380. * Switch the panning model to Equal Power:
  4381. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4383. */
  4384. switchPanningModelToEqualPower(): void;
  4385. /**
  4386. * Connect the sound track to an audio analyser allowing some amazing
  4387. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  4388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  4389. * @param analyser The analyser to connect to the engine
  4390. */
  4391. connectToAnalyser(analyser: Analyser): void;
  4392. }
  4393. }
  4394. declare module BABYLON {
  4395. /**
  4396. * Wraps one or more Sound objects and selects one with random weight for playback.
  4397. */
  4398. class WeightedSound {
  4399. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4400. loop: boolean;
  4401. private _coneInnerAngle;
  4402. private _coneOuterAngle;
  4403. private _volume;
  4404. /** A Sound is currently playing. */
  4405. isPlaying: boolean;
  4406. /** A Sound is currently paused. */
  4407. isPaused: boolean;
  4408. private _sounds;
  4409. private _weights;
  4410. private _currentIndex?;
  4411. /**
  4412. * Creates a new WeightedSound from the list of sounds given.
  4413. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4414. * @param sounds Array of Sounds that will be selected from.
  4415. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4416. */
  4417. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4418. /**
  4419. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4420. */
  4421. /**
  4422. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4423. */
  4424. directionalConeInnerAngle: number;
  4425. /**
  4426. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4427. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4428. */
  4429. /**
  4430. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4431. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4432. */
  4433. directionalConeOuterAngle: number;
  4434. /**
  4435. * Playback volume.
  4436. */
  4437. /**
  4438. * Playback volume.
  4439. */
  4440. volume: number;
  4441. private _onended;
  4442. /**
  4443. * Suspend playback
  4444. */
  4445. pause(): void;
  4446. /**
  4447. * Stop playback
  4448. */
  4449. stop(): void;
  4450. /**
  4451. * Start playback.
  4452. * @param startOffset Position the clip head at a specific time in seconds.
  4453. */
  4454. play(startOffset?: number): void;
  4455. }
  4456. }
  4457. declare module BABYLON {
  4458. /**
  4459. * Class used to store an actual running animation
  4460. */
  4461. class Animatable {
  4462. /** defines the target object */
  4463. target: any;
  4464. /** defines the starting frame number (default is 0) */
  4465. fromFrame: number;
  4466. /** defines the ending frame number (default is 100) */
  4467. toFrame: number;
  4468. /** defines if the animation must loop (default is false) */
  4469. loopAnimation: boolean;
  4470. /** defines a callback to call when animation ends if it is not looping */
  4471. onAnimationEnd?: (() => void) | null | undefined;
  4472. private _localDelayOffset;
  4473. private _pausedDelay;
  4474. private _runtimeAnimations;
  4475. private _paused;
  4476. private _scene;
  4477. private _speedRatio;
  4478. private _weight;
  4479. private _syncRoot;
  4480. /**
  4481. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  4482. * This will only apply for non looping animation (default is true)
  4483. */
  4484. disposeOnEnd: boolean;
  4485. /**
  4486. * Gets a boolean indicating if the animation has started
  4487. */
  4488. animationStarted: boolean;
  4489. /**
  4490. * Observer raised when the animation ends
  4491. */
  4492. onAnimationEndObservable: Observable<Animatable>;
  4493. /**
  4494. * Gets the root Animatable used to synchronize and normalize animations
  4495. */
  4496. readonly syncRoot: Animatable;
  4497. /**
  4498. * Gets the current frame of the first RuntimeAnimation
  4499. * Used to synchronize Animatables
  4500. */
  4501. readonly masterFrame: number;
  4502. /**
  4503. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  4504. */
  4505. weight: number;
  4506. /**
  4507. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  4508. */
  4509. speedRatio: number;
  4510. /**
  4511. * Creates a new Animatable
  4512. * @param scene defines the hosting scene
  4513. * @param target defines the target object
  4514. * @param fromFrame defines the starting frame number (default is 0)
  4515. * @param toFrame defines the ending frame number (default is 100)
  4516. * @param loopAnimation defines if the animation must loop (default is false)
  4517. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  4518. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  4519. * @param animations defines a group of animation to add to the new Animatable
  4520. */
  4521. constructor(scene: Scene,
  4522. /** defines the target object */
  4523. target: any,
  4524. /** defines the starting frame number (default is 0) */
  4525. fromFrame?: number,
  4526. /** defines the ending frame number (default is 100) */
  4527. toFrame?: number,
  4528. /** defines if the animation must loop (default is false) */
  4529. loopAnimation?: boolean, speedRatio?: number,
  4530. /** defines a callback to call when animation ends if it is not looping */
  4531. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  4532. /**
  4533. * Synchronize and normalize current Animatable with a source Animatable
  4534. * This is useful when using animation weights and when animations are not of the same length
  4535. * @param root defines the root Animatable to synchronize with
  4536. * @returns the current Animatable
  4537. */
  4538. syncWith(root: Animatable): Animatable;
  4539. /**
  4540. * Gets the list of runtime animations
  4541. * @returns an array of RuntimeAnimation
  4542. */
  4543. getAnimations(): RuntimeAnimation[];
  4544. /**
  4545. * Adds more animations to the current animatable
  4546. * @param target defines the target of the animations
  4547. * @param animations defines the new animations to add
  4548. */
  4549. appendAnimations(target: any, animations: Animation[]): void;
  4550. /**
  4551. * Gets the source animation for a specific property
  4552. * @param property defines the propertyu to look for
  4553. * @returns null or the source animation for the given property
  4554. */
  4555. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  4556. /**
  4557. * Gets the runtime animation for a specific property
  4558. * @param property defines the propertyu to look for
  4559. * @returns null or the runtime animation for the given property
  4560. */
  4561. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  4562. /**
  4563. * Resets the animatable to its original state
  4564. */
  4565. reset(): void;
  4566. /**
  4567. * Allows the animatable to blend with current running animations
  4568. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4569. * @param blendingSpeed defines the blending speed to use
  4570. */
  4571. enableBlending(blendingSpeed: number): void;
  4572. /**
  4573. * Disable animation blending
  4574. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4575. */
  4576. disableBlending(): void;
  4577. /**
  4578. * Jump directly to a given frame
  4579. * @param frame defines the frame to jump to
  4580. */
  4581. goToFrame(frame: number): void;
  4582. /**
  4583. * Pause the animation
  4584. */
  4585. pause(): void;
  4586. /**
  4587. * Restart the animation
  4588. */
  4589. restart(): void;
  4590. private _raiseOnAnimationEnd;
  4591. /**
  4592. * Stop and delete the current animation
  4593. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  4594. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  4595. */
  4596. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  4597. /**
  4598. * Wait asynchronously for the animation to end
  4599. * @returns a promise which will be fullfilled when the animation ends
  4600. */
  4601. waitAsync(): Promise<Animatable>;
  4602. /** @hidden */
  4603. _animate(delay: number): boolean;
  4604. }
  4605. }
  4606. declare module BABYLON {
  4607. /**
  4608. * Represents the range of an animation
  4609. */
  4610. class AnimationRange {
  4611. /**The name of the animation range**/
  4612. name: string;
  4613. /**The starting frame of the animation */
  4614. from: number;
  4615. /**The ending frame of the animation*/
  4616. to: number;
  4617. /**
  4618. * Initializes the range of an animation
  4619. * @param name The name of the animation range
  4620. * @param from The starting frame of the animation
  4621. * @param to The ending frame of the animation
  4622. */
  4623. constructor(
  4624. /**The name of the animation range**/
  4625. name: string,
  4626. /**The starting frame of the animation */
  4627. from: number,
  4628. /**The ending frame of the animation*/
  4629. to: number);
  4630. /**
  4631. * Makes a copy of the animation range
  4632. * @returns A copy of the animation range
  4633. */
  4634. clone(): AnimationRange;
  4635. }
  4636. /**
  4637. * Composed of a frame, and an action function
  4638. */
  4639. class AnimationEvent {
  4640. /** The frame for which the event is triggered **/
  4641. frame: number;
  4642. /** The event to perform when triggered **/
  4643. action: (currentFrame: number) => void;
  4644. /** Specifies if the event should be triggered only once**/
  4645. onlyOnce?: boolean | undefined;
  4646. /**
  4647. * Specifies if the animation event is done
  4648. */
  4649. isDone: boolean;
  4650. /**
  4651. * Initializes the animation event
  4652. * @param frame The frame for which the event is triggered
  4653. * @param action The event to perform when triggered
  4654. * @param onlyOnce Specifies if the event should be triggered only once
  4655. */
  4656. constructor(
  4657. /** The frame for which the event is triggered **/
  4658. frame: number,
  4659. /** The event to perform when triggered **/
  4660. action: (currentFrame: number) => void,
  4661. /** Specifies if the event should be triggered only once**/
  4662. onlyOnce?: boolean | undefined);
  4663. /** @hidden */
  4664. _clone(): AnimationEvent;
  4665. }
  4666. /**
  4667. * A cursor which tracks a point on a path
  4668. */
  4669. class PathCursor {
  4670. private path;
  4671. /**
  4672. * Stores path cursor callbacks for when an onchange event is triggered
  4673. */
  4674. private _onchange;
  4675. /**
  4676. * The value of the path cursor
  4677. */
  4678. value: number;
  4679. /**
  4680. * The animation array of the path cursor
  4681. */
  4682. animations: Animation[];
  4683. /**
  4684. * Initializes the path cursor
  4685. * @param path The path to track
  4686. */
  4687. constructor(path: Path2);
  4688. /**
  4689. * Gets the cursor point on the path
  4690. * @returns A point on the path cursor at the cursor location
  4691. */
  4692. getPoint(): Vector3;
  4693. /**
  4694. * Moves the cursor ahead by the step amount
  4695. * @param step The amount to move the cursor forward
  4696. * @returns This path cursor
  4697. */
  4698. moveAhead(step?: number): PathCursor;
  4699. /**
  4700. * Moves the cursor behind by the step amount
  4701. * @param step The amount to move the cursor back
  4702. * @returns This path cursor
  4703. */
  4704. moveBack(step?: number): PathCursor;
  4705. /**
  4706. * Moves the cursor by the step amount
  4707. * If the step amount is greater than one, an exception is thrown
  4708. * @param step The amount to move the cursor
  4709. * @returns This path cursor
  4710. */
  4711. move(step: number): PathCursor;
  4712. /**
  4713. * Ensures that the value is limited between zero and one
  4714. * @returns This path cursor
  4715. */
  4716. private ensureLimits;
  4717. /**
  4718. * Runs onchange callbacks on change (used by the animation engine)
  4719. * @returns This path cursor
  4720. */
  4721. private raiseOnChange;
  4722. /**
  4723. * Executes a function on change
  4724. * @param f A path cursor onchange callback
  4725. * @returns This path cursor
  4726. */
  4727. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4728. }
  4729. /**
  4730. * Defines an interface which represents an animation key frame
  4731. */
  4732. interface IAnimationKey {
  4733. /**
  4734. * Frame of the key frame
  4735. */
  4736. frame: number;
  4737. /**
  4738. * Value at the specifies key frame
  4739. */
  4740. value: any;
  4741. /**
  4742. * The input tangent for the cubic hermite spline
  4743. */
  4744. inTangent?: any;
  4745. /**
  4746. * The output tangent for the cubic hermite spline
  4747. */
  4748. outTangent?: any;
  4749. /**
  4750. * The animation interpolation type
  4751. */
  4752. interpolation?: AnimationKeyInterpolation;
  4753. }
  4754. /**
  4755. * Enum for the animation key frame interpolation type
  4756. */
  4757. enum AnimationKeyInterpolation {
  4758. /**
  4759. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4760. */
  4761. STEP = 1
  4762. }
  4763. /**
  4764. * Class used to store any kind of animation
  4765. */
  4766. class Animation {
  4767. /**Name of the animation */
  4768. name: string;
  4769. /**Property to animate */
  4770. targetProperty: string;
  4771. /**The frames per second of the animation */
  4772. framePerSecond: number;
  4773. /**The data type of the animation */
  4774. dataType: number;
  4775. /**The loop mode of the animation */
  4776. loopMode?: number | undefined;
  4777. /**Specifies if blending should be enabled */
  4778. enableBlending?: boolean | undefined;
  4779. /**
  4780. * Use matrix interpolation instead of using direct key value when animating matrices
  4781. */
  4782. static AllowMatricesInterpolation: boolean;
  4783. /**
  4784. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4785. */
  4786. static AllowMatrixDecomposeForInterpolation: boolean;
  4787. /**
  4788. * Stores the key frames of the animation
  4789. */
  4790. private _keys;
  4791. /**
  4792. * Stores the easing function of the animation
  4793. */
  4794. private _easingFunction;
  4795. /**
  4796. * @hidden Internal use only
  4797. */
  4798. _runtimeAnimations: RuntimeAnimation[];
  4799. /**
  4800. * The set of event that will be linked to this animation
  4801. */
  4802. private _events;
  4803. /**
  4804. * Stores an array of target property paths
  4805. */
  4806. targetPropertyPath: string[];
  4807. /**
  4808. * Stores the blending speed of the animation
  4809. */
  4810. blendingSpeed: number;
  4811. /**
  4812. * Stores the animation ranges for the animation
  4813. */
  4814. private _ranges;
  4815. /**
  4816. * @hidden Internal use
  4817. */
  4818. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4819. /**
  4820. * Sets up an animation
  4821. * @param property The property to animate
  4822. * @param animationType The animation type to apply
  4823. * @param framePerSecond The frames per second of the animation
  4824. * @param easingFunction The easing function used in the animation
  4825. * @returns The created animation
  4826. */
  4827. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4828. /**
  4829. * Create and start an animation on a node
  4830. * @param name defines the name of the global animation that will be run on all nodes
  4831. * @param node defines the root node where the animation will take place
  4832. * @param targetProperty defines property to animate
  4833. * @param framePerSecond defines the number of frame per second yo use
  4834. * @param totalFrame defines the number of frames in total
  4835. * @param from defines the initial value
  4836. * @param to defines the final value
  4837. * @param loopMode defines which loop mode you want to use (off by default)
  4838. * @param easingFunction defines the easing function to use (linear by default)
  4839. * @param onAnimationEnd defines the callback to call when animation end
  4840. * @returns the animatable created for this animation
  4841. */
  4842. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4843. /**
  4844. * Create and start an animation on a node and its descendants
  4845. * @param name defines the name of the global animation that will be run on all nodes
  4846. * @param node defines the root node where the animation will take place
  4847. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  4848. * @param targetProperty defines property to animate
  4849. * @param framePerSecond defines the number of frame per second to use
  4850. * @param totalFrame defines the number of frames in total
  4851. * @param from defines the initial value
  4852. * @param to defines the final value
  4853. * @param loopMode defines which loop mode you want to use (off by default)
  4854. * @param easingFunction defines the easing function to use (linear by default)
  4855. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4856. * @returns the list of animatables created for all nodes
  4857. * @example https://www.babylonjs-playground.com/#MH0VLI
  4858. */
  4859. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  4860. /**
  4861. * Creates a new animation, merges it with the existing animations and starts it
  4862. * @param name Name of the animation
  4863. * @param node Node which contains the scene that begins the animations
  4864. * @param targetProperty Specifies which property to animate
  4865. * @param framePerSecond The frames per second of the animation
  4866. * @param totalFrame The total number of frames
  4867. * @param from The frame at the beginning of the animation
  4868. * @param to The frame at the end of the animation
  4869. * @param loopMode Specifies the loop mode of the animation
  4870. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4871. * @param onAnimationEnd Callback to run once the animation is complete
  4872. * @returns Nullable animation
  4873. */
  4874. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4875. /**
  4876. * Transition property of an host to the target Value
  4877. * @param property The property to transition
  4878. * @param targetValue The target Value of the property
  4879. * @param host The object where the property to animate belongs
  4880. * @param scene Scene used to run the animation
  4881. * @param frameRate Framerate (in frame/s) to use
  4882. * @param transition The transition type we want to use
  4883. * @param duration The duration of the animation, in milliseconds
  4884. * @param onAnimationEnd Callback trigger at the end of the animation
  4885. * @returns Nullable animation
  4886. */
  4887. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4888. /**
  4889. * Return the array of runtime animations currently using this animation
  4890. */
  4891. readonly runtimeAnimations: RuntimeAnimation[];
  4892. /**
  4893. * Specifies if any of the runtime animations are currently running
  4894. */
  4895. readonly hasRunningRuntimeAnimations: boolean;
  4896. /**
  4897. * Initializes the animation
  4898. * @param name Name of the animation
  4899. * @param targetProperty Property to animate
  4900. * @param framePerSecond The frames per second of the animation
  4901. * @param dataType The data type of the animation
  4902. * @param loopMode The loop mode of the animation
  4903. * @param enableBlendings Specifies if blending should be enabled
  4904. */
  4905. constructor(
  4906. /**Name of the animation */
  4907. name: string,
  4908. /**Property to animate */
  4909. targetProperty: string,
  4910. /**The frames per second of the animation */
  4911. framePerSecond: number,
  4912. /**The data type of the animation */
  4913. dataType: number,
  4914. /**The loop mode of the animation */
  4915. loopMode?: number | undefined,
  4916. /**Specifies if blending should be enabled */
  4917. enableBlending?: boolean | undefined);
  4918. /**
  4919. * Converts the animation to a string
  4920. * @param fullDetails support for multiple levels of logging within scene loading
  4921. * @returns String form of the animation
  4922. */
  4923. toString(fullDetails?: boolean): string;
  4924. /**
  4925. * Add an event to this animation
  4926. * @param event Event to add
  4927. */
  4928. addEvent(event: AnimationEvent): void;
  4929. /**
  4930. * Remove all events found at the given frame
  4931. * @param frame The frame to remove events from
  4932. */
  4933. removeEvents(frame: number): void;
  4934. /**
  4935. * Retrieves all the events from the animation
  4936. * @returns Events from the animation
  4937. */
  4938. getEvents(): AnimationEvent[];
  4939. /**
  4940. * Creates an animation range
  4941. * @param name Name of the animation range
  4942. * @param from Starting frame of the animation range
  4943. * @param to Ending frame of the animation
  4944. */
  4945. createRange(name: string, from: number, to: number): void;
  4946. /**
  4947. * Deletes an animation range by name
  4948. * @param name Name of the animation range to delete
  4949. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4950. */
  4951. deleteRange(name: string, deleteFrames?: boolean): void;
  4952. /**
  4953. * Gets the animation range by name, or null if not defined
  4954. * @param name Name of the animation range
  4955. * @returns Nullable animation range
  4956. */
  4957. getRange(name: string): Nullable<AnimationRange>;
  4958. /**
  4959. * Gets the key frames from the animation
  4960. * @returns The key frames of the animation
  4961. */
  4962. getKeys(): Array<IAnimationKey>;
  4963. /**
  4964. * Gets the highest frame rate of the animation
  4965. * @returns Highest frame rate of the animation
  4966. */
  4967. getHighestFrame(): number;
  4968. /**
  4969. * Gets the easing function of the animation
  4970. * @returns Easing function of the animation
  4971. */
  4972. getEasingFunction(): IEasingFunction;
  4973. /**
  4974. * Sets the easing function of the animation
  4975. * @param easingFunction A custom mathematical formula for animation
  4976. */
  4977. setEasingFunction(easingFunction: EasingFunction): void;
  4978. /**
  4979. * Interpolates a scalar linearly
  4980. * @param startValue Start value of the animation curve
  4981. * @param endValue End value of the animation curve
  4982. * @param gradient Scalar amount to interpolate
  4983. * @returns Interpolated scalar value
  4984. */
  4985. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4986. /**
  4987. * Interpolates a scalar cubically
  4988. * @param startValue Start value of the animation curve
  4989. * @param outTangent End tangent of the animation
  4990. * @param endValue End value of the animation curve
  4991. * @param inTangent Start tangent of the animation curve
  4992. * @param gradient Scalar amount to interpolate
  4993. * @returns Interpolated scalar value
  4994. */
  4995. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4996. /**
  4997. * Interpolates a quaternion using a spherical linear interpolation
  4998. * @param startValue Start value of the animation curve
  4999. * @param endValue End value of the animation curve
  5000. * @param gradient Scalar amount to interpolate
  5001. * @returns Interpolated quaternion value
  5002. */
  5003. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  5004. /**
  5005. * Interpolates a quaternion cubically
  5006. * @param startValue Start value of the animation curve
  5007. * @param outTangent End tangent of the animation curve
  5008. * @param endValue End value of the animation curve
  5009. * @param inTangent Start tangent of the animation curve
  5010. * @param gradient Scalar amount to interpolate
  5011. * @returns Interpolated quaternion value
  5012. */
  5013. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  5014. /**
  5015. * Interpolates a Vector3 linearl
  5016. * @param startValue Start value of the animation curve
  5017. * @param endValue End value of the animation curve
  5018. * @param gradient Scalar amount to interpolate
  5019. * @returns Interpolated scalar value
  5020. */
  5021. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  5022. /**
  5023. * Interpolates a Vector3 cubically
  5024. * @param startValue Start value of the animation curve
  5025. * @param outTangent End tangent of the animation
  5026. * @param endValue End value of the animation curve
  5027. * @param inTangent Start tangent of the animation curve
  5028. * @param gradient Scalar amount to interpolate
  5029. * @returns InterpolatedVector3 value
  5030. */
  5031. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  5032. /**
  5033. * Interpolates a Vector2 linearly
  5034. * @param startValue Start value of the animation curve
  5035. * @param endValue End value of the animation curve
  5036. * @param gradient Scalar amount to interpolate
  5037. * @returns Interpolated Vector2 value
  5038. */
  5039. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  5040. /**
  5041. * Interpolates a Vector2 cubically
  5042. * @param startValue Start value of the animation curve
  5043. * @param outTangent End tangent of the animation
  5044. * @param endValue End value of the animation curve
  5045. * @param inTangent Start tangent of the animation curve
  5046. * @param gradient Scalar amount to interpolate
  5047. * @returns Interpolated Vector2 value
  5048. */
  5049. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  5050. /**
  5051. * Interpolates a size linearly
  5052. * @param startValue Start value of the animation curve
  5053. * @param endValue End value of the animation curve
  5054. * @param gradient Scalar amount to interpolate
  5055. * @returns Interpolated Size value
  5056. */
  5057. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  5058. /**
  5059. * Interpolates a Color3 linearly
  5060. * @param startValue Start value of the animation curve
  5061. * @param endValue End value of the animation curve
  5062. * @param gradient Scalar amount to interpolate
  5063. * @returns Interpolated Color3 value
  5064. */
  5065. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  5066. /**
  5067. * @hidden Internal use only
  5068. */
  5069. _getKeyValue(value: any): any;
  5070. /**
  5071. * @hidden Internal use only
  5072. */
  5073. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  5074. /**
  5075. * Defines the function to use to interpolate matrices
  5076. * @param startValue defines the start matrix
  5077. * @param endValue defines the end matrix
  5078. * @param gradient defines the gradient between both matrices
  5079. * @param result defines an optional target matrix where to store the interpolation
  5080. * @returns the interpolated matrix
  5081. */
  5082. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  5083. /**
  5084. * Makes a copy of the animation
  5085. * @returns Cloned animation
  5086. */
  5087. clone(): Animation;
  5088. /**
  5089. * Sets the key frames of the animation
  5090. * @param values The animation key frames to set
  5091. */
  5092. setKeys(values: Array<IAnimationKey>): void;
  5093. /**
  5094. * Serializes the animation to an object
  5095. * @returns Serialized object
  5096. */
  5097. serialize(): any;
  5098. /**
  5099. * Float animation type
  5100. */
  5101. private static _ANIMATIONTYPE_FLOAT;
  5102. /**
  5103. * Vector3 animation type
  5104. */
  5105. private static _ANIMATIONTYPE_VECTOR3;
  5106. /**
  5107. * Quaternion animation type
  5108. */
  5109. private static _ANIMATIONTYPE_QUATERNION;
  5110. /**
  5111. * Matrix animation type
  5112. */
  5113. private static _ANIMATIONTYPE_MATRIX;
  5114. /**
  5115. * Color3 animation type
  5116. */
  5117. private static _ANIMATIONTYPE_COLOR3;
  5118. /**
  5119. * Vector2 animation type
  5120. */
  5121. private static _ANIMATIONTYPE_VECTOR2;
  5122. /**
  5123. * Size animation type
  5124. */
  5125. private static _ANIMATIONTYPE_SIZE;
  5126. /**
  5127. * Relative Loop Mode
  5128. */
  5129. private static _ANIMATIONLOOPMODE_RELATIVE;
  5130. /**
  5131. * Cycle Loop Mode
  5132. */
  5133. private static _ANIMATIONLOOPMODE_CYCLE;
  5134. /**
  5135. * Constant Loop Mode
  5136. */
  5137. private static _ANIMATIONLOOPMODE_CONSTANT;
  5138. /**
  5139. * Get the float animation type
  5140. */
  5141. static readonly ANIMATIONTYPE_FLOAT: number;
  5142. /**
  5143. * Get the Vector3 animation type
  5144. */
  5145. static readonly ANIMATIONTYPE_VECTOR3: number;
  5146. /**
  5147. * Get the Vector2 animation type
  5148. */
  5149. static readonly ANIMATIONTYPE_VECTOR2: number;
  5150. /**
  5151. * Get the Size animation type
  5152. */
  5153. static readonly ANIMATIONTYPE_SIZE: number;
  5154. /**
  5155. * Get the Quaternion animation type
  5156. */
  5157. static readonly ANIMATIONTYPE_QUATERNION: number;
  5158. /**
  5159. * Get the Matrix animation type
  5160. */
  5161. static readonly ANIMATIONTYPE_MATRIX: number;
  5162. /**
  5163. * Get the Color3 animation type
  5164. */
  5165. static readonly ANIMATIONTYPE_COLOR3: number;
  5166. /**
  5167. * Get the Relative Loop Mode
  5168. */
  5169. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  5170. /**
  5171. * Get the Cycle Loop Mode
  5172. */
  5173. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  5174. /**
  5175. * Get the Constant Loop Mode
  5176. */
  5177. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  5178. /** @hidden */
  5179. static _UniversalLerp(left: any, right: any, amount: number): any;
  5180. /**
  5181. * Parses an animation object and creates an animation
  5182. * @param parsedAnimation Parsed animation object
  5183. * @returns Animation object
  5184. */
  5185. static Parse(parsedAnimation: any): Animation;
  5186. /**
  5187. * Appends the serialized animations from the source animations
  5188. * @param source Source containing the animations
  5189. * @param destination Target to store the animations
  5190. */
  5191. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  5192. }
  5193. }
  5194. declare module BABYLON {
  5195. /**
  5196. * This class defines the direct association between an animation and a target
  5197. */
  5198. class TargetedAnimation {
  5199. /**
  5200. * Animation to perform
  5201. */
  5202. animation: Animation;
  5203. /**
  5204. * Target to animate
  5205. */
  5206. target: any;
  5207. }
  5208. /**
  5209. * Use this class to create coordinated animations on multiple targets
  5210. */
  5211. class AnimationGroup implements IDisposable {
  5212. /** The name of the animation group */
  5213. name: string;
  5214. private _scene;
  5215. private _targetedAnimations;
  5216. private _animatables;
  5217. private _from;
  5218. private _to;
  5219. private _isStarted;
  5220. private _speedRatio;
  5221. /**
  5222. * This observable will notify when one animation have ended.
  5223. */
  5224. onAnimationEndObservable: Observable<TargetedAnimation>;
  5225. /**
  5226. * This observable will notify when all animations have ended.
  5227. */
  5228. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  5229. /**
  5230. * This observable will notify when all animations have paused.
  5231. */
  5232. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  5233. /**
  5234. * Gets the first frame
  5235. */
  5236. readonly from: number;
  5237. /**
  5238. * Gets the last frame
  5239. */
  5240. readonly to: number;
  5241. /**
  5242. * Define if the animations are started
  5243. */
  5244. readonly isStarted: boolean;
  5245. /**
  5246. * Gets or sets the speed ratio to use for all animations
  5247. */
  5248. /**
  5249. * Gets or sets the speed ratio to use for all animations
  5250. */
  5251. speedRatio: number;
  5252. /**
  5253. * Gets the targeted animations for this animation group
  5254. */
  5255. readonly targetedAnimations: Array<TargetedAnimation>;
  5256. /**
  5257. * returning the list of animatables controlled by this animation group.
  5258. */
  5259. readonly animatables: Array<Animatable>;
  5260. /**
  5261. * Instantiates a new Animation Group.
  5262. * This helps managing several animations at once.
  5263. * @see http://doc.babylonjs.com/how_to/group
  5264. * @param name Defines the name of the group
  5265. * @param scene Defines the scene the group belongs to
  5266. */
  5267. constructor(
  5268. /** The name of the animation group */
  5269. name: string, scene?: Nullable<Scene>);
  5270. /**
  5271. * Add an animation (with its target) in the group
  5272. * @param animation defines the animation we want to add
  5273. * @param target defines the target of the animation
  5274. * @returns the TargetedAnimation object
  5275. */
  5276. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  5277. /**
  5278. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  5279. * It can add constant keys at begin or end
  5280. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  5281. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  5282. * @returns the animation group
  5283. */
  5284. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  5285. /**
  5286. * Start all animations on given targets
  5287. * @param loop defines if animations must loop
  5288. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  5289. * @param from defines the from key (optional)
  5290. * @param to defines the to key (optional)
  5291. * @returns the current animation group
  5292. */
  5293. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  5294. /**
  5295. * Pause all animations
  5296. * @returns the animation group
  5297. */
  5298. pause(): AnimationGroup;
  5299. /**
  5300. * Play all animations to initial state
  5301. * This function will start() the animations if they were not started or will restart() them if they were paused
  5302. * @param loop defines if animations must loop
  5303. * @returns the animation group
  5304. */
  5305. play(loop?: boolean): AnimationGroup;
  5306. /**
  5307. * Reset all animations to initial state
  5308. * @returns the animation group
  5309. */
  5310. reset(): AnimationGroup;
  5311. /**
  5312. * Restart animations from key 0
  5313. * @returns the animation group
  5314. */
  5315. restart(): AnimationGroup;
  5316. /**
  5317. * Stop all animations
  5318. * @returns the animation group
  5319. */
  5320. stop(): AnimationGroup;
  5321. /**
  5322. * Set animation weight for all animatables
  5323. * @param weight defines the weight to use
  5324. * @return the animationGroup
  5325. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  5326. */
  5327. setWeightForAllAnimatables(weight: number): AnimationGroup;
  5328. /**
  5329. * Synchronize and normalize all animatables with a source animatable
  5330. * @param root defines the root animatable to synchronize with
  5331. * @return the animationGroup
  5332. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  5333. */
  5334. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  5335. /**
  5336. * Goes to a specific frame in this animation group
  5337. * @param frame the frame number to go to
  5338. * @return the animationGroup
  5339. */
  5340. goToFrame(frame: number): AnimationGroup;
  5341. /**
  5342. * Dispose all associated resources
  5343. */
  5344. dispose(): void;
  5345. private _checkAnimationGroupEnded;
  5346. /**
  5347. * Returns a new AnimationGroup object parsed from the source provided.
  5348. * @param parsedAnimationGroup defines the source
  5349. * @param scene defines the scene that will receive the animationGroup
  5350. * @returns a new AnimationGroup
  5351. */
  5352. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  5353. /**
  5354. * Returns the string "AnimationGroup"
  5355. * @returns "AnimationGroup"
  5356. */
  5357. getClassName(): string;
  5358. /**
  5359. * Creates a detailled string about the object
  5360. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  5361. * @returns a string representing the object
  5362. */
  5363. toString(fullDetails?: boolean): string;
  5364. }
  5365. }
  5366. declare module BABYLON {
  5367. /**
  5368. * Class used to override all child animations of a given target
  5369. */
  5370. class AnimationPropertiesOverride {
  5371. /**
  5372. * Gets or sets a value indicating if animation blending must be used
  5373. */
  5374. enableBlending: boolean;
  5375. /**
  5376. * Gets or sets the blending speed to use when enableBlending is true
  5377. */
  5378. blendingSpeed: number;
  5379. /**
  5380. * Gets or sets the default loop mode to use
  5381. */
  5382. loopMode: number;
  5383. }
  5384. }
  5385. declare module BABYLON {
  5386. /**
  5387. * This represents the main contract an easing function should follow.
  5388. * Easing functions are used throughout the animation system.
  5389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. interface IEasingFunction {
  5392. /**
  5393. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5394. * of the easing function.
  5395. * The link below provides some of the most common examples of easing functions.
  5396. * @see https://easings.net/
  5397. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5398. * @returns the corresponding value on the curve defined by the easing function
  5399. */
  5400. ease(gradient: number): number;
  5401. }
  5402. /**
  5403. * Base class used for every default easing function.
  5404. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5405. */
  5406. class EasingFunction implements IEasingFunction {
  5407. /**
  5408. * Interpolation follows the mathematical formula associated with the easing function.
  5409. */
  5410. static readonly EASINGMODE_EASEIN: number;
  5411. /**
  5412. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5413. */
  5414. static readonly EASINGMODE_EASEOUT: number;
  5415. /**
  5416. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5417. */
  5418. static readonly EASINGMODE_EASEINOUT: number;
  5419. private _easingMode;
  5420. /**
  5421. * Sets the easing mode of the current function.
  5422. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5423. */
  5424. setEasingMode(easingMode: number): void;
  5425. /**
  5426. * Gets the current easing mode.
  5427. * @returns the easing mode
  5428. */
  5429. getEasingMode(): number;
  5430. /**
  5431. * @hidden
  5432. */
  5433. easeInCore(gradient: number): number;
  5434. /**
  5435. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5436. * of the easing function.
  5437. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5438. * @returns the corresponding value on the curve defined by the easing function
  5439. */
  5440. ease(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a circle shape (see link below).
  5444. * @see https://easings.net/#easeInCirc
  5445. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. class CircleEase extends EasingFunction implements IEasingFunction {
  5448. /** @hidden */
  5449. easeInCore(gradient: number): number;
  5450. }
  5451. /**
  5452. * Easing function with a ease back shape (see link below).
  5453. * @see https://easings.net/#easeInBack
  5454. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5455. */
  5456. class BackEase extends EasingFunction implements IEasingFunction {
  5457. /** Defines the amplitude of the function */
  5458. amplitude: number;
  5459. /**
  5460. * Instantiates a back ease easing
  5461. * @see https://easings.net/#easeInBack
  5462. * @param amplitude Defines the amplitude of the function
  5463. */
  5464. constructor(
  5465. /** Defines the amplitude of the function */
  5466. amplitude?: number);
  5467. /** @hidden */
  5468. easeInCore(gradient: number): number;
  5469. }
  5470. /**
  5471. * Easing function with a bouncing shape (see link below).
  5472. * @see https://easings.net/#easeInBounce
  5473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5474. */
  5475. class BounceEase extends EasingFunction implements IEasingFunction {
  5476. /** Defines the number of bounces */
  5477. bounces: number;
  5478. /** Defines the amplitude of the bounce */
  5479. bounciness: number;
  5480. /**
  5481. * Instantiates a bounce easing
  5482. * @see https://easings.net/#easeInBounce
  5483. * @param bounces Defines the number of bounces
  5484. * @param bounciness Defines the amplitude of the bounce
  5485. */
  5486. constructor(
  5487. /** Defines the number of bounces */
  5488. bounces?: number,
  5489. /** Defines the amplitude of the bounce */
  5490. bounciness?: number);
  5491. /** @hidden */
  5492. easeInCore(gradient: number): number;
  5493. }
  5494. /**
  5495. * Easing function with a power of 3 shape (see link below).
  5496. * @see https://easings.net/#easeInCubic
  5497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5498. */
  5499. class CubicEase extends EasingFunction implements IEasingFunction {
  5500. /** @hidden */
  5501. easeInCore(gradient: number): number;
  5502. }
  5503. /**
  5504. * Easing function with an elastic shape (see link below).
  5505. * @see https://easings.net/#easeInElastic
  5506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5507. */
  5508. class ElasticEase extends EasingFunction implements IEasingFunction {
  5509. /** Defines the number of oscillations*/
  5510. oscillations: number;
  5511. /** Defines the amplitude of the oscillations*/
  5512. springiness: number;
  5513. /**
  5514. * Instantiates an elastic easing function
  5515. * @see https://easings.net/#easeInElastic
  5516. * @param oscillations Defines the number of oscillations
  5517. * @param springiness Defines the amplitude of the oscillations
  5518. */
  5519. constructor(
  5520. /** Defines the number of oscillations*/
  5521. oscillations?: number,
  5522. /** Defines the amplitude of the oscillations*/
  5523. springiness?: number);
  5524. /** @hidden */
  5525. easeInCore(gradient: number): number;
  5526. }
  5527. /**
  5528. * Easing function with an exponential shape (see link below).
  5529. * @see https://easings.net/#easeInExpo
  5530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5531. */
  5532. class ExponentialEase extends EasingFunction implements IEasingFunction {
  5533. /** Defines the exponent of the function */
  5534. exponent: number;
  5535. /**
  5536. * Instantiates an exponential easing function
  5537. * @see https://easings.net/#easeInExpo
  5538. * @param exponent Defines the exponent of the function
  5539. */
  5540. constructor(
  5541. /** Defines the exponent of the function */
  5542. exponent?: number);
  5543. /** @hidden */
  5544. easeInCore(gradient: number): number;
  5545. }
  5546. /**
  5547. * Easing function with a power shape (see link below).
  5548. * @see https://easings.net/#easeInQuad
  5549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5550. */
  5551. class PowerEase extends EasingFunction implements IEasingFunction {
  5552. /** Defines the power of the function */
  5553. power: number;
  5554. /**
  5555. * Instantiates an power base easing function
  5556. * @see https://easings.net/#easeInQuad
  5557. * @param power Defines the power of the function
  5558. */
  5559. constructor(
  5560. /** Defines the power of the function */
  5561. power?: number);
  5562. /** @hidden */
  5563. easeInCore(gradient: number): number;
  5564. }
  5565. /**
  5566. * Easing function with a power of 2 shape (see link below).
  5567. * @see https://easings.net/#easeInQuad
  5568. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5569. */
  5570. class QuadraticEase extends EasingFunction implements IEasingFunction {
  5571. /** @hidden */
  5572. easeInCore(gradient: number): number;
  5573. }
  5574. /**
  5575. * Easing function with a power of 4 shape (see link below).
  5576. * @see https://easings.net/#easeInQuart
  5577. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5578. */
  5579. class QuarticEase extends EasingFunction implements IEasingFunction {
  5580. /** @hidden */
  5581. easeInCore(gradient: number): number;
  5582. }
  5583. /**
  5584. * Easing function with a power of 5 shape (see link below).
  5585. * @see https://easings.net/#easeInQuint
  5586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5587. */
  5588. class QuinticEase extends EasingFunction implements IEasingFunction {
  5589. /** @hidden */
  5590. easeInCore(gradient: number): number;
  5591. }
  5592. /**
  5593. * Easing function with a sin shape (see link below).
  5594. * @see https://easings.net/#easeInSine
  5595. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5596. */
  5597. class SineEase extends EasingFunction implements IEasingFunction {
  5598. /** @hidden */
  5599. easeInCore(gradient: number): number;
  5600. }
  5601. /**
  5602. * Easing function with a bezier shape (see link below).
  5603. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5605. */
  5606. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5607. /** Defines the x component of the start tangent in the bezier curve */
  5608. x1: number;
  5609. /** Defines the y component of the start tangent in the bezier curve */
  5610. y1: number;
  5611. /** Defines the x component of the end tangent in the bezier curve */
  5612. x2: number;
  5613. /** Defines the y component of the end tangent in the bezier curve */
  5614. y2: number;
  5615. /**
  5616. * Instantiates a bezier function
  5617. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5618. * @param x1 Defines the x component of the start tangent in the bezier curve
  5619. * @param y1 Defines the y component of the start tangent in the bezier curve
  5620. * @param x2 Defines the x component of the end tangent in the bezier curve
  5621. * @param y2 Defines the y component of the end tangent in the bezier curve
  5622. */
  5623. constructor(
  5624. /** Defines the x component of the start tangent in the bezier curve */
  5625. x1?: number,
  5626. /** Defines the y component of the start tangent in the bezier curve */
  5627. y1?: number,
  5628. /** Defines the x component of the end tangent in the bezier curve */
  5629. x2?: number,
  5630. /** Defines the y component of the end tangent in the bezier curve */
  5631. y2?: number);
  5632. /** @hidden */
  5633. easeInCore(gradient: number): number;
  5634. }
  5635. }
  5636. declare module BABYLON {
  5637. /**
  5638. * Defines a runtime animation
  5639. */
  5640. class RuntimeAnimation {
  5641. private _events;
  5642. /**
  5643. * The current frame of the runtime animation
  5644. */
  5645. private _currentFrame;
  5646. /**
  5647. * The animation used by the runtime animation
  5648. */
  5649. private _animation;
  5650. /**
  5651. * The target of the runtime animation
  5652. */
  5653. private _target;
  5654. /**
  5655. * The initiating animatable
  5656. */
  5657. private _host;
  5658. /**
  5659. * The original value of the runtime animation
  5660. */
  5661. private _originalValue;
  5662. /**
  5663. * The original blend value of the runtime animation
  5664. */
  5665. private _originalBlendValue;
  5666. /**
  5667. * The offsets cache of the runtime animation
  5668. */
  5669. private _offsetsCache;
  5670. /**
  5671. * The high limits cache of the runtime animation
  5672. */
  5673. private _highLimitsCache;
  5674. /**
  5675. * Specifies if the runtime animation has been stopped
  5676. */
  5677. private _stopped;
  5678. /**
  5679. * The blending factor of the runtime animation
  5680. */
  5681. private _blendingFactor;
  5682. /**
  5683. * The BabylonJS scene
  5684. */
  5685. private _scene;
  5686. /**
  5687. * The current value of the runtime animation
  5688. */
  5689. private _currentValue;
  5690. /** @hidden */
  5691. _workValue: any;
  5692. /**
  5693. * The active target of the runtime animation
  5694. */
  5695. private _activeTarget;
  5696. /**
  5697. * The target path of the runtime animation
  5698. */
  5699. private _targetPath;
  5700. /**
  5701. * The weight of the runtime animation
  5702. */
  5703. private _weight;
  5704. /**
  5705. * The ratio offset of the runtime animation
  5706. */
  5707. private _ratioOffset;
  5708. /**
  5709. * The previous delay of the runtime animation
  5710. */
  5711. private _previousDelay;
  5712. /**
  5713. * The previous ratio of the runtime animation
  5714. */
  5715. private _previousRatio;
  5716. /**
  5717. * Gets the current frame of the runtime animation
  5718. */
  5719. readonly currentFrame: number;
  5720. /**
  5721. * Gets the weight of the runtime animation
  5722. */
  5723. readonly weight: number;
  5724. /**
  5725. * Gets the current value of the runtime animation
  5726. */
  5727. readonly currentValue: any;
  5728. /**
  5729. * Gets the target path of the runtime animation
  5730. */
  5731. readonly targetPath: string;
  5732. /**
  5733. * Gets the actual target of the runtime animation
  5734. */
  5735. readonly target: any;
  5736. /**
  5737. * Create a new RuntimeAnimation object
  5738. * @param target defines the target of the animation
  5739. * @param animation defines the source animation object
  5740. * @param scene defines the hosting scene
  5741. * @param host defines the initiating Animatable
  5742. */
  5743. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5744. /**
  5745. * Gets the animation from the runtime animation
  5746. */
  5747. readonly animation: Animation;
  5748. /**
  5749. * Resets the runtime animation to the beginning
  5750. * @param restoreOriginal defines whether to restore the target property to the original value
  5751. */
  5752. reset(restoreOriginal?: boolean): void;
  5753. /**
  5754. * Specifies if the runtime animation is stopped
  5755. * @returns Boolean specifying if the runtime animation is stopped
  5756. */
  5757. isStopped(): boolean;
  5758. /**
  5759. * Disposes of the runtime animation
  5760. */
  5761. dispose(): void;
  5762. /**
  5763. * Interpolates the animation from the current frame
  5764. * @param currentFrame The frame to interpolate the animation to
  5765. * @param repeatCount The number of times that the animation should loop
  5766. * @param loopMode The type of looping mode to use
  5767. * @param offsetValue Animation offset value
  5768. * @param highLimitValue The high limit value
  5769. * @returns The interpolated value
  5770. */
  5771. private _interpolate;
  5772. /**
  5773. * Apply the interpolated value to the target
  5774. * @param currentValue defines the value computed by the animation
  5775. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5776. */
  5777. setValue(currentValue: any, weight?: number): void;
  5778. private _setValue;
  5779. /**
  5780. * Gets the loop pmode of the runtime animation
  5781. * @returns Loop Mode
  5782. */
  5783. private _getCorrectLoopMode;
  5784. /**
  5785. * Move the current animation to a given frame
  5786. * @param frame defines the frame to move to
  5787. */
  5788. goToFrame(frame: number): void;
  5789. /**
  5790. * @hidden Internal use only
  5791. */
  5792. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5793. /**
  5794. * Execute the current animation
  5795. * @param delay defines the delay to add to the current frame
  5796. * @param from defines the lower bound of the animation range
  5797. * @param to defines the upper bound of the animation range
  5798. * @param loop defines if the current animation must loop
  5799. * @param speedRatio defines the current speed ratio
  5800. * @param weight defines the weight of the animation (default is -1 so no weight)
  5801. * @returns a boolean indicating if the animation is running
  5802. */
  5803. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5804. }
  5805. }
  5806. declare module BABYLON {
  5807. /**
  5808. * Interface used to define a behavior
  5809. */
  5810. interface Behavior<T> {
  5811. /** gets or sets behavior's name */
  5812. name: string;
  5813. /**
  5814. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5815. */
  5816. init(): void;
  5817. /**
  5818. * Called when the behavior is attached to a target
  5819. * @param target defines the target where the behavior is attached to
  5820. */
  5821. attach(target: T): void;
  5822. /**
  5823. * Called when the behavior is detached from its target
  5824. */
  5825. detach(): void;
  5826. }
  5827. /**
  5828. * Interface implemented by classes supporting behaviors
  5829. */
  5830. interface IBehaviorAware<T> {
  5831. /**
  5832. * Attach a behavior
  5833. * @param behavior defines the behavior to attach
  5834. * @returns the current host
  5835. */
  5836. addBehavior(behavior: Behavior<T>): T;
  5837. /**
  5838. * Remove a behavior from the current object
  5839. * @param behavior defines the behavior to detach
  5840. * @returns the current host
  5841. */
  5842. removeBehavior(behavior: Behavior<T>): T;
  5843. /**
  5844. * Gets a behavior using its name to search
  5845. * @param name defines the name to search
  5846. * @returns the behavior or null if not found
  5847. */
  5848. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5849. }
  5850. }
  5851. declare module BABYLON {
  5852. /**
  5853. * Class used to store bone information
  5854. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5855. */
  5856. class Bone extends Node {
  5857. /**
  5858. * defines the bone name
  5859. */
  5860. name: string;
  5861. private static _tmpVecs;
  5862. private static _tmpQuat;
  5863. private static _tmpMats;
  5864. /**
  5865. * Gets the list of child bones
  5866. */
  5867. children: Bone[];
  5868. /** Gets the animations associated with this bone */
  5869. animations: Animation[];
  5870. /**
  5871. * Gets or sets bone length
  5872. */
  5873. length: number;
  5874. /**
  5875. * @hidden Internal only
  5876. * Set this value to map this bone to a different index in the transform matrices
  5877. * Set this value to -1 to exclude the bone from the transform matrices
  5878. */
  5879. _index: Nullable<number>;
  5880. private _skeleton;
  5881. private _localMatrix;
  5882. private _restPose;
  5883. private _baseMatrix;
  5884. private _absoluteTransform;
  5885. private _invertedAbsoluteTransform;
  5886. private _parent;
  5887. private _scalingDeterminant;
  5888. private _worldTransform;
  5889. private _localScaling;
  5890. private _localRotation;
  5891. private _localPosition;
  5892. private _needToDecompose;
  5893. private _needToCompose;
  5894. /** @hidden */
  5895. /** @hidden */
  5896. _matrix: Matrix;
  5897. /**
  5898. * Create a new bone
  5899. * @param name defines the bone name
  5900. * @param skeleton defines the parent skeleton
  5901. * @param parentBone defines the parent (can be null if the bone is the root)
  5902. * @param localMatrix defines the local matrix
  5903. * @param restPose defines the rest pose matrix
  5904. * @param baseMatrix defines the base matrix
  5905. * @param index defines index of the bone in the hiearchy
  5906. */
  5907. constructor(
  5908. /**
  5909. * defines the bone name
  5910. */
  5911. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5912. /**
  5913. * Gets the parent skeleton
  5914. * @returns a skeleton
  5915. */
  5916. getSkeleton(): Skeleton;
  5917. /**
  5918. * Gets parent bone
  5919. * @returns a bone or null if the bone is the root of the bone hierarchy
  5920. */
  5921. getParent(): Nullable<Bone>;
  5922. /**
  5923. * Sets the parent bone
  5924. * @param parent defines the parent (can be null if the bone is the root)
  5925. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5926. */
  5927. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5928. /**
  5929. * Gets the local matrix
  5930. * @returns a matrix
  5931. */
  5932. getLocalMatrix(): Matrix;
  5933. /**
  5934. * Gets the base matrix (initial matrix which remains unchanged)
  5935. * @returns a matrix
  5936. */
  5937. getBaseMatrix(): Matrix;
  5938. /**
  5939. * Gets the rest pose matrix
  5940. * @returns a matrix
  5941. */
  5942. getRestPose(): Matrix;
  5943. /**
  5944. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5945. */
  5946. getWorldMatrix(): Matrix;
  5947. /**
  5948. * Sets the local matrix to rest pose matrix
  5949. */
  5950. returnToRest(): void;
  5951. /**
  5952. * Gets the inverse of the absolute transform matrix.
  5953. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5954. * @returns a matrix
  5955. */
  5956. getInvertedAbsoluteTransform(): Matrix;
  5957. /**
  5958. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5959. * @returns a matrix
  5960. */
  5961. getAbsoluteTransform(): Matrix;
  5962. /** Gets or sets current position (in local space) */
  5963. position: Vector3;
  5964. /** Gets or sets current rotation (in local space) */
  5965. rotation: Vector3;
  5966. /** Gets or sets current rotation quaternion (in local space) */
  5967. rotationQuaternion: Quaternion;
  5968. /** Gets or sets current scaling (in local space) */
  5969. scaling: Vector3;
  5970. /**
  5971. * Gets the animation properties override
  5972. */
  5973. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5974. private _decompose;
  5975. private _compose;
  5976. /**
  5977. * Update the base and local matrices
  5978. * @param matrix defines the new base or local matrix
  5979. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5980. * @param updateLocalMatrix defines if the local matrix should be updated
  5981. */
  5982. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5983. /** @hidden */
  5984. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5985. /**
  5986. * Flag the bone as dirty (Forcing it to update everything)
  5987. */
  5988. markAsDirty(): void;
  5989. private _markAsDirtyAndCompose;
  5990. private _markAsDirtyAndDecompose;
  5991. /**
  5992. * Copy an animation range from another bone
  5993. * @param source defines the source bone
  5994. * @param rangeName defines the range name to copy
  5995. * @param frameOffset defines the frame offset
  5996. * @param rescaleAsRequired defines if rescaling must be applied if required
  5997. * @param skelDimensionsRatio defines the scaling ratio
  5998. * @returns true if operation was successful
  5999. */
  6000. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6001. /**
  6002. * Translate the bone in local or world space
  6003. * @param vec The amount to translate the bone
  6004. * @param space The space that the translation is in
  6005. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6006. */
  6007. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6008. /**
  6009. * Set the postion of the bone in local or world space
  6010. * @param position The position to set the bone
  6011. * @param space The space that the position is in
  6012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6013. */
  6014. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6015. /**
  6016. * Set the absolute position of the bone (world space)
  6017. * @param position The position to set the bone
  6018. * @param mesh The mesh that this bone is attached to
  6019. */
  6020. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6021. /**
  6022. * Scale the bone on the x, y and z axes (in local space)
  6023. * @param x The amount to scale the bone on the x axis
  6024. * @param y The amount to scale the bone on the y axis
  6025. * @param z The amount to scale the bone on the z axis
  6026. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6027. */
  6028. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6029. /**
  6030. * Set the bone scaling in local space
  6031. * @param scale defines the scaling vector
  6032. */
  6033. setScale(scale: Vector3): void;
  6034. /**
  6035. * Gets the current scaling in local space
  6036. * @returns the current scaling vector
  6037. */
  6038. getScale(): Vector3;
  6039. /**
  6040. * Gets the current scaling in local space and stores it in a target vector
  6041. * @param result defines the target vector
  6042. */
  6043. getScaleToRef(result: Vector3): void;
  6044. /**
  6045. * Set the yaw, pitch, and roll of the bone in local or world space
  6046. * @param yaw The rotation of the bone on the y axis
  6047. * @param pitch The rotation of the bone on the x axis
  6048. * @param roll The rotation of the bone on the z axis
  6049. * @param space The space that the axes of rotation are in
  6050. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6051. */
  6052. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6053. /**
  6054. * Add a rotation to the bone on an axis in local or world space
  6055. * @param axis The axis to rotate the bone on
  6056. * @param amount The amount to rotate the bone
  6057. * @param space The space that the axis is in
  6058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6059. */
  6060. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6061. /**
  6062. * Set the rotation of the bone to a particular axis angle in local or world space
  6063. * @param axis The axis to rotate the bone on
  6064. * @param angle The angle that the bone should be rotated to
  6065. * @param space The space that the axis is in
  6066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6067. */
  6068. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6069. /**
  6070. * Set the euler rotation of the bone in local of world space
  6071. * @param rotation The euler rotation that the bone should be set to
  6072. * @param space The space that the rotation is in
  6073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6074. */
  6075. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6076. /**
  6077. * Set the quaternion rotation of the bone in local of world space
  6078. * @param quat The quaternion rotation that the bone should be set to
  6079. * @param space The space that the rotation is in
  6080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6081. */
  6082. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6083. /**
  6084. * Set the rotation matrix of the bone in local of world space
  6085. * @param rotMat The rotation matrix that the bone should be set to
  6086. * @param space The space that the rotation is in
  6087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6088. */
  6089. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6090. private _rotateWithMatrix;
  6091. private _getNegativeRotationToRef;
  6092. /**
  6093. * Get the position of the bone in local or world space
  6094. * @param space The space that the returned position is in
  6095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6096. * @returns The position of the bone
  6097. */
  6098. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6099. /**
  6100. * Copy the position of the bone to a vector3 in local or world space
  6101. * @param space The space that the returned position is in
  6102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6103. * @param result The vector3 to copy the position to
  6104. */
  6105. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6106. /**
  6107. * Get the absolute position of the bone (world space)
  6108. * @param mesh The mesh that this bone is attached to
  6109. * @returns The absolute position of the bone
  6110. */
  6111. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6112. /**
  6113. * Copy the absolute position of the bone (world space) to the result param
  6114. * @param mesh The mesh that this bone is attached to
  6115. * @param result The vector3 to copy the absolute position to
  6116. */
  6117. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6118. /**
  6119. * Compute the absolute transforms of this bone and its children
  6120. */
  6121. computeAbsoluteTransforms(): void;
  6122. /**
  6123. * Get the world direction from an axis that is in the local space of the bone
  6124. * @param localAxis The local direction that is used to compute the world direction
  6125. * @param mesh The mesh that this bone is attached to
  6126. * @returns The world direction
  6127. */
  6128. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6129. /**
  6130. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6131. * @param localAxis The local direction that is used to compute the world direction
  6132. * @param mesh The mesh that this bone is attached to
  6133. * @param result The vector3 that the world direction will be copied to
  6134. */
  6135. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6136. /**
  6137. * Get the euler rotation of the bone in local or world space
  6138. * @param space The space that the rotation should be in
  6139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6140. * @returns The euler rotation
  6141. */
  6142. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6143. /**
  6144. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6145. * @param space The space that the rotation should be in
  6146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6147. * @param result The vector3 that the rotation should be copied to
  6148. */
  6149. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6150. /**
  6151. * Get the quaternion rotation of the bone in either local or world space
  6152. * @param space The space that the rotation should be in
  6153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6154. * @returns The quaternion rotation
  6155. */
  6156. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6157. /**
  6158. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6159. * @param space The space that the rotation should be in
  6160. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6161. * @param result The quaternion that the rotation should be copied to
  6162. */
  6163. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6164. /**
  6165. * Get the rotation matrix of the bone in local or world space
  6166. * @param space The space that the rotation should be in
  6167. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6168. * @returns The rotation matrix
  6169. */
  6170. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6171. /**
  6172. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6173. * @param space The space that the rotation should be in
  6174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6175. * @param result The quaternion that the rotation should be copied to
  6176. */
  6177. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6178. /**
  6179. * Get the world position of a point that is in the local space of the bone
  6180. * @param position The local position
  6181. * @param mesh The mesh that this bone is attached to
  6182. * @returns The world position
  6183. */
  6184. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6185. /**
  6186. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6187. * @param position The local position
  6188. * @param mesh The mesh that this bone is attached to
  6189. * @param result The vector3 that the world position should be copied to
  6190. */
  6191. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6192. /**
  6193. * Get the local position of a point that is in world space
  6194. * @param position The world position
  6195. * @param mesh The mesh that this bone is attached to
  6196. * @returns The local position
  6197. */
  6198. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6199. /**
  6200. * Get the local position of a point that is in world space and copy it to the result param
  6201. * @param position The world position
  6202. * @param mesh The mesh that this bone is attached to
  6203. * @param result The vector3 that the local position should be copied to
  6204. */
  6205. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6206. }
  6207. }
  6208. declare module BABYLON {
  6209. /**
  6210. * Class used to apply inverse kinematics to bones
  6211. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6212. */
  6213. class BoneIKController {
  6214. private static _tmpVecs;
  6215. private static _tmpQuat;
  6216. private static _tmpMats;
  6217. /**
  6218. * Gets or sets the target mesh
  6219. */
  6220. targetMesh: AbstractMesh;
  6221. /** Gets or sets the mesh used as pole */
  6222. poleTargetMesh: AbstractMesh;
  6223. /**
  6224. * Gets or sets the bone used as pole
  6225. */
  6226. poleTargetBone: Nullable<Bone>;
  6227. /**
  6228. * Gets or sets the target position
  6229. */
  6230. targetPosition: Vector3;
  6231. /**
  6232. * Gets or sets the pole target position
  6233. */
  6234. poleTargetPosition: Vector3;
  6235. /**
  6236. * Gets or sets the pole target local offset
  6237. */
  6238. poleTargetLocalOffset: Vector3;
  6239. /**
  6240. * Gets or sets the pole angle
  6241. */
  6242. poleAngle: number;
  6243. /**
  6244. * Gets or sets the mesh associated with the controller
  6245. */
  6246. mesh: AbstractMesh;
  6247. /**
  6248. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6249. */
  6250. slerpAmount: number;
  6251. private _bone1Quat;
  6252. private _bone1Mat;
  6253. private _bone2Ang;
  6254. private _bone1;
  6255. private _bone2;
  6256. private _bone1Length;
  6257. private _bone2Length;
  6258. private _maxAngle;
  6259. private _maxReach;
  6260. private _rightHandedSystem;
  6261. private _bendAxis;
  6262. private _slerping;
  6263. private _adjustRoll;
  6264. /**
  6265. * Gets or sets maximum allowed angle
  6266. */
  6267. maxAngle: number;
  6268. /**
  6269. * Creates a new BoneIKController
  6270. * @param mesh defines the mesh to control
  6271. * @param bone defines the bone to control
  6272. * @param options defines options to set up the controller
  6273. */
  6274. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6275. targetMesh?: AbstractMesh;
  6276. poleTargetMesh?: AbstractMesh;
  6277. poleTargetBone?: Bone;
  6278. poleTargetLocalOffset?: Vector3;
  6279. poleAngle?: number;
  6280. bendAxis?: Vector3;
  6281. maxAngle?: number;
  6282. slerpAmount?: number;
  6283. });
  6284. private _setMaxAngle;
  6285. /**
  6286. * Force the controller to update the bones
  6287. */
  6288. update(): void;
  6289. }
  6290. }
  6291. declare module BABYLON {
  6292. /**
  6293. * Class used to make a bone look toward a point in space
  6294. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6295. */
  6296. class BoneLookController {
  6297. private static _tmpVecs;
  6298. private static _tmpQuat;
  6299. private static _tmpMats;
  6300. /**
  6301. * The target Vector3 that the bone will look at
  6302. */
  6303. target: Vector3;
  6304. /**
  6305. * The mesh that the bone is attached to
  6306. */
  6307. mesh: AbstractMesh;
  6308. /**
  6309. * The bone that will be looking to the target
  6310. */
  6311. bone: Bone;
  6312. /**
  6313. * The up axis of the coordinate system that is used when the bone is rotated
  6314. */
  6315. upAxis: Vector3;
  6316. /**
  6317. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6318. */
  6319. upAxisSpace: Space;
  6320. /**
  6321. * Used to make an adjustment to the yaw of the bone
  6322. */
  6323. adjustYaw: number;
  6324. /**
  6325. * Used to make an adjustment to the pitch of the bone
  6326. */
  6327. adjustPitch: number;
  6328. /**
  6329. * Used to make an adjustment to the roll of the bone
  6330. */
  6331. adjustRoll: number;
  6332. /**
  6333. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6334. */
  6335. slerpAmount: number;
  6336. private _minYaw;
  6337. private _maxYaw;
  6338. private _minPitch;
  6339. private _maxPitch;
  6340. private _minYawSin;
  6341. private _minYawCos;
  6342. private _maxYawSin;
  6343. private _maxYawCos;
  6344. private _midYawConstraint;
  6345. private _minPitchTan;
  6346. private _maxPitchTan;
  6347. private _boneQuat;
  6348. private _slerping;
  6349. private _transformYawPitch;
  6350. private _transformYawPitchInv;
  6351. private _firstFrameSkipped;
  6352. private _yawRange;
  6353. private _fowardAxis;
  6354. /**
  6355. * Gets or sets the minimum yaw angle that the bone can look to
  6356. */
  6357. minYaw: number;
  6358. /**
  6359. * Gets or sets the maximum yaw angle that the bone can look to
  6360. */
  6361. maxYaw: number;
  6362. /**
  6363. * Gets or sets the minimum pitch angle that the bone can look to
  6364. */
  6365. minPitch: number;
  6366. /**
  6367. * Gets or sets the maximum pitch angle that the bone can look to
  6368. */
  6369. maxPitch: number;
  6370. /**
  6371. * Create a BoneLookController
  6372. * @param mesh the mesh that the bone belongs to
  6373. * @param bone the bone that will be looking to the target
  6374. * @param target the target Vector3 to look at
  6375. * @param settings optional settings:
  6376. * * maxYaw: the maximum angle the bone will yaw to
  6377. * * minYaw: the minimum angle the bone will yaw to
  6378. * * maxPitch: the maximum angle the bone will pitch to
  6379. * * minPitch: the minimum angle the bone will yaw to
  6380. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6381. * * upAxis: the up axis of the coordinate system
  6382. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6383. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6384. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6385. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6386. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6387. * * adjustRoll: used to make an adjustment to the roll of the bone
  6388. **/
  6389. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6390. maxYaw?: number;
  6391. minYaw?: number;
  6392. maxPitch?: number;
  6393. minPitch?: number;
  6394. slerpAmount?: number;
  6395. upAxis?: Vector3;
  6396. upAxisSpace?: Space;
  6397. yawAxis?: Vector3;
  6398. pitchAxis?: Vector3;
  6399. adjustYaw?: number;
  6400. adjustPitch?: number;
  6401. adjustRoll?: number;
  6402. });
  6403. /**
  6404. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6405. */
  6406. update(): void;
  6407. private _getAngleDiff;
  6408. private _getAngleBetween;
  6409. private _isAngleBetween;
  6410. }
  6411. }
  6412. declare module BABYLON {
  6413. /**
  6414. * Class used to handle skinning animations
  6415. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6416. */
  6417. class Skeleton implements IAnimatable {
  6418. /** defines the skeleton name */
  6419. name: string;
  6420. /** defines the skeleton Id */
  6421. id: string;
  6422. /**
  6423. * Gets the list of child bones
  6424. */
  6425. bones: Bone[];
  6426. /**
  6427. * Gets an estimate of the dimension of the skeleton at rest
  6428. */
  6429. dimensionsAtRest: Vector3;
  6430. /**
  6431. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6432. */
  6433. needInitialSkinMatrix: boolean;
  6434. /**
  6435. * Gets the list of animations attached to this skeleton
  6436. */
  6437. animations: Array<Animation>;
  6438. private _scene;
  6439. private _isDirty;
  6440. private _transformMatrices;
  6441. private _meshesWithPoseMatrix;
  6442. private _animatables;
  6443. private _identity;
  6444. private _synchronizedWithMesh;
  6445. private _ranges;
  6446. private _lastAbsoluteTransformsUpdateId;
  6447. /**
  6448. * Specifies if the skeleton should be serialized
  6449. */
  6450. doNotSerialize: boolean;
  6451. private _animationPropertiesOverride;
  6452. /**
  6453. * Gets or sets the animation properties override
  6454. */
  6455. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6456. /**
  6457. * An observable triggered before computing the skeleton's matrices
  6458. */
  6459. onBeforeComputeObservable: Observable<Skeleton>;
  6460. /**
  6461. * Creates a new skeleton
  6462. * @param name defines the skeleton name
  6463. * @param id defines the skeleton Id
  6464. * @param scene defines the hosting scene
  6465. */
  6466. constructor(
  6467. /** defines the skeleton name */
  6468. name: string,
  6469. /** defines the skeleton Id */
  6470. id: string, scene: Scene);
  6471. /**
  6472. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6473. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6474. * @returns a Float32Array containing matrices data
  6475. */
  6476. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6477. /**
  6478. * Gets the current hosting scene
  6479. * @returns a scene object
  6480. */
  6481. getScene(): Scene;
  6482. /**
  6483. * Gets a string representing the current skeleton data
  6484. * @param fullDetails defines a boolean indicating if we want a verbose version
  6485. * @returns a string representing the current skeleton data
  6486. */
  6487. toString(fullDetails?: boolean): string;
  6488. /**
  6489. * Get bone's index searching by name
  6490. * @param name defines bone's name to search for
  6491. * @return the indice of the bone. Returns -1 if not found
  6492. */
  6493. getBoneIndexByName(name: string): number;
  6494. /**
  6495. * Creater a new animation range
  6496. * @param name defines the name of the range
  6497. * @param from defines the start key
  6498. * @param to defines the end key
  6499. */
  6500. createAnimationRange(name: string, from: number, to: number): void;
  6501. /**
  6502. * Delete a specific animation range
  6503. * @param name defines the name of the range
  6504. * @param deleteFrames defines if frames must be removed as well
  6505. */
  6506. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6507. /**
  6508. * Gets a specific animation range
  6509. * @param name defines the name of the range to look for
  6510. * @returns the requested animation range or null if not found
  6511. */
  6512. getAnimationRange(name: string): Nullable<AnimationRange>;
  6513. /**
  6514. * Gets the list of all animation ranges defined on this skeleton
  6515. * @returns an array
  6516. */
  6517. getAnimationRanges(): Nullable<AnimationRange>[];
  6518. /**
  6519. * Copy animation range from a source skeleton.
  6520. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6521. * @param source defines the source skeleton
  6522. * @param name defines the name of the range to copy
  6523. * @param rescaleAsRequired defines if rescaling must be applied if required
  6524. * @returns true if operation was successful
  6525. */
  6526. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6527. /**
  6528. * Forces the skeleton to go to rest pose
  6529. */
  6530. returnToRest(): void;
  6531. private _getHighestAnimationFrame;
  6532. /**
  6533. * Begin a specific animation range
  6534. * @param name defines the name of the range to start
  6535. * @param loop defines if looping must be turned on (false by default)
  6536. * @param speedRatio defines the speed ratio to apply (1 by default)
  6537. * @param onAnimationEnd defines a callback which will be called when animation will end
  6538. * @returns a new animatable
  6539. */
  6540. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6541. /** @hidden */
  6542. _markAsDirty(): void;
  6543. /** @hidden */
  6544. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6545. /** @hidden */
  6546. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6547. /** @hidden */
  6548. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6549. /**
  6550. * Build all resources required to render a skeleton
  6551. */
  6552. prepare(): void;
  6553. /**
  6554. * Gets the list of animatables currently running for this skeleton
  6555. * @returns an array of animatables
  6556. */
  6557. getAnimatables(): IAnimatable[];
  6558. /**
  6559. * Clone the current skeleton
  6560. * @param name defines the name of the new skeleton
  6561. * @param id defines the id of the enw skeleton
  6562. * @returns the new skeleton
  6563. */
  6564. clone(name: string, id: string): Skeleton;
  6565. /**
  6566. * Enable animation blending for this skeleton
  6567. * @param blendingSpeed defines the blending speed to apply
  6568. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6569. */
  6570. enableBlending(blendingSpeed?: number): void;
  6571. /**
  6572. * Releases all resources associated with the current skeleton
  6573. */
  6574. dispose(): void;
  6575. /**
  6576. * Serialize the skeleton in a JSON object
  6577. * @returns a JSON object
  6578. */
  6579. serialize(): any;
  6580. /**
  6581. * Creates a new skeleton from serialized data
  6582. * @param parsedSkeleton defines the serialized data
  6583. * @param scene defines the hosting scene
  6584. * @returns a new skeleton
  6585. */
  6586. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6587. /**
  6588. * Compute all node absolute transforms
  6589. * @param forceUpdate defines if computation must be done even if cache is up to date
  6590. */
  6591. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6592. /**
  6593. * Gets the root pose matrix
  6594. * @returns a matrix
  6595. */
  6596. getPoseMatrix(): Nullable<Matrix>;
  6597. /**
  6598. * Sorts bones per internal index
  6599. */
  6600. sortBones(): void;
  6601. private _sortBones;
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /** @hidden */
  6606. class Collider {
  6607. /** Define if a collision was found */
  6608. collisionFound: boolean;
  6609. /**
  6610. * Define last intersection point in local space
  6611. */
  6612. intersectionPoint: Vector3;
  6613. /**
  6614. * Define last collided mesh
  6615. */
  6616. collidedMesh: Nullable<AbstractMesh>;
  6617. private _collisionPoint;
  6618. private _planeIntersectionPoint;
  6619. private _tempVector;
  6620. private _tempVector2;
  6621. private _tempVector3;
  6622. private _tempVector4;
  6623. private _edge;
  6624. private _baseToVertex;
  6625. private _destinationPoint;
  6626. private _slidePlaneNormal;
  6627. private _displacementVector;
  6628. /** @hidden */
  6629. _radius: Vector3;
  6630. /** @hidden */
  6631. _retry: number;
  6632. private _velocity;
  6633. private _basePoint;
  6634. private _epsilon;
  6635. /** @hidden */
  6636. _velocityWorldLength: number;
  6637. /** @hidden */
  6638. _basePointWorld: Vector3;
  6639. private _velocityWorld;
  6640. private _normalizedVelocity;
  6641. /** @hidden */
  6642. _initialVelocity: Vector3;
  6643. /** @hidden */
  6644. _initialPosition: Vector3;
  6645. private _nearestDistance;
  6646. private _collisionMask;
  6647. collisionMask: number;
  6648. /**
  6649. * Gets the plane normal used to compute the sliding response (in local space)
  6650. */
  6651. readonly slidePlaneNormal: Vector3;
  6652. /** @hidden */
  6653. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6654. /** @hidden */
  6655. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6656. /** @hidden */
  6657. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6658. /** @hidden */
  6659. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6660. /** @hidden */
  6661. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6662. /** @hidden */
  6663. _getResponse(pos: Vector3, vel: Vector3): void;
  6664. }
  6665. }
  6666. declare module BABYLON {
  6667. /** @hidden */
  6668. var CollisionWorker: string;
  6669. /** @hidden */
  6670. interface ICollisionCoordinator {
  6671. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6672. init(scene: Scene): void;
  6673. destroy(): void;
  6674. onMeshAdded(mesh: AbstractMesh): void;
  6675. onMeshUpdated(mesh: AbstractMesh): void;
  6676. onMeshRemoved(mesh: AbstractMesh): void;
  6677. onGeometryAdded(geometry: Geometry): void;
  6678. onGeometryUpdated(geometry: Geometry): void;
  6679. onGeometryDeleted(geometry: Geometry): void;
  6680. }
  6681. /** @hidden */
  6682. interface SerializedMesh {
  6683. id: string;
  6684. name: string;
  6685. uniqueId: number;
  6686. geometryId: Nullable<string>;
  6687. sphereCenter: Array<number>;
  6688. sphereRadius: number;
  6689. boxMinimum: Array<number>;
  6690. boxMaximum: Array<number>;
  6691. worldMatrixFromCache: any;
  6692. subMeshes: Array<SerializedSubMesh>;
  6693. checkCollisions: boolean;
  6694. }
  6695. /** @hidden */
  6696. interface SerializedSubMesh {
  6697. position: number;
  6698. verticesStart: number;
  6699. verticesCount: number;
  6700. indexStart: number;
  6701. indexCount: number;
  6702. hasMaterial: boolean;
  6703. sphereCenter: Array<number>;
  6704. sphereRadius: number;
  6705. boxMinimum: Array<number>;
  6706. boxMaximum: Array<number>;
  6707. }
  6708. /**
  6709. * Interface describing the value associated with a geometry.
  6710. * @hidden
  6711. */
  6712. interface SerializedGeometry {
  6713. /**
  6714. * Defines the unique ID of the geometry
  6715. */
  6716. id: string;
  6717. /**
  6718. * Defines the array containing the positions
  6719. */
  6720. positions: Float32Array;
  6721. /**
  6722. * Defines the array containing the indices
  6723. */
  6724. indices: Uint32Array;
  6725. /**
  6726. * Defines the array containing the normals
  6727. */
  6728. normals: Float32Array;
  6729. }
  6730. /** @hidden */
  6731. interface BabylonMessage {
  6732. taskType: WorkerTaskType;
  6733. payload: InitPayload | CollidePayload | UpdatePayload;
  6734. }
  6735. /** @hidden */
  6736. interface SerializedColliderToWorker {
  6737. position: Array<number>;
  6738. velocity: Array<number>;
  6739. radius: Array<number>;
  6740. }
  6741. /** Defines supported task for worker process */
  6742. enum WorkerTaskType {
  6743. /** Initialization */
  6744. INIT = 0,
  6745. /** Update of geometry */
  6746. UPDATE = 1,
  6747. /** Evaluate collision */
  6748. COLLIDE = 2
  6749. }
  6750. /** @hidden */
  6751. interface WorkerReply {
  6752. error: WorkerReplyType;
  6753. taskType: WorkerTaskType;
  6754. payload?: any;
  6755. }
  6756. /** @hidden */
  6757. interface CollisionReplyPayload {
  6758. newPosition: Array<number>;
  6759. collisionId: number;
  6760. collidedMeshUniqueId: number;
  6761. }
  6762. /** @hidden */
  6763. interface InitPayload {
  6764. }
  6765. /** @hidden */
  6766. interface CollidePayload {
  6767. collisionId: number;
  6768. collider: SerializedColliderToWorker;
  6769. maximumRetry: number;
  6770. excludedMeshUniqueId: Nullable<number>;
  6771. }
  6772. /** @hidden */
  6773. interface UpdatePayload {
  6774. updatedMeshes: {
  6775. [n: number]: SerializedMesh;
  6776. };
  6777. updatedGeometries: {
  6778. [s: string]: SerializedGeometry;
  6779. };
  6780. removedMeshes: Array<number>;
  6781. removedGeometries: Array<string>;
  6782. }
  6783. /** Defines kind of replies returned by worker */
  6784. enum WorkerReplyType {
  6785. /** Success */
  6786. SUCCESS = 0,
  6787. /** Unkown error */
  6788. UNKNOWN_ERROR = 1
  6789. }
  6790. /** @hidden */
  6791. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6792. private _scene;
  6793. private _scaledPosition;
  6794. private _scaledVelocity;
  6795. private _collisionsCallbackArray;
  6796. private _init;
  6797. private _runningUpdated;
  6798. private _worker;
  6799. private _addUpdateMeshesList;
  6800. private _addUpdateGeometriesList;
  6801. private _toRemoveMeshesArray;
  6802. private _toRemoveGeometryArray;
  6803. constructor();
  6804. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6805. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6806. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6807. init(scene: Scene): void;
  6808. destroy(): void;
  6809. onMeshAdded(mesh: AbstractMesh): void;
  6810. onMeshUpdated: (transformNode: TransformNode) => void;
  6811. onMeshRemoved(mesh: AbstractMesh): void;
  6812. onGeometryAdded(geometry: Geometry): void;
  6813. onGeometryUpdated: (geometry: Geometry) => void;
  6814. onGeometryDeleted(geometry: Geometry): void;
  6815. private _afterRender;
  6816. private _onMessageFromWorker;
  6817. }
  6818. /** @hidden */
  6819. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6820. private _scene;
  6821. private _scaledPosition;
  6822. private _scaledVelocity;
  6823. private _finalPosition;
  6824. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6825. init(scene: Scene): void;
  6826. destroy(): void;
  6827. onMeshAdded(mesh: AbstractMesh): void;
  6828. onMeshUpdated(mesh: AbstractMesh): void;
  6829. onMeshRemoved(mesh: AbstractMesh): void;
  6830. onGeometryAdded(geometry: Geometry): void;
  6831. onGeometryUpdated(geometry: Geometry): void;
  6832. onGeometryDeleted(geometry: Geometry): void;
  6833. private _collideWithWorld;
  6834. }
  6835. }
  6836. declare function importScripts(...urls: string[]): void;
  6837. declare const safePostMessage: any;
  6838. declare module BABYLON {
  6839. /** @hidden */
  6840. var WorkerIncluded: boolean;
  6841. /** @hidden */
  6842. class CollisionCache {
  6843. private _meshes;
  6844. private _geometries;
  6845. getMeshes(): {
  6846. [n: number]: SerializedMesh;
  6847. };
  6848. getGeometries(): {
  6849. [s: number]: SerializedGeometry;
  6850. };
  6851. getMesh(id: any): SerializedMesh;
  6852. addMesh(mesh: SerializedMesh): void;
  6853. removeMesh(uniqueId: number): void;
  6854. getGeometry(id: string): SerializedGeometry;
  6855. addGeometry(geometry: SerializedGeometry): void;
  6856. removeGeometry(id: string): void;
  6857. }
  6858. /** @hidden */
  6859. class CollideWorker {
  6860. collider: Collider;
  6861. private _collisionCache;
  6862. private finalPosition;
  6863. private collisionsScalingMatrix;
  6864. private collisionTranformationMatrix;
  6865. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6866. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6867. private checkCollision;
  6868. private processCollisionsForSubMeshes;
  6869. private collideForSubMesh;
  6870. private checkSubmeshCollision;
  6871. }
  6872. /** @hidden */
  6873. interface ICollisionDetector {
  6874. onInit(payload: InitPayload): void;
  6875. onUpdate(payload: UpdatePayload): void;
  6876. onCollision(payload: CollidePayload): void;
  6877. }
  6878. /** @hidden */
  6879. class CollisionDetectorTransferable implements ICollisionDetector {
  6880. private _collisionCache;
  6881. onInit(payload: InitPayload): void;
  6882. onUpdate(payload: UpdatePayload): void;
  6883. onCollision(payload: CollidePayload): void;
  6884. }
  6885. }
  6886. declare module BABYLON {
  6887. /**
  6888. * @hidden
  6889. */
  6890. class IntersectionInfo {
  6891. bu: Nullable<number>;
  6892. bv: Nullable<number>;
  6893. distance: number;
  6894. faceId: number;
  6895. subMeshId: number;
  6896. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6897. }
  6898. /**
  6899. * Information about the result of picking within a scene
  6900. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  6901. */
  6902. class PickingInfo {
  6903. /**
  6904. * If the pick collided with an object
  6905. */
  6906. hit: boolean;
  6907. /**
  6908. * Distance away where the pick collided
  6909. */
  6910. distance: number;
  6911. /**
  6912. * The location of pick collision
  6913. */
  6914. pickedPoint: Nullable<Vector3>;
  6915. /**
  6916. * The mesh corresponding the the pick collision
  6917. */
  6918. pickedMesh: Nullable<AbstractMesh>;
  6919. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6920. bu: number;
  6921. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6922. bv: number;
  6923. /** The id of the face on the mesh that was picked */
  6924. faceId: number;
  6925. /** Id of the the submesh that was picked */
  6926. subMeshId: number;
  6927. /** If a sprite was picked, this will be the sprite the pick collided with */
  6928. pickedSprite: Nullable<Sprite>;
  6929. /**
  6930. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6931. */
  6932. originMesh: Nullable<AbstractMesh>;
  6933. /**
  6934. * The ray that was used to perform the picking.
  6935. */
  6936. ray: Nullable<Ray>;
  6937. /**
  6938. * Gets the normal correspodning to the face the pick collided with
  6939. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6940. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6941. * @returns The normal correspodning to the face the pick collided with
  6942. */
  6943. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6944. /**
  6945. * Gets the texture coordinates of where the pick occured
  6946. * @returns the vector containing the coordnates of the texture
  6947. */
  6948. getTextureCoordinates(): Nullable<Vector2>;
  6949. }
  6950. }
  6951. declare module BABYLON {
  6952. /**
  6953. * This represents an orbital type of camera.
  6954. *
  6955. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  6956. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  6957. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6958. */
  6959. class ArcRotateCamera extends TargetCamera {
  6960. /**
  6961. * Defines the rotation angle of the camera along the longitudinal axis.
  6962. */
  6963. alpha: number;
  6964. /**
  6965. * Defines the rotation angle of the camera along the latitudinal axis.
  6966. */
  6967. beta: number;
  6968. /**
  6969. * Defines the radius of the camera from it s target point.
  6970. */
  6971. radius: number;
  6972. protected _target: Vector3;
  6973. protected _targetHost: Nullable<AbstractMesh>;
  6974. /**
  6975. * Defines the target point of the camera.
  6976. * The camera looks towards it form the radius distance.
  6977. */
  6978. target: Vector3;
  6979. /**
  6980. * Current inertia value on the longitudinal axis.
  6981. * The bigger this number the longer it will take for the camera to stop.
  6982. */
  6983. inertialAlphaOffset: number;
  6984. /**
  6985. * Current inertia value on the latitudinal axis.
  6986. * The bigger this number the longer it will take for the camera to stop.
  6987. */
  6988. inertialBetaOffset: number;
  6989. /**
  6990. * Current inertia value on the radius axis.
  6991. * The bigger this number the longer it will take for the camera to stop.
  6992. */
  6993. inertialRadiusOffset: number;
  6994. /**
  6995. * Minimum allowed angle on the longitudinal axis.
  6996. * This can help limiting how the Camera is able to move in the scene.
  6997. */
  6998. lowerAlphaLimit: Nullable<number>;
  6999. /**
  7000. * Maximum allowed angle on the longitudinal axis.
  7001. * This can help limiting how the Camera is able to move in the scene.
  7002. */
  7003. upperAlphaLimit: Nullable<number>;
  7004. /**
  7005. * Minimum allowed angle on the latitudinal axis.
  7006. * This can help limiting how the Camera is able to move in the scene.
  7007. */
  7008. lowerBetaLimit: number;
  7009. /**
  7010. * Maximum allowed angle on the latitudinal axis.
  7011. * This can help limiting how the Camera is able to move in the scene.
  7012. */
  7013. upperBetaLimit: number;
  7014. /**
  7015. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7016. * This can help limiting how the Camera is able to move in the scene.
  7017. */
  7018. lowerRadiusLimit: Nullable<number>;
  7019. /**
  7020. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7021. * This can help limiting how the Camera is able to move in the scene.
  7022. */
  7023. upperRadiusLimit: Nullable<number>;
  7024. /**
  7025. * Defines the current inertia value used during panning of the camera along the X axis.
  7026. */
  7027. inertialPanningX: number;
  7028. /**
  7029. * Defines the current inertia value used during panning of the camera along the Y axis.
  7030. */
  7031. inertialPanningY: number;
  7032. /**
  7033. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7034. * Basically if your fingers moves away from more than this distance you will be considered
  7035. * in pinch mode.
  7036. */
  7037. pinchToPanMaxDistance: number;
  7038. /**
  7039. * Defines the maximum distance the camera can pan.
  7040. * This could help keeping the cammera always in your scene.
  7041. */
  7042. panningDistanceLimit: Nullable<number>;
  7043. /**
  7044. * Defines the target of the camera before paning.
  7045. */
  7046. panningOriginTarget: Vector3;
  7047. /**
  7048. * Defines the value of the inertia used during panning.
  7049. * 0 would mean stop inertia and one would mean no decelleration at all.
  7050. */
  7051. panningInertia: number;
  7052. /**
  7053. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7054. */
  7055. angularSensibilityX: number;
  7056. /**
  7057. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7058. */
  7059. angularSensibilityY: number;
  7060. /**
  7061. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7062. */
  7063. pinchPrecision: number;
  7064. /**
  7065. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7066. * It will be used instead of pinchDeltaPrecision if different from 0.
  7067. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7068. */
  7069. pinchDeltaPercentage: number;
  7070. /**
  7071. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7072. */
  7073. panningSensibility: number;
  7074. /**
  7075. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7076. */
  7077. keysUp: number[];
  7078. /**
  7079. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7080. */
  7081. keysDown: number[];
  7082. /**
  7083. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7084. */
  7085. keysLeft: number[];
  7086. /**
  7087. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7088. */
  7089. keysRight: number[];
  7090. /**
  7091. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7092. */
  7093. wheelPrecision: number;
  7094. /**
  7095. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7096. * It will be used instead of pinchDeltaPrecision if different from 0.
  7097. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7098. */
  7099. wheelDeltaPercentage: number;
  7100. /**
  7101. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7102. */
  7103. zoomOnFactor: number;
  7104. /**
  7105. * Defines a screen offset for the camera position.
  7106. */
  7107. targetScreenOffset: Vector2;
  7108. /**
  7109. * Allows the camera to be completely reversed.
  7110. * If false the camera can not arrive upside down.
  7111. */
  7112. allowUpsideDown: boolean;
  7113. /**
  7114. * Define if double tap/click is used to restore the previously saved state of the camera.
  7115. */
  7116. useInputToRestoreState: boolean;
  7117. /** @hidden */
  7118. _viewMatrix: Matrix;
  7119. /** @hidden */
  7120. _useCtrlForPanning: boolean;
  7121. /** @hidden */
  7122. _panningMouseButton: number;
  7123. /**
  7124. * Defines the inpute associated to the camera.
  7125. */
  7126. inputs: ArcRotateCameraInputsManager;
  7127. /** @hidden */
  7128. _reset: () => void;
  7129. /**
  7130. * Defines the allowed panning axis.
  7131. */
  7132. panningAxis: Vector3;
  7133. protected _localDirection: Vector3;
  7134. protected _transformedDirection: Vector3;
  7135. private _bouncingBehavior;
  7136. /**
  7137. * Gets the bouncing behavior of the camera if it has been enabled.
  7138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7139. */
  7140. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7141. /**
  7142. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7144. */
  7145. useBouncingBehavior: boolean;
  7146. private _framingBehavior;
  7147. /**
  7148. * Gets the framing behavior of the camera if it has been enabled.
  7149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7150. */
  7151. readonly framingBehavior: Nullable<FramingBehavior>;
  7152. /**
  7153. * Defines if the framing behavior of the camera is enabled on the camera.
  7154. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7155. */
  7156. useFramingBehavior: boolean;
  7157. private _autoRotationBehavior;
  7158. /**
  7159. * Gets the auto rotation behavior of the camera if it has been enabled.
  7160. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7161. */
  7162. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7163. /**
  7164. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7165. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7166. */
  7167. useAutoRotationBehavior: boolean;
  7168. /**
  7169. * Observable triggered when the mesh target has been changed on the camera.
  7170. */
  7171. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7172. /**
  7173. * Event raised when the camera is colliding with a mesh.
  7174. */
  7175. onCollide: (collidedMesh: AbstractMesh) => void;
  7176. /**
  7177. * Defines whether the camera should check collision with the objects oh the scene.
  7178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7179. */
  7180. checkCollisions: boolean;
  7181. /**
  7182. * Defines the collision radius of the camera.
  7183. * This simulates a sphere around the camera.
  7184. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7185. */
  7186. collisionRadius: Vector3;
  7187. protected _collider: Collider;
  7188. protected _previousPosition: Vector3;
  7189. protected _collisionVelocity: Vector3;
  7190. protected _newPosition: Vector3;
  7191. protected _previousAlpha: number;
  7192. protected _previousBeta: number;
  7193. protected _previousRadius: number;
  7194. protected _collisionTriggered: boolean;
  7195. protected _targetBoundingCenter: Nullable<Vector3>;
  7196. private _computationVector;
  7197. /**
  7198. * Instantiates a new ArcRotateCamera in a given scene
  7199. * @param name Defines the name of the camera
  7200. * @param alpha Defines the camera rotation along the logitudinal axis
  7201. * @param beta Defines the camera rotation along the latitudinal axis
  7202. * @param radius Defines the camera distance from its target
  7203. * @param target Defines the camera target
  7204. * @param scene Defines the scene the camera belongs to
  7205. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7206. */
  7207. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7208. /** @hidden */
  7209. _initCache(): void;
  7210. /** @hidden */
  7211. _updateCache(ignoreParentClass?: boolean): void;
  7212. protected _getTargetPosition(): Vector3;
  7213. private _storedAlpha;
  7214. private _storedBeta;
  7215. private _storedRadius;
  7216. private _storedTarget;
  7217. /**
  7218. * Stores the current state of the camera (alpha, beta, radius and target)
  7219. * @returns the camera itself
  7220. */
  7221. storeState(): Camera;
  7222. /**
  7223. * @hidden
  7224. * Restored camera state. You must call storeState() first
  7225. */
  7226. _restoreStateValues(): boolean;
  7227. /** @hidden */
  7228. _isSynchronizedViewMatrix(): boolean;
  7229. /**
  7230. * Attached controls to the current camera.
  7231. * @param element Defines the element the controls should be listened from
  7232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7233. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7234. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7235. */
  7236. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7237. /**
  7238. * Detach the current controls from the camera.
  7239. * The camera will stop reacting to inputs.
  7240. * @param element Defines the element to stop listening the inputs from
  7241. */
  7242. detachControl(element: HTMLElement): void;
  7243. /** @hidden */
  7244. _checkInputs(): void;
  7245. protected _checkLimits(): void;
  7246. /**
  7247. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7248. */
  7249. rebuildAnglesAndRadius(): void;
  7250. /**
  7251. * Use a position to define the current camera related information like aplha, beta and radius
  7252. * @param position Defines the position to set the camera at
  7253. */
  7254. setPosition(position: Vector3): void;
  7255. /**
  7256. * Defines the target the camera should look at.
  7257. * This will automatically adapt alpha beta and radius to fit within the new target.
  7258. * @param target Defines the new target as a Vector or a mesh
  7259. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7260. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7261. */
  7262. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7263. /** @hidden */
  7264. _getViewMatrix(): Matrix;
  7265. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7266. /**
  7267. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7268. * @param meshes Defines the mesh to zoom on
  7269. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  7270. */
  7271. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7272. /**
  7273. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7274. * The target will be changed but the radius
  7275. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7276. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  7277. */
  7278. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7279. min: Vector3;
  7280. max: Vector3;
  7281. distance: number;
  7282. }, doNotUpdateMaxZ?: boolean): void;
  7283. /**
  7284. * @override
  7285. * Override Camera.createRigCamera
  7286. */
  7287. createRigCamera(name: string, cameraIndex: number): Camera;
  7288. /**
  7289. * @hidden
  7290. * @override
  7291. * Override Camera._updateRigCameras
  7292. */
  7293. _updateRigCameras(): void;
  7294. /**
  7295. * Destroy the camera and release the current resources hold by it.
  7296. */
  7297. dispose(): void;
  7298. /**
  7299. * Gets the current object class name.
  7300. * @return the class name
  7301. */
  7302. getClassName(): string;
  7303. }
  7304. }
  7305. declare module BABYLON {
  7306. /**
  7307. * Default Inputs manager for the ArcRotateCamera.
  7308. * It groups all the default supported inputs for ease of use.
  7309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7310. */
  7311. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7312. /**
  7313. * Instantiates a new ArcRotateCameraInputsManager.
  7314. * @param camera Defines the camera the inputs belong to
  7315. */
  7316. constructor(camera: ArcRotateCamera);
  7317. /**
  7318. * Add mouse wheel input support to the input manager.
  7319. * @returns the current input manager
  7320. */
  7321. addMouseWheel(): ArcRotateCameraInputsManager;
  7322. /**
  7323. * Add pointers input support to the input manager.
  7324. * @returns the current input manager
  7325. */
  7326. addPointers(): ArcRotateCameraInputsManager;
  7327. /**
  7328. * Add keyboard input support to the input manager.
  7329. * @returns the current input manager
  7330. */
  7331. addKeyboard(): ArcRotateCameraInputsManager;
  7332. /**
  7333. * Add orientation input support to the input manager.
  7334. * @returns the current input manager
  7335. */
  7336. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7337. }
  7338. }
  7339. declare module BABYLON {
  7340. /**
  7341. * This is the base class of all the camera used in the application.
  7342. * @see http://doc.babylonjs.com/features/cameras
  7343. */
  7344. class Camera extends Node {
  7345. /**
  7346. * This is the default projection mode used by the cameras.
  7347. * It helps recreating a feeling of perspective and better appreciate depth.
  7348. * This is the best way to simulate real life cameras.
  7349. */
  7350. static readonly PERSPECTIVE_CAMERA: number;
  7351. /**
  7352. * This helps creating camera with an orthographic mode.
  7353. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  7354. */
  7355. static readonly ORTHOGRAPHIC_CAMERA: number;
  7356. /**
  7357. * This is the default FOV mode for perspective cameras.
  7358. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7359. */
  7360. static readonly FOVMODE_VERTICAL_FIXED: number;
  7361. /**
  7362. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7363. */
  7364. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7365. /**
  7366. * This specifies ther is no need for a camera rig.
  7367. * Basically only one eye is rendered corresponding to the camera.
  7368. */
  7369. static readonly RIG_MODE_NONE: number;
  7370. /**
  7371. * Simulates a camera Rig with one blue eye and one red eye.
  7372. * This can be use with 3d blue and red glasses.
  7373. */
  7374. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7375. /**
  7376. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7377. */
  7378. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7379. /**
  7380. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7381. */
  7382. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7383. /**
  7384. * Defines that both eyes of the camera will be rendered over under each other.
  7385. */
  7386. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7387. /**
  7388. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7389. */
  7390. static readonly RIG_MODE_VR: number;
  7391. /**
  7392. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7393. */
  7394. static readonly RIG_MODE_WEBVR: number;
  7395. /**
  7396. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7397. */
  7398. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7399. /**
  7400. * @hidden
  7401. * Might be removed once multiview will be a thing
  7402. */
  7403. static UseAlternateWebVRRendering: boolean;
  7404. /**
  7405. * Define the input manager associated with the camera.
  7406. */
  7407. inputs: CameraInputsManager<Camera>;
  7408. /**
  7409. * Define the current local position of the camera in the scene
  7410. */
  7411. position: Vector3;
  7412. /**
  7413. * The vector the camera should consider as up.
  7414. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7415. */
  7416. upVector: Vector3;
  7417. /**
  7418. * Define the current limit on the left side for an orthographic camera
  7419. * In scene unit
  7420. */
  7421. orthoLeft: Nullable<number>;
  7422. /**
  7423. * Define the current limit on the right side for an orthographic camera
  7424. * In scene unit
  7425. */
  7426. orthoRight: Nullable<number>;
  7427. /**
  7428. * Define the current limit on the bottom side for an orthographic camera
  7429. * In scene unit
  7430. */
  7431. orthoBottom: Nullable<number>;
  7432. /**
  7433. * Define the current limit on the top side for an orthographic camera
  7434. * In scene unit
  7435. */
  7436. orthoTop: Nullable<number>;
  7437. /**
  7438. * Field Of View is set in Radians. (default is 0.8)
  7439. */
  7440. fov: number;
  7441. /**
  7442. * Define the minimum distance the camera can see from.
  7443. * This is important to note that the depth buffer are not infinite and the closer it starts
  7444. * the more your scene might encounter depth fighting issue.
  7445. */
  7446. minZ: number;
  7447. /**
  7448. * Define the maximum distance the camera can see to.
  7449. * This is important to note that the depth buffer are not infinite and the further it end
  7450. * the more your scene might encounter depth fighting issue.
  7451. */
  7452. maxZ: number;
  7453. /**
  7454. * Define the default inertia of the camera.
  7455. * This helps giving a smooth feeling to the camera movement.
  7456. */
  7457. inertia: number;
  7458. /**
  7459. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7460. */
  7461. mode: number;
  7462. /**
  7463. * Define wether the camera is intermediate.
  7464. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7465. */
  7466. isIntermediate: boolean;
  7467. /**
  7468. * Define the viewport of the camera.
  7469. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7470. */
  7471. viewport: Viewport;
  7472. /**
  7473. * Restricts the camera to viewing objects with the same layerMask.
  7474. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7475. */
  7476. layerMask: number;
  7477. /**
  7478. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7479. */
  7480. fovMode: number;
  7481. /**
  7482. * Rig mode of the camera.
  7483. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7484. * This is normally controlled byt the camera themselves as internal use.
  7485. */
  7486. cameraRigMode: number;
  7487. /**
  7488. * Defines the distance between both "eyes" in case of a RIG
  7489. */
  7490. interaxialDistance: number;
  7491. /**
  7492. * Defines if stereoscopic rendering is done side by side or over under.
  7493. */
  7494. isStereoscopicSideBySide: boolean;
  7495. /**
  7496. * Defines the list of custom render target the camera should render to.
  7497. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7498. * else in the scene.
  7499. */
  7500. customRenderTargets: RenderTargetTexture[];
  7501. /**
  7502. * Observable triggered when the camera view matrix has changed.
  7503. */
  7504. onViewMatrixChangedObservable: Observable<Camera>;
  7505. /**
  7506. * Observable triggered when the camera Projection matrix has changed.
  7507. */
  7508. onProjectionMatrixChangedObservable: Observable<Camera>;
  7509. /**
  7510. * Observable triggered when the inputs have been processed.
  7511. */
  7512. onAfterCheckInputsObservable: Observable<Camera>;
  7513. /**
  7514. * Observable triggered when reset has been called and applied to the camera.
  7515. */
  7516. onRestoreStateObservable: Observable<Camera>;
  7517. /** @hidden */
  7518. _cameraRigParams: any;
  7519. /** @hidden */
  7520. _rigCameras: Camera[];
  7521. /** @hidden */
  7522. _rigPostProcess: Nullable<PostProcess>;
  7523. protected _webvrViewMatrix: Matrix;
  7524. /** @hidden */
  7525. _skipRendering: boolean;
  7526. /** @hidden */
  7527. _alternateCamera: Camera;
  7528. /** @hidden */
  7529. _projectionMatrix: Matrix;
  7530. /** @hidden */
  7531. _postProcesses: Nullable<PostProcess>[];
  7532. /** @hidden */
  7533. _activeMeshes: SmartArray<AbstractMesh>;
  7534. protected _globalPosition: Vector3;
  7535. private _computedViewMatrix;
  7536. private _doNotComputeProjectionMatrix;
  7537. private _transformMatrix;
  7538. private _frustumPlanes;
  7539. private _refreshFrustumPlanes;
  7540. private _storedFov;
  7541. private _stateStored;
  7542. /**
  7543. * Instantiates a new camera object.
  7544. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7545. * @see http://doc.babylonjs.com/features/cameras
  7546. * @param name Defines the name of the camera in the scene
  7547. * @param position Defines the position of the camera
  7548. * @param scene Defines the scene the camera belongs too
  7549. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7550. */
  7551. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7552. /**
  7553. * Store current camera state (fov, position, etc..)
  7554. * @returns the camera
  7555. */
  7556. storeState(): Camera;
  7557. /**
  7558. * Restores the camera state values if it has been stored. You must call storeState() first
  7559. */
  7560. protected _restoreStateValues(): boolean;
  7561. /**
  7562. * Restored camera state. You must call storeState() first.
  7563. * @returns true if restored and false otherwise
  7564. */
  7565. restoreState(): boolean;
  7566. /**
  7567. * Gets the class name of the camera.
  7568. * @returns the class name
  7569. */
  7570. getClassName(): string;
  7571. /**
  7572. * Gets a string representation of the camera usefull for debug purpose.
  7573. * @param fullDetails Defines that a more verboe level of logging is required
  7574. * @returns the string representation
  7575. */
  7576. toString(fullDetails?: boolean): string;
  7577. /**
  7578. * Gets the current world space position of the camera.
  7579. */
  7580. readonly globalPosition: Vector3;
  7581. /**
  7582. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7583. * @returns the active meshe list
  7584. */
  7585. getActiveMeshes(): SmartArray<AbstractMesh>;
  7586. /**
  7587. * Check wether a mesh is part of the current active mesh list of the camera
  7588. * @param mesh Defines the mesh to check
  7589. * @returns true if active, false otherwise
  7590. */
  7591. isActiveMesh(mesh: Mesh): boolean;
  7592. /**
  7593. * Is this camera ready to be used/rendered
  7594. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7595. * @return true if the camera is ready
  7596. */
  7597. isReady(completeCheck?: boolean): boolean;
  7598. /** @hidden */
  7599. _initCache(): void;
  7600. /** @hidden */
  7601. _updateCache(ignoreParentClass?: boolean): void;
  7602. /** @hidden */
  7603. _isSynchronized(): boolean;
  7604. /** @hidden */
  7605. _isSynchronizedViewMatrix(): boolean;
  7606. /** @hidden */
  7607. _isSynchronizedProjectionMatrix(): boolean;
  7608. /**
  7609. * Attach the input controls to a specific dom element to get the input from.
  7610. * @param element Defines the element the controls should be listened from
  7611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7612. */
  7613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7614. /**
  7615. * Detach the current controls from the specified dom element.
  7616. * @param element Defines the element to stop listening the inputs from
  7617. */
  7618. detachControl(element: HTMLElement): void;
  7619. /**
  7620. * Update the camera state according to the different inputs gathered during the frame.
  7621. */
  7622. update(): void;
  7623. /** @hidden */
  7624. _checkInputs(): void;
  7625. /** @hidden */
  7626. readonly rigCameras: Camera[];
  7627. /**
  7628. * Gets the post process used by the rig cameras
  7629. */
  7630. readonly rigPostProcess: Nullable<PostProcess>;
  7631. /**
  7632. * Internal, gets the first post proces.
  7633. * @returns the first post process to be run on this camera.
  7634. */
  7635. _getFirstPostProcess(): Nullable<PostProcess>;
  7636. private _cascadePostProcessesToRigCams;
  7637. /**
  7638. * Attach a post process to the camera.
  7639. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7640. * @param postProcess The post process to attach to the camera
  7641. * @param insertAt The position of the post process in case several of them are in use in the scene
  7642. * @returns the position the post process has been inserted at
  7643. */
  7644. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7645. /**
  7646. * Detach a post process to the camera.
  7647. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7648. * @param postProcess The post process to detach from the camera
  7649. */
  7650. detachPostProcess(postProcess: PostProcess): void;
  7651. /**
  7652. * Gets the current world matrix of the camera
  7653. */
  7654. getWorldMatrix(): Matrix;
  7655. /** @hidden */
  7656. protected _getViewMatrix(): Matrix;
  7657. /**
  7658. * Gets the current view matrix of the camera.
  7659. * @param force forces the camera to recompute the matrix without looking at the cached state
  7660. * @returns the view matrix
  7661. */
  7662. getViewMatrix(force?: boolean): Matrix;
  7663. /**
  7664. * Freeze the projection matrix.
  7665. * It will prevent the cache check of the camera projection compute and can speed up perf
  7666. * if no parameter of the camera are meant to change
  7667. * @param projection Defines manually a projection if necessary
  7668. */
  7669. freezeProjectionMatrix(projection?: Matrix): void;
  7670. /**
  7671. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7672. */
  7673. unfreezeProjectionMatrix(): void;
  7674. /**
  7675. * Gets the current projection matrix of the camera.
  7676. * @param force forces the camera to recompute the matrix without looking at the cached state
  7677. * @returns the projection matrix
  7678. */
  7679. getProjectionMatrix(force?: boolean): Matrix;
  7680. /**
  7681. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7682. * @returns a Matrix
  7683. */
  7684. getTransformationMatrix(): Matrix;
  7685. private _updateFrustumPlanes;
  7686. /**
  7687. * Checks if a cullable object (mesh...) is in the camera frustum
  7688. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7689. * @param target The object to check
  7690. * @returns true if the object is in frustum otherwise false
  7691. */
  7692. isInFrustum(target: ICullable): boolean;
  7693. /**
  7694. * Checks if a cullable object (mesh...) is in the camera frustum
  7695. * Unlike isInFrustum this cheks the full bounding box
  7696. * @param target The object to check
  7697. * @returns true if the object is in frustum otherwise false
  7698. */
  7699. isCompletelyInFrustum(target: ICullable): boolean;
  7700. /**
  7701. * Gets a ray in the forward direction from the camera.
  7702. * @param length Defines the length of the ray to create
  7703. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7704. * @param origin Defines the start point of the ray which defaults to the camera position
  7705. * @returns the forward ray
  7706. */
  7707. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7708. /**
  7709. * Releases resources associated with this node.
  7710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7712. */
  7713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7714. /**
  7715. * Gets the left camera of a rig setup in case of Rigged Camera
  7716. */
  7717. readonly leftCamera: Nullable<FreeCamera>;
  7718. /**
  7719. * Gets the right camera of a rig setup in case of Rigged Camera
  7720. */
  7721. readonly rightCamera: Nullable<FreeCamera>;
  7722. /**
  7723. * Gets the left camera target of a rig setup in case of Rigged Camera
  7724. * @returns the target position
  7725. */
  7726. getLeftTarget(): Nullable<Vector3>;
  7727. /**
  7728. * Gets the right camera target of a rig setup in case of Rigged Camera
  7729. * @returns the target position
  7730. */
  7731. getRightTarget(): Nullable<Vector3>;
  7732. /**
  7733. * @hidden
  7734. */
  7735. setCameraRigMode(mode: number, rigParams: any): void;
  7736. private _getVRProjectionMatrix;
  7737. protected _updateCameraRotationMatrix(): void;
  7738. protected _updateWebVRCameraRotationMatrix(): void;
  7739. /**
  7740. * This function MUST be overwritten by the different WebVR cameras available.
  7741. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7742. */
  7743. protected _getWebVRProjectionMatrix(): Matrix;
  7744. /**
  7745. * This function MUST be overwritten by the different WebVR cameras available.
  7746. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7747. */
  7748. protected _getWebVRViewMatrix(): Matrix;
  7749. /** @hidden */
  7750. setCameraRigParameter(name: string, value: any): void;
  7751. /**
  7752. * needs to be overridden by children so sub has required properties to be copied
  7753. * @hidden
  7754. */
  7755. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7756. /**
  7757. * May need to be overridden by children
  7758. * @hidden
  7759. */
  7760. _updateRigCameras(): void;
  7761. /** @hidden */
  7762. _setupInputs(): void;
  7763. /**
  7764. * Serialiaze the camera setup to a json represention
  7765. * @returns the JSON representation
  7766. */
  7767. serialize(): any;
  7768. /**
  7769. * Clones the current camera.
  7770. * @param name The cloned camera name
  7771. * @returns the cloned camera
  7772. */
  7773. clone(name: string): Camera;
  7774. /**
  7775. * Gets the direction of the camera relative to a given local axis.
  7776. * @param localAxis Defines the reference axis to provide a relative direction.
  7777. * @return the direction
  7778. */
  7779. getDirection(localAxis: Vector3): Vector3;
  7780. /**
  7781. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7782. * @param localAxis Defines the reference axis to provide a relative direction.
  7783. * @param result Defines the vector to store the result in
  7784. */
  7785. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7786. /**
  7787. * Gets a camera constructor for a given camera type
  7788. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7789. * @param name The name of the camera the result will be able to instantiate
  7790. * @param scene The scene the result will construct the camera in
  7791. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7792. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7793. * @returns a factory method to construc the camera
  7794. */
  7795. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7796. /**
  7797. * Compute the world matrix of the camera.
  7798. * @returns the camera workd matrix
  7799. */
  7800. computeWorldMatrix(): Matrix;
  7801. /**
  7802. * Parse a JSON and creates the camera from the parsed information
  7803. * @param parsedCamera The JSON to parse
  7804. * @param scene The scene to instantiate the camera in
  7805. * @returns the newly constructed camera
  7806. */
  7807. static Parse(parsedCamera: any, scene: Scene): Camera;
  7808. }
  7809. }
  7810. declare module BABYLON {
  7811. /**
  7812. * @ignore
  7813. * This is a list of all the different input types that are available in the application.
  7814. * Fo instance: ArcRotateCameraGamepadInput...
  7815. */
  7816. var CameraInputTypes: {};
  7817. /**
  7818. * This is the contract to implement in order to create a new input class.
  7819. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7820. */
  7821. interface ICameraInput<TCamera extends Camera> {
  7822. /**
  7823. * Defines the camera the input is attached to.
  7824. */
  7825. camera: Nullable<TCamera>;
  7826. /**
  7827. * Gets the class name of the current intput.
  7828. * @returns the class name
  7829. */
  7830. getClassName(): string;
  7831. /**
  7832. * Get the friendly name associated with the input class.
  7833. * @returns the input friendly name
  7834. */
  7835. getSimpleName(): string;
  7836. /**
  7837. * Attach the input controls to a specific dom element to get the input from.
  7838. * @param element Defines the element the controls should be listened from
  7839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7840. */
  7841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7842. /**
  7843. * Detach the current controls from the specified dom element.
  7844. * @param element Defines the element to stop listening the inputs from
  7845. */
  7846. detachControl(element: Nullable<HTMLElement>): void;
  7847. /**
  7848. * Update the current camera state depending on the inputs that have been used this frame.
  7849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7850. */
  7851. checkInputs?: () => void;
  7852. }
  7853. /**
  7854. * Represents a map of input types to input instance or input index to input instance.
  7855. */
  7856. interface CameraInputsMap<TCamera extends Camera> {
  7857. /**
  7858. * Accessor to the input by input type.
  7859. */
  7860. [name: string]: ICameraInput<TCamera>;
  7861. /**
  7862. * Accessor to the input by input index.
  7863. */
  7864. [idx: number]: ICameraInput<TCamera>;
  7865. }
  7866. /**
  7867. * This represents the input manager used within a camera.
  7868. * It helps dealing with all the different kind of input attached to a camera.
  7869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7870. */
  7871. class CameraInputsManager<TCamera extends Camera> {
  7872. /**
  7873. * Defines the list of inputs attahed to the camera.
  7874. */
  7875. attached: CameraInputsMap<TCamera>;
  7876. /**
  7877. * Defines the dom element the camera is collecting inputs from.
  7878. * This is null if the controls have not been attached.
  7879. */
  7880. attachedElement: Nullable<HTMLElement>;
  7881. /**
  7882. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7883. */
  7884. noPreventDefault: boolean;
  7885. /**
  7886. * Defined the camera the input manager belongs to.
  7887. */
  7888. camera: TCamera;
  7889. /**
  7890. * Update the current camera state depending on the inputs that have been used this frame.
  7891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7892. */
  7893. checkInputs: () => void;
  7894. /**
  7895. * Instantiate a new Camera Input Manager.
  7896. * @param camera Defines the camera the input manager blongs to
  7897. */
  7898. constructor(camera: TCamera);
  7899. /**
  7900. * Add an input method to a camera
  7901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7902. * @param input camera input method
  7903. */
  7904. add(input: ICameraInput<TCamera>): void;
  7905. /**
  7906. * Remove a specific input method from a camera
  7907. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7908. * @param inputToRemove camera input method
  7909. */
  7910. remove(inputToRemove: ICameraInput<TCamera>): void;
  7911. /**
  7912. * Remove a specific input type from a camera
  7913. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7914. * @param inputType the type of the input to remove
  7915. */
  7916. removeByType(inputType: string): void;
  7917. private _addCheckInputs;
  7918. /**
  7919. * Attach the input controls to the currently attached dom element to listen the events from.
  7920. * @param input Defines the input to attach
  7921. */
  7922. attachInput(input: ICameraInput<TCamera>): void;
  7923. /**
  7924. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7925. * @param element Defines the dom element to collect the events from
  7926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7927. */
  7928. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7929. /**
  7930. * Detach the current manager inputs controls from a specific dom element.
  7931. * @param element Defines the dom element to collect the events from
  7932. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7933. */
  7934. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7935. /**
  7936. * Rebuild the dynamic inputCheck function from the current list of
  7937. * defined inputs in the manager.
  7938. */
  7939. rebuildInputCheck(): void;
  7940. /**
  7941. * Remove all attached input methods from a camera
  7942. */
  7943. clear(): void;
  7944. /**
  7945. * Serialize the current input manager attached to a camera.
  7946. * This ensures than once parsed,
  7947. * the input associated to the camera will be identical to the current ones
  7948. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7949. */
  7950. serialize(serializedCamera: any): void;
  7951. /**
  7952. * Parses an input manager serialized JSON to restore the previous list of inputs
  7953. * and states associated to a camera.
  7954. * @param parsedCamera Defines the JSON to parse
  7955. */
  7956. parse(parsedCamera: any): void;
  7957. }
  7958. }
  7959. declare module BABYLON {
  7960. /**
  7961. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7962. * being tilted forward or back and left or right.
  7963. */
  7964. class DeviceOrientationCamera extends FreeCamera {
  7965. private _initialQuaternion;
  7966. private _quaternionCache;
  7967. /**
  7968. * Creates a new device orientation camera
  7969. * @param name The name of the camera
  7970. * @param position The start position camera
  7971. * @param scene The scene the camera belongs to
  7972. */
  7973. constructor(name: string, position: Vector3, scene: Scene);
  7974. /**
  7975. * Gets the current instance class name ("DeviceOrientationCamera").
  7976. * This helps avoiding instanceof at run time.
  7977. * @returns the class name
  7978. */
  7979. getClassName(): string;
  7980. /**
  7981. * @hidden
  7982. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7983. */
  7984. _checkInputs(): void;
  7985. /**
  7986. * Reset the camera to its default orientation on the specified axis only.
  7987. * @param axis The axis to reset
  7988. */
  7989. resetToCurrentRotation(axis?: Axis): void;
  7990. }
  7991. }
  7992. declare module BABYLON {
  7993. /**
  7994. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7995. * an arc rotate version arcFollowCamera are available.
  7996. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7997. */
  7998. class FollowCamera extends TargetCamera {
  7999. /**
  8000. * Distance the follow camera should follow an object at
  8001. */
  8002. radius: number;
  8003. /**
  8004. * Define a rotation offset between the camera and the object it follows
  8005. */
  8006. rotationOffset: number;
  8007. /**
  8008. * Define a height offset between the camera and the object it follows.
  8009. * It can help following an object from the top (like a car chaing a plane)
  8010. */
  8011. heightOffset: number;
  8012. /**
  8013. * Define how fast the camera can accelerate to follow it s target.
  8014. */
  8015. cameraAcceleration: number;
  8016. /**
  8017. * Define the speed limit of the camera following an object.
  8018. */
  8019. maxCameraSpeed: number;
  8020. /**
  8021. * Define the target of the camera.
  8022. */
  8023. lockedTarget: Nullable<AbstractMesh>;
  8024. /**
  8025. * Instantiates the follow camera.
  8026. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8027. * @param name Define the name of the camera in the scene
  8028. * @param position Define the position of the camera
  8029. * @param scene Define the scene the camera belong to
  8030. * @param lockedTarget Define the target of the camera
  8031. */
  8032. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8033. private _follow;
  8034. /** @hidden */
  8035. _checkInputs(): void;
  8036. /**
  8037. * Gets the camera class name.
  8038. * @returns the class name
  8039. */
  8040. getClassName(): string;
  8041. }
  8042. /**
  8043. * Arc Rotate version of the follow camera.
  8044. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8045. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8046. */
  8047. class ArcFollowCamera extends TargetCamera {
  8048. /** The longitudinal angle of the camera */
  8049. alpha: number;
  8050. /** The latitudinal angle of the camera */
  8051. beta: number;
  8052. /** The radius of the camera from its target */
  8053. radius: number;
  8054. /** Define the camera target (the messh it should follow) */
  8055. target: Nullable<AbstractMesh>;
  8056. private _cartesianCoordinates;
  8057. /**
  8058. * Instantiates a new ArcFollowCamera
  8059. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8060. * @param name Define the name of the camera
  8061. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8062. * @param beta Define the rotation angle of the camera around the elevation axis
  8063. * @param radius Define the radius of the camera from its target point
  8064. * @param target Define the target of the camera
  8065. * @param scene Define the scene the camera belongs to
  8066. */
  8067. constructor(name: string,
  8068. /** The longitudinal angle of the camera */
  8069. alpha: number,
  8070. /** The latitudinal angle of the camera */
  8071. beta: number,
  8072. /** The radius of the camera from its target */
  8073. radius: number,
  8074. /** Define the camera target (the messh it should follow) */
  8075. target: Nullable<AbstractMesh>, scene: Scene);
  8076. private _follow;
  8077. /** @hidden */
  8078. _checkInputs(): void;
  8079. /**
  8080. * Returns the class name of the object.
  8081. * It is mostly used internally for serialization purposes.
  8082. */
  8083. getClassName(): string;
  8084. }
  8085. }
  8086. declare module BABYLON {
  8087. /**
  8088. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8089. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8090. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8091. */
  8092. class FreeCamera extends TargetCamera {
  8093. /**
  8094. * Define the collision ellipsoid of the camera.
  8095. * This is helpful to simulate a camera body like the player body around the camera
  8096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8097. */
  8098. ellipsoid: Vector3;
  8099. /**
  8100. * Define an offset for the position of the ellipsoid around the camera.
  8101. * This can be helpful to determine the center of the body near the gravity center of the body
  8102. * instead of its head.
  8103. */
  8104. ellipsoidOffset: Vector3;
  8105. /**
  8106. * Enable or disable collisions of the camera with the rest of the scene objects.
  8107. */
  8108. checkCollisions: boolean;
  8109. /**
  8110. * Enable or disable gravity on the camera.
  8111. */
  8112. applyGravity: boolean;
  8113. /**
  8114. * Define the input manager associated to the camera.
  8115. */
  8116. inputs: FreeCameraInputsManager;
  8117. /**
  8118. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8119. * Higher values reduce sensitivity.
  8120. */
  8121. /**
  8122. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8123. * Higher values reduce sensitivity.
  8124. */
  8125. angularSensibility: number;
  8126. /**
  8127. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8128. */
  8129. keysUp: number[];
  8130. /**
  8131. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8132. */
  8133. keysDown: number[];
  8134. /**
  8135. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8136. */
  8137. keysLeft: number[];
  8138. /**
  8139. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8140. */
  8141. keysRight: number[];
  8142. /**
  8143. * Event raised when the camera collide with a mesh in the scene.
  8144. */
  8145. onCollide: (collidedMesh: AbstractMesh) => void;
  8146. private _collider;
  8147. private _needMoveForGravity;
  8148. private _oldPosition;
  8149. private _diffPosition;
  8150. private _newPosition;
  8151. /** @hidden */
  8152. _localDirection: Vector3;
  8153. /** @hidden */
  8154. _transformedDirection: Vector3;
  8155. /**
  8156. * Instantiates a Free Camera.
  8157. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8158. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8159. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8160. * @param name Define the name of the camera in the scene
  8161. * @param position Define the start position of the camera in the scene
  8162. * @param scene Define the scene the camera belongs to
  8163. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8164. */
  8165. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8166. /**
  8167. * Attached controls to the current camera.
  8168. * @param element Defines the element the controls should be listened from
  8169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8170. */
  8171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8172. /**
  8173. * Detach the current controls from the camera.
  8174. * The camera will stop reacting to inputs.
  8175. * @param element Defines the element to stop listening the inputs from
  8176. */
  8177. detachControl(element: HTMLElement): void;
  8178. private _collisionMask;
  8179. /**
  8180. * Define a collision mask to limit the list of object the camera can collide with
  8181. */
  8182. collisionMask: number;
  8183. /** @hidden */
  8184. _collideWithWorld(displacement: Vector3): void;
  8185. private _onCollisionPositionChange;
  8186. /** @hidden */
  8187. _checkInputs(): void;
  8188. /** @hidden */
  8189. _decideIfNeedsToMove(): boolean;
  8190. /** @hidden */
  8191. _updatePosition(): void;
  8192. /**
  8193. * Destroy the camera and release the current resources hold by it.
  8194. */
  8195. dispose(): void;
  8196. /**
  8197. * Gets the current object class name.
  8198. * @return the class name
  8199. */
  8200. getClassName(): string;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Default Inputs manager for the FreeCamera.
  8206. * It groups all the default supported inputs for ease of use.
  8207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8208. */
  8209. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8210. /**
  8211. * Instantiates a new FreeCameraInputsManager.
  8212. * @param camera Defines the camera the inputs belong to
  8213. */
  8214. constructor(camera: FreeCamera);
  8215. /**
  8216. * Add keyboard input support to the input manager.
  8217. * @returns the current input manager
  8218. */
  8219. addKeyboard(): FreeCameraInputsManager;
  8220. /**
  8221. * Add mouse input support to the input manager.
  8222. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8223. * @returns the current input manager
  8224. */
  8225. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8226. /**
  8227. * Add orientation input support to the input manager.
  8228. * @returns the current input manager
  8229. */
  8230. addDeviceOrientation(): FreeCameraInputsManager;
  8231. /**
  8232. * Add touch input support to the input manager.
  8233. * @returns the current input manager
  8234. */
  8235. addTouch(): FreeCameraInputsManager;
  8236. /**
  8237. * Add virtual joystick input support to the input manager.
  8238. * @returns the current input manager
  8239. */
  8240. addVirtualJoystick(): FreeCameraInputsManager;
  8241. }
  8242. }
  8243. declare module BABYLON {
  8244. /**
  8245. * This represents a FPS type of camera. This is only here for back compat purpose.
  8246. * Please use the UniversalCamera instead as both are identical.
  8247. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8248. */
  8249. class GamepadCamera extends UniversalCamera {
  8250. /**
  8251. * Instantiates a new Gamepad Camera
  8252. * This represents a FPS type of camera. This is only here for back compat purpose.
  8253. * Please use the UniversalCamera instead as both are identical.
  8254. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8255. * @param name Define the name of the camera in the scene
  8256. * @param position Define the start position of the camera in the scene
  8257. * @param scene Define the scene the camera belongs to
  8258. */
  8259. constructor(name: string, position: Vector3, scene: Scene);
  8260. /**
  8261. * Gets the current object class name.
  8262. * @return the class name
  8263. */
  8264. getClassName(): string;
  8265. }
  8266. }
  8267. declare module BABYLON {
  8268. /**
  8269. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8270. * This is the base of the follow, arc rotate cameras and Free camera
  8271. * @see http://doc.babylonjs.com/features/cameras
  8272. */
  8273. class TargetCamera extends Camera {
  8274. /**
  8275. * Define the current direction the camera is moving to
  8276. */
  8277. cameraDirection: Vector3;
  8278. /**
  8279. * Define the current rotation the camera is rotating to
  8280. */
  8281. cameraRotation: Vector2;
  8282. /**
  8283. * Define the current rotation of the camera
  8284. */
  8285. rotation: Vector3;
  8286. /**
  8287. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8288. */
  8289. rotationQuaternion: Quaternion;
  8290. /**
  8291. * Define the current speed of the camera
  8292. */
  8293. speed: number;
  8294. /**
  8295. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8296. * around all axis.
  8297. */
  8298. noRotationConstraint: boolean;
  8299. /**
  8300. * Define the current target of the camera as an object or a position.
  8301. */
  8302. lockedTarget: any;
  8303. /** @hidden */
  8304. _currentTarget: Vector3;
  8305. /** @hidden */
  8306. _viewMatrix: Matrix;
  8307. /** @hidden */
  8308. _camMatrix: Matrix;
  8309. /** @hidden */
  8310. _cameraTransformMatrix: Matrix;
  8311. /** @hidden */
  8312. _cameraRotationMatrix: Matrix;
  8313. private _rigCamTransformMatrix;
  8314. /** @hidden */
  8315. _referencePoint: Vector3;
  8316. /** @hidden */
  8317. _transformedReferencePoint: Vector3;
  8318. protected _globalCurrentTarget: Vector3;
  8319. protected _globalCurrentUpVector: Vector3;
  8320. /** @hidden */
  8321. _reset: () => void;
  8322. private _defaultUp;
  8323. /**
  8324. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8325. * This is the base of the follow, arc rotate cameras and Free camera
  8326. * @see http://doc.babylonjs.com/features/cameras
  8327. * @param name Defines the name of the camera in the scene
  8328. * @param position Defines the start position of the camera in the scene
  8329. * @param scene Defines the scene the camera belongs to
  8330. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8331. */
  8332. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8333. /**
  8334. * Gets the position in front of the camera at a given distance.
  8335. * @param distance The distance from the camera we want the position to be
  8336. * @returns the position
  8337. */
  8338. getFrontPosition(distance: number): Vector3;
  8339. /** @hidden */
  8340. _getLockedTargetPosition(): Nullable<Vector3>;
  8341. private _storedPosition;
  8342. private _storedRotation;
  8343. private _storedRotationQuaternion;
  8344. /**
  8345. * Store current camera state of the camera (fov, position, rotation, etc..)
  8346. * @returns the camera
  8347. */
  8348. storeState(): Camera;
  8349. /**
  8350. * Restored camera state. You must call storeState() first
  8351. * @returns whether it was successful or not
  8352. * @hidden
  8353. */
  8354. _restoreStateValues(): boolean;
  8355. /** @hidden */
  8356. _initCache(): void;
  8357. /** @hidden */
  8358. _updateCache(ignoreParentClass?: boolean): void;
  8359. /** @hidden */
  8360. _isSynchronizedViewMatrix(): boolean;
  8361. /** @hidden */
  8362. _computeLocalCameraSpeed(): number;
  8363. /** @hidden */
  8364. setTarget(target: Vector3): void;
  8365. /**
  8366. * Return the current target position of the camera. This value is expressed in local space.
  8367. * @returns the target position
  8368. */
  8369. getTarget(): Vector3;
  8370. /** @hidden */
  8371. _decideIfNeedsToMove(): boolean;
  8372. /** @hidden */
  8373. _updatePosition(): void;
  8374. /** @hidden */
  8375. _checkInputs(): void;
  8376. protected _updateCameraRotationMatrix(): void;
  8377. /**
  8378. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8379. * @returns the current camera
  8380. */
  8381. private _rotateUpVectorWithCameraRotationMatrix;
  8382. private _cachedRotationZ;
  8383. private _cachedQuaternionRotationZ;
  8384. /** @hidden */
  8385. _getViewMatrix(): Matrix;
  8386. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8387. /**
  8388. * @hidden
  8389. */
  8390. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8391. /**
  8392. * @hidden
  8393. */
  8394. _updateRigCameras(): void;
  8395. private _getRigCamPosition;
  8396. /**
  8397. * Gets the current object class name.
  8398. * @return the class name
  8399. */
  8400. getClassName(): string;
  8401. }
  8402. }
  8403. declare module BABYLON {
  8404. /**
  8405. * This represents a FPS type of camera controlled by touch.
  8406. * This is like a universal camera minus the Gamepad controls.
  8407. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8408. */
  8409. class TouchCamera extends FreeCamera {
  8410. /**
  8411. * Defines the touch sensibility for rotation.
  8412. * The higher the faster.
  8413. */
  8414. touchAngularSensibility: number;
  8415. /**
  8416. * Defines the touch sensibility for move.
  8417. * The higher the faster.
  8418. */
  8419. touchMoveSensibility: number;
  8420. /**
  8421. * Instantiates a new touch camera.
  8422. * This represents a FPS type of camera controlled by touch.
  8423. * This is like a universal camera minus the Gamepad controls.
  8424. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8425. * @param name Define the name of the camera in the scene
  8426. * @param position Define the start position of the camera in the scene
  8427. * @param scene Define the scene the camera belongs to
  8428. */
  8429. constructor(name: string, position: Vector3, scene: Scene);
  8430. /**
  8431. * Gets the current object class name.
  8432. * @return the class name
  8433. */
  8434. getClassName(): string;
  8435. /** @hidden */
  8436. _setupInputs(): void;
  8437. }
  8438. }
  8439. declare module BABYLON {
  8440. /**
  8441. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  8442. * which still works and will still be found in many Playgrounds.
  8443. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8444. */
  8445. class UniversalCamera extends TouchCamera {
  8446. /**
  8447. * Defines the gamepad rotation sensiblity.
  8448. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8449. */
  8450. gamepadAngularSensibility: number;
  8451. /**
  8452. * Defines the gamepad move sensiblity.
  8453. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8454. */
  8455. gamepadMoveSensibility: number;
  8456. /**
  8457. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  8458. * which still works and will still be found in many Playgrounds.
  8459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8460. * @param name Define the name of the camera in the scene
  8461. * @param position Define the start position of the camera in the scene
  8462. * @param scene Define the scene the camera belongs to
  8463. */
  8464. constructor(name: string, position: Vector3, scene: Scene);
  8465. /**
  8466. * Gets the current object class name.
  8467. * @return the class name
  8468. */
  8469. getClassName(): string;
  8470. }
  8471. }
  8472. declare module BABYLON {
  8473. /**
  8474. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8475. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8476. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8477. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8478. */
  8479. class VirtualJoysticksCamera extends FreeCamera {
  8480. /**
  8481. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8482. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8483. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8484. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8485. * @param name Define the name of the camera in the scene
  8486. * @param position Define the start position of the camera in the scene
  8487. * @param scene Define the scene the camera belongs to
  8488. */
  8489. constructor(name: string, position: Vector3, scene: Scene);
  8490. /**
  8491. * Gets the current object class name.
  8492. * @return the class name
  8493. */
  8494. getClassName(): string;
  8495. }
  8496. }
  8497. interface VRDisplay extends EventTarget {
  8498. /**
  8499. * Dictionary of capabilities describing the VRDisplay.
  8500. */
  8501. readonly capabilities: VRDisplayCapabilities;
  8502. /**
  8503. * z-depth defining the far plane of the eye view frustum
  8504. * enables mapping of values in the render target depth
  8505. * attachment to scene coordinates. Initially set to 10000.0.
  8506. */
  8507. depthFar: number;
  8508. /**
  8509. * z-depth defining the near plane of the eye view frustum
  8510. * enables mapping of values in the render target depth
  8511. * attachment to scene coordinates. Initially set to 0.01.
  8512. */
  8513. depthNear: number;
  8514. /**
  8515. * An identifier for this distinct VRDisplay. Used as an
  8516. * association point in the Gamepad API.
  8517. */
  8518. readonly displayId: number;
  8519. /**
  8520. * A display name, a user-readable name identifying it.
  8521. */
  8522. readonly displayName: string;
  8523. readonly isConnected: boolean;
  8524. readonly isPresenting: boolean;
  8525. /**
  8526. * If this VRDisplay supports room-scale experiences, the optional
  8527. * stage attribute contains details on the room-scale parameters.
  8528. */
  8529. readonly stageParameters: VRStageParameters | null;
  8530. /**
  8531. * Passing the value returned by `requestAnimationFrame` to
  8532. * `cancelAnimationFrame` will unregister the callback.
  8533. * @param handle Define the hanle of the request to cancel
  8534. */
  8535. cancelAnimationFrame(handle: number): void;
  8536. /**
  8537. * Stops presenting to the VRDisplay.
  8538. * @returns a promise to know when it stopped
  8539. */
  8540. exitPresent(): Promise<void>;
  8541. /**
  8542. * Return the current VREyeParameters for the given eye.
  8543. * @param whichEye Define the eye we want the parameter for
  8544. * @returns the eye parameters
  8545. */
  8546. getEyeParameters(whichEye: string): VREyeParameters;
  8547. /**
  8548. * Populates the passed VRFrameData with the information required to render
  8549. * the current frame.
  8550. * @param frameData Define the data structure to populate
  8551. * @returns true if ok otherwise false
  8552. */
  8553. getFrameData(frameData: VRFrameData): boolean;
  8554. /**
  8555. * Get the layers currently being presented.
  8556. * @returns the list of VR layers
  8557. */
  8558. getLayers(): VRLayer[];
  8559. /**
  8560. * Return a VRPose containing the future predicted pose of the VRDisplay
  8561. * when the current frame will be presented. The value returned will not
  8562. * change until JavaScript has returned control to the browser.
  8563. *
  8564. * The VRPose will contain the position, orientation, velocity,
  8565. * and acceleration of each of these properties.
  8566. * @returns the pose object
  8567. */
  8568. getPose(): VRPose;
  8569. /**
  8570. * Return the current instantaneous pose of the VRDisplay, with no
  8571. * prediction applied.
  8572. * @returns the current instantaneous pose
  8573. */
  8574. getImmediatePose(): VRPose;
  8575. /**
  8576. * The callback passed to `requestAnimationFrame` will be called
  8577. * any time a new frame should be rendered. When the VRDisplay is
  8578. * presenting the callback will be called at the native refresh
  8579. * rate of the HMD. When not presenting this function acts
  8580. * identically to how window.requestAnimationFrame acts. Content should
  8581. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8582. * asynchronously from other displays and at differing refresh rates.
  8583. * @param callback Define the eaction to run next frame
  8584. * @returns the request handle it
  8585. */
  8586. requestAnimationFrame(callback: FrameRequestCallback): number;
  8587. /**
  8588. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8589. * Repeat calls while already presenting will update the VRLayers being displayed.
  8590. * @param layers Define the list of layer to present
  8591. * @returns a promise to know when the request has been fulfilled
  8592. */
  8593. requestPresent(layers: VRLayer[]): Promise<void>;
  8594. /**
  8595. * Reset the pose for this display, treating its current position and
  8596. * orientation as the "origin/zero" values. VRPose.position,
  8597. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8598. * updated when calling resetPose(). This should be called in only
  8599. * sitting-space experiences.
  8600. */
  8601. resetPose(): void;
  8602. /**
  8603. * The VRLayer provided to the VRDisplay will be captured and presented
  8604. * in the HMD. Calling this function has the same effect on the source
  8605. * canvas as any other operation that uses its source image, and canvases
  8606. * created without preserveDrawingBuffer set to true will be cleared.
  8607. * @param pose Define the pose to submit
  8608. */
  8609. submitFrame(pose?: VRPose): void;
  8610. }
  8611. declare var VRDisplay: {
  8612. prototype: VRDisplay;
  8613. new (): VRDisplay;
  8614. };
  8615. interface VRLayer {
  8616. leftBounds?: number[] | Float32Array | null;
  8617. rightBounds?: number[] | Float32Array | null;
  8618. source?: HTMLCanvasElement | null;
  8619. }
  8620. interface VRDisplayCapabilities {
  8621. readonly canPresent: boolean;
  8622. readonly hasExternalDisplay: boolean;
  8623. readonly hasOrientation: boolean;
  8624. readonly hasPosition: boolean;
  8625. readonly maxLayers: number;
  8626. }
  8627. interface VREyeParameters {
  8628. /** @deprecated */
  8629. readonly fieldOfView: VRFieldOfView;
  8630. readonly offset: Float32Array;
  8631. readonly renderHeight: number;
  8632. readonly renderWidth: number;
  8633. }
  8634. interface VRFieldOfView {
  8635. readonly downDegrees: number;
  8636. readonly leftDegrees: number;
  8637. readonly rightDegrees: number;
  8638. readonly upDegrees: number;
  8639. }
  8640. interface VRFrameData {
  8641. readonly leftProjectionMatrix: Float32Array;
  8642. readonly leftViewMatrix: Float32Array;
  8643. readonly pose: VRPose;
  8644. readonly rightProjectionMatrix: Float32Array;
  8645. readonly rightViewMatrix: Float32Array;
  8646. readonly timestamp: number;
  8647. }
  8648. interface VRPose {
  8649. readonly angularAcceleration: Float32Array | null;
  8650. readonly angularVelocity: Float32Array | null;
  8651. readonly linearAcceleration: Float32Array | null;
  8652. readonly linearVelocity: Float32Array | null;
  8653. readonly orientation: Float32Array | null;
  8654. readonly position: Float32Array | null;
  8655. readonly timestamp: number;
  8656. }
  8657. interface VRStageParameters {
  8658. sittingToStandingTransform?: Float32Array;
  8659. sizeX?: number;
  8660. sizeY?: number;
  8661. }
  8662. interface Navigator {
  8663. getVRDisplays(): Promise<VRDisplay[]>;
  8664. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8665. }
  8666. interface Window {
  8667. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8668. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8669. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8670. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8671. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8672. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8673. }
  8674. interface Gamepad {
  8675. readonly displayId: number;
  8676. }
  8677. /**
  8678. * Module Debug contains the (visual) components to debug a scene correctly
  8679. */
  8680. declare module BABYLON.Debug {
  8681. /**
  8682. * The Axes viewer will show 3 axes in a specific point in space
  8683. */
  8684. class AxesViewer {
  8685. private _xline;
  8686. private _yline;
  8687. private _zline;
  8688. private _xmesh;
  8689. private _ymesh;
  8690. private _zmesh;
  8691. /**
  8692. * Gets the hosting scene
  8693. */
  8694. scene: Nullable<Scene>;
  8695. /**
  8696. * Gets or sets a number used to scale line length
  8697. */
  8698. scaleLines: number;
  8699. /**
  8700. * Creates a new AxesViewer
  8701. * @param scene defines the hosting scene
  8702. * @param scaleLines defines a number used to scale line length (1 by default)
  8703. */
  8704. constructor(scene: Scene, scaleLines?: number);
  8705. /**
  8706. * Force the viewer to update
  8707. * @param position defines the position of the viewer
  8708. * @param xaxis defines the x axis of the viewer
  8709. * @param yaxis defines the y axis of the viewer
  8710. * @param zaxis defines the z axis of the viewer
  8711. */
  8712. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  8713. /** Releases resources */
  8714. dispose(): void;
  8715. }
  8716. }
  8717. declare module BABYLON.Debug {
  8718. /**
  8719. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  8720. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  8721. */
  8722. class BoneAxesViewer extends AxesViewer {
  8723. /**
  8724. * Gets or sets the target mesh where to display the axes viewer
  8725. */
  8726. mesh: Nullable<Mesh>;
  8727. /**
  8728. * Gets or sets the target bone where to display the axes viewer
  8729. */
  8730. bone: Nullable<Bone>;
  8731. /** Gets current position */
  8732. pos: Vector3;
  8733. /** Gets direction of X axis */
  8734. xaxis: Vector3;
  8735. /** Gets direction of Y axis */
  8736. yaxis: Vector3;
  8737. /** Gets direction of Z axis */
  8738. zaxis: Vector3;
  8739. /**
  8740. * Creates a new BoneAxesViewer
  8741. * @param scene defines the hosting scene
  8742. * @param bone defines the target bone
  8743. * @param mesh defines the target mesh
  8744. * @param scaleLines defines a scaling factor for line length (1 by default)
  8745. */
  8746. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  8747. /**
  8748. * Force the viewer to update
  8749. */
  8750. update(): void;
  8751. /** Releases resources */
  8752. dispose(): void;
  8753. }
  8754. }
  8755. declare module BABYLON {
  8756. interface Scene {
  8757. /**
  8758. * @hidden
  8759. * Backing field
  8760. */
  8761. _debugLayer: DebugLayer;
  8762. /**
  8763. * Gets the debug layer (aka Inspector) associated with the scene
  8764. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8765. */
  8766. debugLayer: DebugLayer;
  8767. }
  8768. /**
  8769. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8770. * what is happening in your scene
  8771. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8772. */
  8773. class DebugLayer {
  8774. /**
  8775. * Define the url to get the inspector script from.
  8776. * By default it uses the babylonjs CDN.
  8777. * @ignoreNaming
  8778. */
  8779. static InspectorURL: string;
  8780. private _scene;
  8781. private _inspector;
  8782. private BJSINSPECTOR;
  8783. /**
  8784. * Observable triggered when a property is changed through the inspector.
  8785. */
  8786. onPropertyChangedObservable: Observable<{
  8787. object: any;
  8788. property: string;
  8789. value: any;
  8790. initialValue: any;
  8791. }>;
  8792. /**
  8793. * Instantiates a new debug layer.
  8794. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8795. * what is happening in your scene
  8796. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8797. * @param scene Defines the scene to inspect
  8798. */
  8799. constructor(scene: Scene);
  8800. /** Creates the inspector window. */
  8801. private _createInspector;
  8802. /**
  8803. * Get if the inspector is visible or not.
  8804. * @returns true if visible otherwise, false
  8805. */
  8806. isVisible(): boolean;
  8807. /**
  8808. * Hide the inspector and close its window.
  8809. */
  8810. hide(): void;
  8811. /**
  8812. *
  8813. * Launch the debugLayer.
  8814. *
  8815. * initialTab:
  8816. * | Value | Tab Name |
  8817. * | --- | --- |
  8818. * | 0 | Scene |
  8819. * | 1 | Console |
  8820. * | 2 | Stats |
  8821. * | 3 | Textures |
  8822. * | 4 | Mesh |
  8823. * | 5 | Light |
  8824. * | 6 | Material |
  8825. * | 7 | GLTF |
  8826. * | 8 | GUI |
  8827. * | 9 | Physics |
  8828. * | 10 | Camera |
  8829. * | 11 | Audio |
  8830. *
  8831. * @param config Define the configuration of the inspector
  8832. */
  8833. show(config?: {
  8834. popup?: boolean;
  8835. initialTab?: number | string;
  8836. parentElement?: HTMLElement;
  8837. newColors?: {
  8838. backgroundColor?: string;
  8839. backgroundColorLighter?: string;
  8840. backgroundColorLighter2?: string;
  8841. backgroundColorLighter3?: string;
  8842. color?: string;
  8843. colorTop?: string;
  8844. colorBot?: string;
  8845. };
  8846. }): void;
  8847. /**
  8848. * Gets the active tab
  8849. * @return the index of the active tab or -1 if the inspector is hidden
  8850. */
  8851. getActiveTab(): number;
  8852. }
  8853. }
  8854. declare module BABYLON.Debug {
  8855. /**
  8856. * Used to show the physics impostor around the specific mesh
  8857. */
  8858. class PhysicsViewer {
  8859. /** @hidden */
  8860. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  8861. /** @hidden */
  8862. protected _meshes: Array<Nullable<AbstractMesh>>;
  8863. /** @hidden */
  8864. protected _scene: Nullable<Scene>;
  8865. /** @hidden */
  8866. protected _numMeshes: number;
  8867. /** @hidden */
  8868. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  8869. private _renderFunction;
  8870. private _debugBoxMesh;
  8871. private _debugSphereMesh;
  8872. private _debugMaterial;
  8873. /**
  8874. * Creates a new PhysicsViewer
  8875. * @param scene defines the hosting scene
  8876. */
  8877. constructor(scene: Scene);
  8878. /** @hidden */
  8879. protected _updateDebugMeshes(): void;
  8880. /**
  8881. * Renders a specified physic impostor
  8882. * @param impostor defines the impostor to render
  8883. */
  8884. showImpostor(impostor: PhysicsImpostor): void;
  8885. /**
  8886. * Hides a specified physic impostor
  8887. * @param impostor defines the impostor to hide
  8888. */
  8889. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  8890. private _getDebugMaterial;
  8891. private _getDebugBoxMesh;
  8892. private _getDebugSphereMesh;
  8893. private _getDebugMesh;
  8894. /** Releases all resources */
  8895. dispose(): void;
  8896. }
  8897. }
  8898. declare module BABYLON {
  8899. /**
  8900. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8901. * in order to better appreciate the issue one might have.
  8902. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8903. */
  8904. class RayHelper {
  8905. /**
  8906. * Defines the ray we are currently tryin to visualize.
  8907. */
  8908. ray: Nullable<Ray>;
  8909. private _renderPoints;
  8910. private _renderLine;
  8911. private _renderFunction;
  8912. private _scene;
  8913. private _updateToMeshFunction;
  8914. private _attachedToMesh;
  8915. private _meshSpaceDirection;
  8916. private _meshSpaceOrigin;
  8917. /**
  8918. * Helper function to create a colored helper in a scene in one line.
  8919. * @param ray Defines the ray we are currently tryin to visualize
  8920. * @param scene Defines the scene the ray is used in
  8921. * @param color Defines the color we want to see the ray in
  8922. * @returns The newly created ray helper.
  8923. */
  8924. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  8925. /**
  8926. * Instantiate a new ray helper.
  8927. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8928. * in order to better appreciate the issue one might have.
  8929. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8930. * @param ray Defines the ray we are currently tryin to visualize
  8931. */
  8932. constructor(ray: Ray);
  8933. /**
  8934. * Shows the ray we are willing to debug.
  8935. * @param scene Defines the scene the ray needs to be rendered in
  8936. * @param color Defines the color the ray needs to be rendered in
  8937. */
  8938. show(scene: Scene, color?: Color3): void;
  8939. /**
  8940. * Hides the ray we are debugging.
  8941. */
  8942. hide(): void;
  8943. private _render;
  8944. /**
  8945. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  8946. * @param mesh Defines the mesh we want the helper attached to
  8947. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  8948. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  8949. * @param length Defines the length of the ray
  8950. */
  8951. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  8952. /**
  8953. * Detach the ray helper from the mesh it has previously been attached to.
  8954. */
  8955. detachFromMesh(): void;
  8956. private _updateToMesh;
  8957. /**
  8958. * Dispose the helper and release its associated resources.
  8959. */
  8960. dispose(): void;
  8961. }
  8962. }
  8963. declare module BABYLON.Debug {
  8964. /**
  8965. * Class used to render a debug view of a given skeleton
  8966. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  8967. */
  8968. class SkeletonViewer {
  8969. /** defines the skeleton to render */
  8970. skeleton: Skeleton;
  8971. /** defines the mesh attached to the skeleton */
  8972. mesh: AbstractMesh;
  8973. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8974. autoUpdateBonesMatrices: boolean;
  8975. /** defines the rendering group id to use with the viewer */
  8976. renderingGroupId: number;
  8977. /** Gets or sets the color used to render the skeleton */
  8978. color: Color3;
  8979. private _scene;
  8980. private _debugLines;
  8981. private _debugMesh;
  8982. private _isEnabled;
  8983. private _renderFunction;
  8984. /**
  8985. * Creates a new SkeletonViewer
  8986. * @param skeleton defines the skeleton to render
  8987. * @param mesh defines the mesh attached to the skeleton
  8988. * @param scene defines the hosting scene
  8989. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  8990. * @param renderingGroupId defines the rendering group id to use with the viewer
  8991. */
  8992. constructor(
  8993. /** defines the skeleton to render */
  8994. skeleton: Skeleton,
  8995. /** defines the mesh attached to the skeleton */
  8996. mesh: AbstractMesh, scene: Scene,
  8997. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8998. autoUpdateBonesMatrices?: boolean,
  8999. /** defines the rendering group id to use with the viewer */
  9000. renderingGroupId?: number);
  9001. /** Gets or sets a boolean indicating if the viewer is enabled */
  9002. isEnabled: boolean;
  9003. private _getBonePosition;
  9004. private _getLinesForBonesWithLength;
  9005. private _getLinesForBonesNoLength;
  9006. /** Update the viewer to sync with current skeleton state */
  9007. update(): void;
  9008. /** Release associated resources */
  9009. dispose(): void;
  9010. }
  9011. }
  9012. declare module BABYLON {
  9013. /**
  9014. * Interface for attribute information associated with buffer instanciation
  9015. */
  9016. class InstancingAttributeInfo {
  9017. /**
  9018. * Index/offset of the attribute in the vertex shader
  9019. */
  9020. index: number;
  9021. /**
  9022. * size of the attribute, 1, 2, 3 or 4
  9023. */
  9024. attributeSize: number;
  9025. /**
  9026. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9027. * default is FLOAT
  9028. */
  9029. attribyteType: number;
  9030. /**
  9031. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9032. */
  9033. normalized: boolean;
  9034. /**
  9035. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9036. */
  9037. offset: number;
  9038. /**
  9039. * Name of the GLSL attribute, for debugging purpose only
  9040. */
  9041. attributeName: string;
  9042. }
  9043. /**
  9044. * Define options used to create a render target texture
  9045. */
  9046. class RenderTargetCreationOptions {
  9047. /**
  9048. * Specifies is mipmaps must be generated
  9049. */
  9050. generateMipMaps?: boolean;
  9051. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9052. generateDepthBuffer?: boolean;
  9053. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9054. generateStencilBuffer?: boolean;
  9055. /** Defines texture type (int by default) */
  9056. type?: number;
  9057. /** Defines sampling mode (trilinear by default) */
  9058. samplingMode?: number;
  9059. /** Defines format (RGBA by default) */
  9060. format?: number;
  9061. }
  9062. /**
  9063. * Define options used to create a depth texture
  9064. */
  9065. class DepthTextureCreationOptions {
  9066. /** Specifies whether or not a stencil should be allocated in the texture */
  9067. generateStencil?: boolean;
  9068. /** Specifies whether or not bilinear filtering is enable on the texture */
  9069. bilinearFiltering?: boolean;
  9070. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9071. comparisonFunction?: number;
  9072. /** Specifies if the created texture is a cube texture */
  9073. isCube?: boolean;
  9074. }
  9075. /**
  9076. * Class used to describe the capabilities of the engine relatively to the current browser
  9077. */
  9078. class EngineCapabilities {
  9079. /** Maximum textures units per fragment shader */
  9080. maxTexturesImageUnits: number;
  9081. /** Maximum texture units per vertex shader */
  9082. maxVertexTextureImageUnits: number;
  9083. /** Maximum textures units in the entire pipeline */
  9084. maxCombinedTexturesImageUnits: number;
  9085. /** Maximum texture size */
  9086. maxTextureSize: number;
  9087. /** Maximum cube texture size */
  9088. maxCubemapTextureSize: number;
  9089. /** Maximum render texture size */
  9090. maxRenderTextureSize: number;
  9091. /** Maximum number of vertex attributes */
  9092. maxVertexAttribs: number;
  9093. /** Maximum number of varyings */
  9094. maxVaryingVectors: number;
  9095. /** Maximum number of uniforms per vertex shader */
  9096. maxVertexUniformVectors: number;
  9097. /** Maximum number of uniforms per fragment shader */
  9098. maxFragmentUniformVectors: number;
  9099. /** Defines if standard derivates (dx/dy) are supported */
  9100. standardDerivatives: boolean;
  9101. /** Defines if s3tc texture compression is supported */
  9102. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9103. /** Defines if pvrtc texture compression is supported */
  9104. pvrtc: any;
  9105. /** Defines if etc1 texture compression is supported */
  9106. etc1: any;
  9107. /** Defines if etc2 texture compression is supported */
  9108. etc2: any;
  9109. /** Defines if astc texture compression is supported */
  9110. astc: any;
  9111. /** Defines if float textures are supported */
  9112. textureFloat: boolean;
  9113. /** Defines if vertex array objects are supported */
  9114. vertexArrayObject: boolean;
  9115. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9116. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9117. /** Gets the maximum level of anisotropy supported */
  9118. maxAnisotropy: number;
  9119. /** Defines if instancing is supported */
  9120. instancedArrays: boolean;
  9121. /** Defines if 32 bits indices are supported */
  9122. uintIndices: boolean;
  9123. /** Defines if high precision shaders are supported */
  9124. highPrecisionShaderSupported: boolean;
  9125. /** Defines if depth reading in the fragment shader is supported */
  9126. fragmentDepthSupported: boolean;
  9127. /** Defines if float texture linear filtering is supported*/
  9128. textureFloatLinearFiltering: boolean;
  9129. /** Defines if rendering to float textures is supported */
  9130. textureFloatRender: boolean;
  9131. /** Defines if half float textures are supported*/
  9132. textureHalfFloat: boolean;
  9133. /** Defines if half float texture linear filtering is supported*/
  9134. textureHalfFloatLinearFiltering: boolean;
  9135. /** Defines if rendering to half float textures is supported */
  9136. textureHalfFloatRender: boolean;
  9137. /** Defines if textureLOD shader command is supported */
  9138. textureLOD: boolean;
  9139. /** Defines if draw buffers extension is supported */
  9140. drawBuffersExtension: boolean;
  9141. /** Defines if depth textures are supported */
  9142. depthTextureExtension: boolean;
  9143. /** Defines if float color buffer are supported */
  9144. colorBufferFloat: boolean;
  9145. /** Gets disjoint timer query extension (null if not supported) */
  9146. timerQuery: EXT_disjoint_timer_query;
  9147. /** Defines if timestamp can be used with timer query */
  9148. canUseTimestampForTimerQuery: boolean;
  9149. }
  9150. /** Interface defining initialization parameters for Engine class */
  9151. interface EngineOptions extends WebGLContextAttributes {
  9152. /**
  9153. * Defines if the engine should no exceed a specified device ratio
  9154. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9155. */
  9156. limitDeviceRatio?: number;
  9157. /**
  9158. * Defines if webvr should be enabled automatically
  9159. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9160. */
  9161. autoEnableWebVR?: boolean;
  9162. /**
  9163. * Defines if webgl2 should be turned off even if supported
  9164. * @see http://doc.babylonjs.com/features/webgl2
  9165. */
  9166. disableWebGL2Support?: boolean;
  9167. /**
  9168. * Defines if webaudio should be initialized as well
  9169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9170. */
  9171. audioEngine?: boolean;
  9172. /**
  9173. * Defines if animations should run using a deterministic lock step
  9174. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9175. */
  9176. deterministicLockstep?: boolean;
  9177. /** Defines the maximum steps to use with deterministic lock step mode */
  9178. lockstepMaxSteps?: number;
  9179. /**
  9180. * Defines that engine should ignore context lost events
  9181. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9182. */
  9183. doNotHandleContextLost?: boolean;
  9184. }
  9185. /**
  9186. * Defines the interface used by display changed events
  9187. */
  9188. interface IDisplayChangedEventArgs {
  9189. /** Gets the vrDisplay object (if any) */
  9190. vrDisplay: Nullable<any>;
  9191. /** Gets a boolean indicating if webVR is supported */
  9192. vrSupported: boolean;
  9193. }
  9194. /**
  9195. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9196. */
  9197. class Engine {
  9198. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9199. static ExceptionList: ({
  9200. key: string;
  9201. capture: string;
  9202. captureConstraint: number;
  9203. targets: string[];
  9204. } | {
  9205. key: string;
  9206. capture: null;
  9207. captureConstraint: null;
  9208. targets: string[];
  9209. })[];
  9210. /** Gets the list of created engines */
  9211. static Instances: Engine[];
  9212. /**
  9213. * Gets the latest created engine
  9214. */
  9215. static readonly LastCreatedEngine: Nullable<Engine>;
  9216. /**
  9217. * Gets the latest created scene
  9218. */
  9219. static readonly LastCreatedScene: Nullable<Scene>;
  9220. /**
  9221. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9222. * @param flag defines which part of the materials must be marked as dirty
  9223. * @param predicate defines a predicate used to filter which materials should be affected
  9224. */
  9225. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9226. /**
  9227. * Hidden
  9228. */
  9229. static _TextureLoaders: IInternalTextureLoader[];
  9230. /** Defines that alpha blending is disabled */
  9231. static readonly ALPHA_DISABLE: number;
  9232. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9233. static readonly ALPHA_ADD: number;
  9234. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9235. static readonly ALPHA_COMBINE: number;
  9236. /** Defines that alpha blending to DEST - SRC * DEST */
  9237. static readonly ALPHA_SUBTRACT: number;
  9238. /** Defines that alpha blending to SRC * DEST */
  9239. static readonly ALPHA_MULTIPLY: number;
  9240. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9241. static readonly ALPHA_MAXIMIZED: number;
  9242. /** Defines that alpha blending to SRC + DEST */
  9243. static readonly ALPHA_ONEONE: number;
  9244. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9245. static readonly ALPHA_PREMULTIPLIED: number;
  9246. /**
  9247. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9248. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9249. */
  9250. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9251. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  9252. static readonly ALPHA_INTERPOLATE: number;
  9253. /**
  9254. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  9255. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  9256. */
  9257. static readonly ALPHA_SCREENMODE: number;
  9258. /** Defines that the ressource is not delayed*/
  9259. static readonly DELAYLOADSTATE_NONE: number;
  9260. /** Defines that the ressource was successfully delay loaded */
  9261. static readonly DELAYLOADSTATE_LOADED: number;
  9262. /** Defines that the ressource is currently delay loading */
  9263. static readonly DELAYLOADSTATE_LOADING: number;
  9264. /** Defines that the ressource is delayed and has not started loading */
  9265. static readonly DELAYLOADSTATE_NOTLOADED: number;
  9266. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  9267. static readonly NEVER: number;
  9268. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  9269. static readonly ALWAYS: number;
  9270. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  9271. static readonly LESS: number;
  9272. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  9273. static readonly EQUAL: number;
  9274. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  9275. static readonly LEQUAL: number;
  9276. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  9277. static readonly GREATER: number;
  9278. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  9279. static readonly GEQUAL: number;
  9280. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  9281. static readonly NOTEQUAL: number;
  9282. /** Passed to stencilOperation to specify that stencil value must be kept */
  9283. static readonly KEEP: number;
  9284. /** Passed to stencilOperation to specify that stencil value must be replaced */
  9285. static readonly REPLACE: number;
  9286. /** Passed to stencilOperation to specify that stencil value must be incremented */
  9287. static readonly INCR: number;
  9288. /** Passed to stencilOperation to specify that stencil value must be decremented */
  9289. static readonly DECR: number;
  9290. /** Passed to stencilOperation to specify that stencil value must be inverted */
  9291. static readonly INVERT: number;
  9292. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  9293. static readonly INCR_WRAP: number;
  9294. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  9295. static readonly DECR_WRAP: number;
  9296. /** Texture is not repeating outside of 0..1 UVs */
  9297. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  9298. /** Texture is repeating outside of 0..1 UVs */
  9299. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  9300. /** Texture is repeating and mirrored */
  9301. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  9302. /** ALPHA */
  9303. static readonly TEXTUREFORMAT_ALPHA: number;
  9304. /** LUMINANCE */
  9305. static readonly TEXTUREFORMAT_LUMINANCE: number;
  9306. /** LUMINANCE_ALPHA */
  9307. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  9308. /** RGB */
  9309. static readonly TEXTUREFORMAT_RGB: number;
  9310. /** RGBA */
  9311. static readonly TEXTUREFORMAT_RGBA: number;
  9312. /** RED */
  9313. static readonly TEXTUREFORMAT_RED: number;
  9314. /** RED (2nd reference) */
  9315. static readonly TEXTUREFORMAT_R: number;
  9316. /** RG */
  9317. static readonly TEXTUREFORMAT_RG: number;
  9318. /** RED_INTEGER */
  9319. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  9320. /** RED_INTEGER (2nd reference) */
  9321. static readonly TEXTUREFORMAT_R_INTEGER: number;
  9322. /** RG_INTEGER */
  9323. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  9324. /** RGB_INTEGER */
  9325. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  9326. /** RGBA_INTEGER */
  9327. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  9328. /** UNSIGNED_BYTE */
  9329. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  9330. /** UNSIGNED_BYTE (2nd reference) */
  9331. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  9332. /** FLOAT */
  9333. static readonly TEXTURETYPE_FLOAT: number;
  9334. /** HALF_FLOAT */
  9335. static readonly TEXTURETYPE_HALF_FLOAT: number;
  9336. /** BYTE */
  9337. static readonly TEXTURETYPE_BYTE: number;
  9338. /** SHORT */
  9339. static readonly TEXTURETYPE_SHORT: number;
  9340. /** UNSIGNED_SHORT */
  9341. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  9342. /** INT */
  9343. static readonly TEXTURETYPE_INT: number;
  9344. /** UNSIGNED_INT */
  9345. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  9346. /** UNSIGNED_SHORT_4_4_4_4 */
  9347. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  9348. /** UNSIGNED_SHORT_5_5_5_1 */
  9349. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  9350. /** UNSIGNED_SHORT_5_6_5 */
  9351. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  9352. /** UNSIGNED_INT_2_10_10_10_REV */
  9353. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  9354. /** UNSIGNED_INT_24_8 */
  9355. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  9356. /** UNSIGNED_INT_10F_11F_11F_REV */
  9357. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  9358. /** UNSIGNED_INT_5_9_9_9_REV */
  9359. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  9360. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  9361. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9362. /** nearest is mag = nearest and min = nearest and mip = linear */
  9363. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  9364. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9365. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  9366. /** Trilinear is mag = linear and min = linear and mip = linear */
  9367. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  9368. /** nearest is mag = nearest and min = nearest and mip = linear */
  9369. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  9370. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9371. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  9372. /** Trilinear is mag = linear and min = linear and mip = linear */
  9373. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  9374. /** mag = nearest and min = nearest and mip = nearest */
  9375. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  9376. /** mag = nearest and min = linear and mip = nearest */
  9377. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  9378. /** mag = nearest and min = linear and mip = linear */
  9379. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  9380. /** mag = nearest and min = linear and mip = none */
  9381. static readonly TEXTURE_NEAREST_LINEAR: number;
  9382. /** mag = nearest and min = nearest and mip = none */
  9383. static readonly TEXTURE_NEAREST_NEAREST: number;
  9384. /** mag = linear and min = nearest and mip = nearest */
  9385. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  9386. /** mag = linear and min = nearest and mip = linear */
  9387. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  9388. /** mag = linear and min = linear and mip = none */
  9389. static readonly TEXTURE_LINEAR_LINEAR: number;
  9390. /** mag = linear and min = nearest and mip = none */
  9391. static readonly TEXTURE_LINEAR_NEAREST: number;
  9392. /** Explicit coordinates mode */
  9393. static readonly TEXTURE_EXPLICIT_MODE: number;
  9394. /** Spherical coordinates mode */
  9395. static readonly TEXTURE_SPHERICAL_MODE: number;
  9396. /** Planar coordinates mode */
  9397. static readonly TEXTURE_PLANAR_MODE: number;
  9398. /** Cubic coordinates mode */
  9399. static readonly TEXTURE_CUBIC_MODE: number;
  9400. /** Projection coordinates mode */
  9401. static readonly TEXTURE_PROJECTION_MODE: number;
  9402. /** Skybox coordinates mode */
  9403. static readonly TEXTURE_SKYBOX_MODE: number;
  9404. /** Inverse Cubic coordinates mode */
  9405. static readonly TEXTURE_INVCUBIC_MODE: number;
  9406. /** Equirectangular coordinates mode */
  9407. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  9408. /** Equirectangular Fixed coordinates mode */
  9409. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  9410. /** Equirectangular Fixed Mirrored coordinates mode */
  9411. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  9412. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  9413. static readonly SCALEMODE_FLOOR: number;
  9414. /** Defines that texture rescaling will look for the nearest power of 2 size */
  9415. static readonly SCALEMODE_NEAREST: number;
  9416. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  9417. static readonly SCALEMODE_CEILING: number;
  9418. /**
  9419. * Returns the current version of the framework
  9420. */
  9421. static readonly Version: string;
  9422. /**
  9423. * Gets or sets the epsilon value used by collision engine
  9424. */
  9425. static CollisionsEpsilon: number;
  9426. /**
  9427. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  9428. */
  9429. static CodeRepository: string;
  9430. /**
  9431. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  9432. */
  9433. static ShadersRepository: string;
  9434. /**
  9435. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  9436. */
  9437. forcePOTTextures: boolean;
  9438. /**
  9439. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  9440. */
  9441. isFullscreen: boolean;
  9442. /**
  9443. * Gets a boolean indicating if the pointer is currently locked
  9444. */
  9445. isPointerLock: boolean;
  9446. /**
  9447. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  9448. */
  9449. cullBackFaces: boolean;
  9450. /**
  9451. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  9452. */
  9453. renderEvenInBackground: boolean;
  9454. /**
  9455. * Gets or sets a boolean indicating that cache can be kept between frames
  9456. */
  9457. preventCacheWipeBetweenFrames: boolean;
  9458. /**
  9459. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  9460. **/
  9461. enableOfflineSupport: boolean;
  9462. /**
  9463. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  9464. **/
  9465. disableManifestCheck: boolean;
  9466. /**
  9467. * Gets the list of created scenes
  9468. */
  9469. scenes: Scene[];
  9470. /**
  9471. * Gets the list of created postprocesses
  9472. */
  9473. postProcesses: PostProcess[];
  9474. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  9475. validateShaderPrograms: boolean;
  9476. /**
  9477. * Observable event triggered each time the rendering canvas is resized
  9478. */
  9479. onResizeObservable: Observable<Engine>;
  9480. /**
  9481. * Observable event triggered each time the canvas loses focus
  9482. */
  9483. onCanvasBlurObservable: Observable<Engine>;
  9484. /**
  9485. * Observable event triggered each time the canvas gains focus
  9486. */
  9487. onCanvasFocusObservable: Observable<Engine>;
  9488. /**
  9489. * Observable event triggered each time the canvas receives pointerout event
  9490. */
  9491. onCanvasPointerOutObservable: Observable<PointerEvent>;
  9492. /**
  9493. * Observable event triggered before each texture is initialized
  9494. */
  9495. onBeforeTextureInitObservable: Observable<Texture>;
  9496. private _vrDisplay;
  9497. private _vrSupported;
  9498. private _oldSize;
  9499. private _oldHardwareScaleFactor;
  9500. private _vrExclusivePointerMode;
  9501. private _webVRInitPromise;
  9502. /**
  9503. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  9504. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  9505. */
  9506. readonly isInVRExclusivePointerMode: boolean;
  9507. /**
  9508. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  9509. */
  9510. disableUniformBuffers: boolean;
  9511. /** @hidden */
  9512. _uniformBuffers: UniformBuffer[];
  9513. /**
  9514. * Gets a boolean indicating that the engine supports uniform buffers
  9515. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  9516. */
  9517. readonly supportsUniformBuffers: boolean;
  9518. /**
  9519. * Observable raised when the engine begins a new frame
  9520. */
  9521. onBeginFrameObservable: Observable<Engine>;
  9522. /**
  9523. * Observable raised when the engine ends the current frame
  9524. */
  9525. onEndFrameObservable: Observable<Engine>;
  9526. /**
  9527. * Observable raised when the engine is about to compile a shader
  9528. */
  9529. onBeforeShaderCompilationObservable: Observable<Engine>;
  9530. /**
  9531. * Observable raised when the engine has jsut compiled a shader
  9532. */
  9533. onAfterShaderCompilationObservable: Observable<Engine>;
  9534. /** @hidden */
  9535. _gl: WebGLRenderingContext;
  9536. private _renderingCanvas;
  9537. private _windowIsBackground;
  9538. private _webGLVersion;
  9539. /**
  9540. * Gets a boolean indicating that only power of 2 textures are supported
  9541. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  9542. */
  9543. readonly needPOTTextures: boolean;
  9544. /** @hidden */
  9545. _badOS: boolean;
  9546. /** @hidden */
  9547. _badDesktopOS: boolean;
  9548. /**
  9549. * Gets or sets a value indicating if we want to disable texture binding optmization.
  9550. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  9551. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  9552. */
  9553. disableTextureBindingOptimization: boolean;
  9554. /**
  9555. * Gets the audio engine
  9556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9557. * @ignorenaming
  9558. */
  9559. static audioEngine: IAudioEngine;
  9560. /**
  9561. * Default AudioEngine Factory responsible of creating the Audio Engine.
  9562. * By default, this will create a BabylonJS Audio Engine if the workload
  9563. * has been embedded.
  9564. */
  9565. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  9566. private _onFocus;
  9567. private _onBlur;
  9568. private _onCanvasPointerOut;
  9569. private _onCanvasBlur;
  9570. private _onCanvasFocus;
  9571. private _onFullscreenChange;
  9572. private _onPointerLockChange;
  9573. private _onVRDisplayPointerRestricted;
  9574. private _onVRDisplayPointerUnrestricted;
  9575. private _onVrDisplayConnect;
  9576. private _onVrDisplayDisconnect;
  9577. private _onVrDisplayPresentChange;
  9578. /**
  9579. * Observable signaled when VR display mode changes
  9580. */
  9581. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  9582. /**
  9583. * Observable signaled when VR request present is complete
  9584. */
  9585. onVRRequestPresentComplete: Observable<boolean>;
  9586. /**
  9587. * Observable signaled when VR request present starts
  9588. */
  9589. onVRRequestPresentStart: Observable<Engine>;
  9590. private _hardwareScalingLevel;
  9591. /** @hidden */
  9592. protected _caps: EngineCapabilities;
  9593. private _pointerLockRequested;
  9594. private _isStencilEnable;
  9595. private _colorWrite;
  9596. private _loadingScreen;
  9597. /** @hidden */
  9598. _drawCalls: PerfCounter;
  9599. /** @hidden */
  9600. _textureCollisions: PerfCounter;
  9601. private _glVersion;
  9602. private _glRenderer;
  9603. private _glVendor;
  9604. private _videoTextureSupported;
  9605. private _renderingQueueLaunched;
  9606. private _activeRenderLoops;
  9607. private _deterministicLockstep;
  9608. private _lockstepMaxSteps;
  9609. /**
  9610. * Observable signaled when a context lost event is raised
  9611. */
  9612. onContextLostObservable: Observable<Engine>;
  9613. /**
  9614. * Observable signaled when a context restored event is raised
  9615. */
  9616. onContextRestoredObservable: Observable<Engine>;
  9617. private _onContextLost;
  9618. private _onContextRestored;
  9619. private _contextWasLost;
  9620. private _doNotHandleContextLost;
  9621. /**
  9622. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  9623. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  9624. */
  9625. doNotHandleContextLost: boolean;
  9626. private _performanceMonitor;
  9627. private _fps;
  9628. private _deltaTime;
  9629. /**
  9630. * Turn this value on if you want to pause FPS computation when in background
  9631. */
  9632. disablePerformanceMonitorInBackground: boolean;
  9633. /**
  9634. * Gets the performance monitor attached to this engine
  9635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  9636. */
  9637. readonly performanceMonitor: PerformanceMonitor;
  9638. /** @hidden */
  9639. protected _depthCullingState: _DepthCullingState;
  9640. /** @hidden */
  9641. protected _stencilState: _StencilState;
  9642. /** @hidden */
  9643. protected _alphaState: _AlphaState;
  9644. /** @hidden */
  9645. protected _alphaMode: number;
  9646. protected _internalTexturesCache: InternalTexture[];
  9647. /** @hidden */
  9648. protected _activeChannel: number;
  9649. private _currentTextureChannel;
  9650. /** @hidden */
  9651. protected _boundTexturesCache: {
  9652. [key: string]: Nullable<InternalTexture>;
  9653. };
  9654. /** @hidden */
  9655. protected _currentEffect: Nullable<Effect>;
  9656. /** @hidden */
  9657. protected _currentProgram: Nullable<WebGLProgram>;
  9658. private _compiledEffects;
  9659. private _vertexAttribArraysEnabled;
  9660. /** @hidden */
  9661. protected _cachedViewport: Nullable<Viewport>;
  9662. private _cachedVertexArrayObject;
  9663. /** @hidden */
  9664. protected _cachedVertexBuffers: any;
  9665. /** @hidden */
  9666. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  9667. /** @hidden */
  9668. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  9669. /** @hidden */
  9670. protected _currentRenderTarget: Nullable<InternalTexture>;
  9671. private _uintIndicesCurrentlySet;
  9672. private _currentBoundBuffer;
  9673. /** @hidden */
  9674. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  9675. private _currentBufferPointers;
  9676. private _currentInstanceLocations;
  9677. private _currentInstanceBuffers;
  9678. private _textureUnits;
  9679. private _firstBoundInternalTextureTracker;
  9680. private _lastBoundInternalTextureTracker;
  9681. private _workingCanvas;
  9682. private _workingContext;
  9683. private _rescalePostProcess;
  9684. private _dummyFramebuffer;
  9685. private _externalData;
  9686. private _bindedRenderFunction;
  9687. private _vaoRecordInProgress;
  9688. private _mustWipeVertexAttributes;
  9689. private _emptyTexture;
  9690. private _emptyCubeTexture;
  9691. private _emptyTexture3D;
  9692. private _frameHandler;
  9693. private _nextFreeTextureSlots;
  9694. private _maxSimultaneousTextures;
  9695. private _activeRequests;
  9696. private _texturesSupported;
  9697. private _textureFormatInUse;
  9698. /**
  9699. * Gets the list of texture formats supported
  9700. */
  9701. readonly texturesSupported: Array<string>;
  9702. /**
  9703. * Gets the list of texture formats in use
  9704. */
  9705. readonly textureFormatInUse: Nullable<string>;
  9706. /**
  9707. * Gets the current viewport
  9708. */
  9709. readonly currentViewport: Nullable<Viewport>;
  9710. /**
  9711. * Gets the default empty texture
  9712. */
  9713. readonly emptyTexture: InternalTexture;
  9714. /**
  9715. * Gets the default empty 3D texture
  9716. */
  9717. readonly emptyTexture3D: InternalTexture;
  9718. /**
  9719. * Gets the default empty cube texture
  9720. */
  9721. readonly emptyCubeTexture: InternalTexture;
  9722. /**
  9723. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  9724. */
  9725. readonly premultipliedAlpha: boolean;
  9726. /**
  9727. * Creates a new engine
  9728. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  9729. * @param antialias defines enable antialiasing (default: false)
  9730. * @param options defines further options to be sent to the getContext() function
  9731. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  9732. */
  9733. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  9734. private _rebuildInternalTextures;
  9735. private _rebuildEffects;
  9736. private _rebuildBuffers;
  9737. private _initGLContext;
  9738. /**
  9739. * Gets version of the current webGL context
  9740. */
  9741. readonly webGLVersion: number;
  9742. /**
  9743. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  9744. */
  9745. readonly isStencilEnable: boolean;
  9746. private _prepareWorkingCanvas;
  9747. /**
  9748. * Reset the texture cache to empty state
  9749. */
  9750. resetTextureCache(): void;
  9751. /**
  9752. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  9753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9754. * @returns true if engine is in deterministic lock step mode
  9755. */
  9756. isDeterministicLockStep(): boolean;
  9757. /**
  9758. * Gets the max steps when engine is running in deterministic lock step
  9759. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9760. * @returns the max steps
  9761. */
  9762. getLockstepMaxSteps(): number;
  9763. /**
  9764. * Gets an object containing information about the current webGL context
  9765. * @returns an object containing the vender, the renderer and the version of the current webGL context
  9766. */
  9767. getGlInfo(): {
  9768. vendor: string;
  9769. renderer: string;
  9770. version: string;
  9771. };
  9772. /**
  9773. * Gets current aspect ratio
  9774. * @param camera defines the camera to use to get the aspect ratio
  9775. * @param useScreen defines if screen size must be used (or the current render target if any)
  9776. * @returns a number defining the aspect ratio
  9777. */
  9778. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  9779. /**
  9780. * Gets current screen aspect ratio
  9781. * @returns a number defining the aspect ratio
  9782. */
  9783. getScreenAspectRatio(): number;
  9784. /**
  9785. * Gets the current render width
  9786. * @param useScreen defines if screen size must be used (or the current render target if any)
  9787. * @returns a number defining the current render width
  9788. */
  9789. getRenderWidth(useScreen?: boolean): number;
  9790. /**
  9791. * Gets the current render height
  9792. * @param useScreen defines if screen size must be used (or the current render target if any)
  9793. * @returns a number defining the current render height
  9794. */
  9795. getRenderHeight(useScreen?: boolean): number;
  9796. /**
  9797. * Gets the HTML canvas attached with the current webGL context
  9798. * @returns a HTML canvas
  9799. */
  9800. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  9801. /**
  9802. * Gets the client rect of the HTML canvas attached with the current webGL context
  9803. * @returns a client rectanglee
  9804. */
  9805. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  9806. /**
  9807. * Defines the hardware scaling level.
  9808. * By default the hardware scaling level is computed from the window device ratio.
  9809. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  9810. * @param level defines the level to use
  9811. */
  9812. setHardwareScalingLevel(level: number): void;
  9813. /**
  9814. * Gets the current hardware scaling level.
  9815. * By default the hardware scaling level is computed from the window device ratio.
  9816. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  9817. * @returns a number indicating the current hardware scaling level
  9818. */
  9819. getHardwareScalingLevel(): number;
  9820. /**
  9821. * Gets the list of loaded textures
  9822. * @returns an array containing all loaded textures
  9823. */
  9824. getLoadedTexturesCache(): InternalTexture[];
  9825. /**
  9826. * Gets the object containing all engine capabilities
  9827. * @returns the EngineCapabilities object
  9828. */
  9829. getCaps(): EngineCapabilities;
  9830. /** @hidden */
  9831. readonly drawCalls: number;
  9832. /** @hidden */
  9833. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  9834. /**
  9835. * Gets the current depth function
  9836. * @returns a number defining the depth function
  9837. */
  9838. getDepthFunction(): Nullable<number>;
  9839. /**
  9840. * Sets the current depth function
  9841. * @param depthFunc defines the function to use
  9842. */
  9843. setDepthFunction(depthFunc: number): void;
  9844. /**
  9845. * Sets the current depth function to GREATER
  9846. */
  9847. setDepthFunctionToGreater(): void;
  9848. /**
  9849. * Sets the current depth function to GEQUAL
  9850. */
  9851. setDepthFunctionToGreaterOrEqual(): void;
  9852. /**
  9853. * Sets the current depth function to LESS
  9854. */
  9855. setDepthFunctionToLess(): void;
  9856. /**
  9857. * Sets the current depth function to LEQUAL
  9858. */
  9859. setDepthFunctionToLessOrEqual(): void;
  9860. /**
  9861. * Gets a boolean indicating if stencil buffer is enabled
  9862. * @returns the current stencil buffer state
  9863. */
  9864. getStencilBuffer(): boolean;
  9865. /**
  9866. * Enable or disable the stencil buffer
  9867. * @param enable defines if the stencil buffer must be enabled or disabled
  9868. */
  9869. setStencilBuffer(enable: boolean): void;
  9870. /**
  9871. * Gets the current stencil mask
  9872. * @returns a number defining the new stencil mask to use
  9873. */
  9874. getStencilMask(): number;
  9875. /**
  9876. * Sets the current stencil mask
  9877. * @param mask defines the new stencil mask to use
  9878. */
  9879. setStencilMask(mask: number): void;
  9880. /**
  9881. * Gets the current stencil function
  9882. * @returns a number defining the stencil function to use
  9883. */
  9884. getStencilFunction(): number;
  9885. /**
  9886. * Gets the current stencil reference value
  9887. * @returns a number defining the stencil reference value to use
  9888. */
  9889. getStencilFunctionReference(): number;
  9890. /**
  9891. * Gets the current stencil mask
  9892. * @returns a number defining the stencil mask to use
  9893. */
  9894. getStencilFunctionMask(): number;
  9895. /**
  9896. * Sets the current stencil function
  9897. * @param stencilFunc defines the new stencil function to use
  9898. */
  9899. setStencilFunction(stencilFunc: number): void;
  9900. /**
  9901. * Sets the current stencil reference
  9902. * @param reference defines the new stencil reference to use
  9903. */
  9904. setStencilFunctionReference(reference: number): void;
  9905. /**
  9906. * Sets the current stencil mask
  9907. * @param mask defines the new stencil mask to use
  9908. */
  9909. setStencilFunctionMask(mask: number): void;
  9910. /**
  9911. * Gets the current stencil operation when stencil fails
  9912. * @returns a number defining stencil operation to use when stencil fails
  9913. */
  9914. getStencilOperationFail(): number;
  9915. /**
  9916. * Gets the current stencil operation when depth fails
  9917. * @returns a number defining stencil operation to use when depth fails
  9918. */
  9919. getStencilOperationDepthFail(): number;
  9920. /**
  9921. * Gets the current stencil operation when stencil passes
  9922. * @returns a number defining stencil operation to use when stencil passes
  9923. */
  9924. getStencilOperationPass(): number;
  9925. /**
  9926. * Sets the stencil operation to use when stencil fails
  9927. * @param operation defines the stencil operation to use when stencil fails
  9928. */
  9929. setStencilOperationFail(operation: number): void;
  9930. /**
  9931. * Sets the stencil operation to use when depth fails
  9932. * @param operation defines the stencil operation to use when depth fails
  9933. */
  9934. setStencilOperationDepthFail(operation: number): void;
  9935. /**
  9936. * Sets the stencil operation to use when stencil passes
  9937. * @param operation defines the stencil operation to use when stencil passes
  9938. */
  9939. setStencilOperationPass(operation: number): void;
  9940. /**
  9941. * Sets a boolean indicating if the dithering state is enabled or disabled
  9942. * @param value defines the dithering state
  9943. */
  9944. setDitheringState(value: boolean): void;
  9945. /**
  9946. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  9947. * @param value defines the rasterizer state
  9948. */
  9949. setRasterizerState(value: boolean): void;
  9950. /**
  9951. * stop executing a render loop function and remove it from the execution array
  9952. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  9953. */
  9954. stopRenderLoop(renderFunction?: () => void): void;
  9955. /** @hidden */
  9956. _renderLoop(): void;
  9957. /**
  9958. * Register and execute a render loop. The engine can have more than one render function
  9959. * @param renderFunction defines the function to continuously execute
  9960. */
  9961. runRenderLoop(renderFunction: () => void): void;
  9962. /**
  9963. * Toggle full screen mode
  9964. * @param requestPointerLock defines if a pointer lock should be requested from the user
  9965. */
  9966. switchFullscreen(requestPointerLock: boolean): void;
  9967. /**
  9968. * Clear the current render buffer or the current render target (if any is set up)
  9969. * @param color defines the color to use
  9970. * @param backBuffer defines if the back buffer must be cleared
  9971. * @param depth defines if the depth buffer must be cleared
  9972. * @param stencil defines if the stencil buffer must be cleared
  9973. */
  9974. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9975. /**
  9976. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  9977. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  9978. * @param y defines the y-coordinate of the corner of the clear rectangle
  9979. * @param width defines the width of the clear rectangle
  9980. * @param height defines the height of the clear rectangle
  9981. * @param clearColor defines the clear color
  9982. */
  9983. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  9984. private _viewportCached;
  9985. /** @hidden */
  9986. _viewport(x: number, y: number, width: number, height: number): void;
  9987. /**
  9988. * Set the WebGL's viewport
  9989. * @param viewport defines the viewport element to be used
  9990. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  9991. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  9992. */
  9993. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9994. /**
  9995. * Directly set the WebGL Viewport
  9996. * @param x defines the x coordinate of the viewport (in screen space)
  9997. * @param y defines the y coordinate of the viewport (in screen space)
  9998. * @param width defines the width of the viewport (in screen space)
  9999. * @param height defines the height of the viewport (in screen space)
  10000. * @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
  10001. */
  10002. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10003. /**
  10004. * Begin a new frame
  10005. */
  10006. beginFrame(): void;
  10007. /**
  10008. * Enf the current frame
  10009. */
  10010. endFrame(): void;
  10011. /**
  10012. * Resize the view according to the canvas' size
  10013. */
  10014. resize(): void;
  10015. /**
  10016. * Force a specific size of the canvas
  10017. * @param width defines the new canvas' width
  10018. * @param height defines the new canvas' height
  10019. */
  10020. setSize(width: number, height: number): void;
  10021. /**
  10022. * Gets a boolean indicating if a webVR device was detected
  10023. * @returns true if a webVR device was detected
  10024. */
  10025. isVRDevicePresent(): boolean;
  10026. /**
  10027. * Gets the current webVR device
  10028. * @returns the current webVR device (or null)
  10029. */
  10030. getVRDevice(): any;
  10031. /**
  10032. * Initializes a webVR display and starts listening to display change events
  10033. * The onVRDisplayChangedObservable will be notified upon these changes
  10034. * @returns The onVRDisplayChangedObservable
  10035. */
  10036. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10037. /**
  10038. * Initializes a webVR display and starts listening to display change events
  10039. * The onVRDisplayChangedObservable will be notified upon these changes
  10040. * @returns A promise containing a VRDisplay and if vr is supported
  10041. */
  10042. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10043. /**
  10044. * Call this function to switch to webVR mode
  10045. * Will do nothing if webVR is not supported or if there is no webVR device
  10046. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10047. */
  10048. enableVR(): void;
  10049. /**
  10050. * Call this function to leave webVR mode
  10051. * Will do nothing if webVR is not supported or if there is no webVR device
  10052. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10053. */
  10054. disableVR(): void;
  10055. private _onVRFullScreenTriggered;
  10056. private _getVRDisplaysAsync;
  10057. /**
  10058. * Binds the frame buffer to the specified texture.
  10059. * @param texture The texture to render to or null for the default canvas
  10060. * @param faceIndex The face of the texture to render to in case of cube texture
  10061. * @param requiredWidth The width of the target to render to
  10062. * @param requiredHeight The height of the target to render to
  10063. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10064. * @param depthStencilTexture The depth stencil texture to use to render
  10065. * @param lodLevel defines le lod level to bind to the frame buffer
  10066. */
  10067. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10068. private bindUnboundFramebuffer;
  10069. /**
  10070. * Unbind the current render target texture from the webGL context
  10071. * @param texture defines the render target texture to unbind
  10072. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10073. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10074. */
  10075. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10076. /**
  10077. * Unbind a list of render target textures from the webGL context
  10078. * This is used only when drawBuffer extension or webGL2 are active
  10079. * @param textures defines the render target textures to unbind
  10080. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10081. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10082. */
  10083. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10084. /**
  10085. * Force the mipmap generation for the given render target texture
  10086. * @param texture defines the render target texture to use
  10087. */
  10088. generateMipMapsForCubemap(texture: InternalTexture): void;
  10089. /**
  10090. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10091. */
  10092. flushFramebuffer(): void;
  10093. /**
  10094. * Unbind the current render target and bind the default framebuffer
  10095. */
  10096. restoreDefaultFramebuffer(): void;
  10097. /**
  10098. * Create an uniform buffer
  10099. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10100. * @param elements defines the content of the uniform buffer
  10101. * @returns the webGL uniform buffer
  10102. */
  10103. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10104. /**
  10105. * Create a dynamic uniform buffer
  10106. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10107. * @param elements defines the content of the uniform buffer
  10108. * @returns the webGL uniform buffer
  10109. */
  10110. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10111. /**
  10112. * Update an existing uniform buffer
  10113. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10114. * @param uniformBuffer defines the target uniform buffer
  10115. * @param elements defines the content to update
  10116. * @param offset defines the offset in the uniform buffer where update should start
  10117. * @param count defines the size of the data to update
  10118. */
  10119. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10120. private _resetVertexBufferBinding;
  10121. /**
  10122. * Creates a vertex buffer
  10123. * @param data the data for the vertex buffer
  10124. * @returns the new WebGL static buffer
  10125. */
  10126. createVertexBuffer(data: DataArray): WebGLBuffer;
  10127. /**
  10128. * Creates a dynamic vertex buffer
  10129. * @param data the data for the dynamic vertex buffer
  10130. * @returns the new WebGL dynamic buffer
  10131. */
  10132. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10133. /**
  10134. * Update a dynamic index buffer
  10135. * @param indexBuffer defines the target index buffer
  10136. * @param indices defines the data to update
  10137. * @param offset defines the offset in the target index buffer where update should start
  10138. */
  10139. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10140. /**
  10141. * Updates a dynamic vertex buffer.
  10142. * @param vertexBuffer the vertex buffer to update
  10143. * @param data the data used to update the vertex buffer
  10144. * @param byteOffset the byte offset of the data
  10145. * @param byteLength the byte length of the data
  10146. */
  10147. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10148. private _resetIndexBufferBinding;
  10149. /**
  10150. * Creates a new index buffer
  10151. * @param indices defines the content of the index buffer
  10152. * @param updatable defines if the index buffer must be updatable
  10153. * @returns a new webGL buffer
  10154. */
  10155. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10156. /**
  10157. * Bind a webGL buffer to the webGL context
  10158. * @param buffer defines the buffer to bind
  10159. */
  10160. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10161. /**
  10162. * Bind an uniform buffer to the current webGL context
  10163. * @param buffer defines the buffer to bind
  10164. */
  10165. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10166. /**
  10167. * Bind a buffer to the current webGL context at a given location
  10168. * @param buffer defines the buffer to bind
  10169. * @param location defines the index where to bind the buffer
  10170. */
  10171. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10172. /**
  10173. * Bind a specific block at a given index in a specific shader program
  10174. * @param shaderProgram defines the shader program
  10175. * @param blockName defines the block name
  10176. * @param index defines the index where to bind the block
  10177. */
  10178. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10179. private bindIndexBuffer;
  10180. private bindBuffer;
  10181. /**
  10182. * update the bound buffer with the given data
  10183. * @param data defines the data to update
  10184. */
  10185. updateArrayBuffer(data: Float32Array): void;
  10186. private _vertexAttribPointer;
  10187. private _bindIndexBufferWithCache;
  10188. private _bindVertexBuffersAttributes;
  10189. /**
  10190. * Records a vertex array object
  10191. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10192. * @param vertexBuffers defines the list of vertex buffers to store
  10193. * @param indexBuffer defines the index buffer to store
  10194. * @param effect defines the effect to store
  10195. * @returns the new vertex array object
  10196. */
  10197. recordVertexArrayObject(vertexBuffers: {
  10198. [key: string]: VertexBuffer;
  10199. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10200. /**
  10201. * Bind a specific vertex array object
  10202. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10203. * @param vertexArrayObject defines the vertex array object to bind
  10204. * @param indexBuffer defines the index buffer to bind
  10205. */
  10206. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10207. /**
  10208. * Bind webGl buffers directly to the webGL context
  10209. * @param vertexBuffer defines the vertex buffer to bind
  10210. * @param indexBuffer defines the index buffer to bind
  10211. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10212. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10213. * @param effect defines the effect associated with the vertex buffer
  10214. */
  10215. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10216. private _unbindVertexArrayObject;
  10217. /**
  10218. * Bind a list of vertex buffers to the webGL context
  10219. * @param vertexBuffers defines the list of vertex buffers to bind
  10220. * @param indexBuffer defines the index buffer to bind
  10221. * @param effect defines the effect associated with the vertex buffers
  10222. */
  10223. bindBuffers(vertexBuffers: {
  10224. [key: string]: Nullable<VertexBuffer>;
  10225. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10226. /**
  10227. * Unbind all instance attributes
  10228. */
  10229. unbindInstanceAttributes(): void;
  10230. /**
  10231. * Release and free the memory of a vertex array object
  10232. * @param vao defines the vertex array object to delete
  10233. */
  10234. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10235. /** @hidden */
  10236. _releaseBuffer(buffer: WebGLBuffer): boolean;
  10237. /**
  10238. * Creates a webGL buffer to use with instanciation
  10239. * @param capacity defines the size of the buffer
  10240. * @returns the webGL buffer
  10241. */
  10242. createInstancesBuffer(capacity: number): WebGLBuffer;
  10243. /**
  10244. * Delete a webGL buffer used with instanciation
  10245. * @param buffer defines the webGL buffer to delete
  10246. */
  10247. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  10248. /**
  10249. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  10250. * @param instancesBuffer defines the webGL buffer to update and bind
  10251. * @param data defines the data to store in the buffer
  10252. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  10253. */
  10254. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  10255. /**
  10256. * Apply all cached states (depth, culling, stencil and alpha)
  10257. */
  10258. applyStates(): void;
  10259. /**
  10260. * Send a draw order
  10261. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10262. * @param indexStart defines the starting index
  10263. * @param indexCount defines the number of index to draw
  10264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10265. */
  10266. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  10267. /**
  10268. * Draw a list of points
  10269. * @param verticesStart defines the index of first vertex to draw
  10270. * @param verticesCount defines the count of vertices to draw
  10271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10272. */
  10273. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10274. /**
  10275. * Draw a list of unindexed primitives
  10276. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10277. * @param verticesStart defines the index of first vertex to draw
  10278. * @param verticesCount defines the count of vertices to draw
  10279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10280. */
  10281. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10282. /**
  10283. * Draw a list of indexed primitives
  10284. * @param fillMode defines the primitive to use
  10285. * @param indexStart defines the starting index
  10286. * @param indexCount defines the number of index to draw
  10287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10288. */
  10289. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  10290. /**
  10291. * Draw a list of unindexed primitives
  10292. * @param fillMode defines the primitive to use
  10293. * @param verticesStart defines the index of first vertex to draw
  10294. * @param verticesCount defines the count of vertices to draw
  10295. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10296. */
  10297. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10298. private _drawMode;
  10299. /** @hidden */
  10300. _releaseEffect(effect: Effect): void;
  10301. /** @hidden */
  10302. _deleteProgram(program: WebGLProgram): void;
  10303. /**
  10304. * Create a new effect (used to store vertex/fragment shaders)
  10305. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  10306. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  10307. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  10308. * @param samplers defines an array of string used to represent textures
  10309. * @param defines defines the string containing the defines to use to compile the shaders
  10310. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  10311. * @param onCompiled defines a function to call when the effect creation is successful
  10312. * @param onError defines a function to call when the effect creation has failed
  10313. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  10314. * @returns the new Effect
  10315. */
  10316. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  10317. private _compileShader;
  10318. private _compileRawShader;
  10319. /**
  10320. * Directly creates a webGL program
  10321. * @param vertexCode defines the vertex shader code to use
  10322. * @param fragmentCode defines the fragment shader code to use
  10323. * @param context defines the webGL context to use (if not set, the current one will be used)
  10324. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10325. * @returns the new webGL program
  10326. */
  10327. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10328. /**
  10329. * Creates a webGL program
  10330. * @param vertexCode defines the vertex shader code to use
  10331. * @param fragmentCode defines the fragment shader code to use
  10332. * @param defines defines the string containing the defines to use to compile the shaders
  10333. * @param context defines the webGL context to use (if not set, the current one will be used)
  10334. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10335. * @returns the new webGL program
  10336. */
  10337. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10338. private _createShaderProgram;
  10339. /**
  10340. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  10341. * @param shaderProgram defines the webGL program to use
  10342. * @param uniformsNames defines the list of uniform names
  10343. * @returns an array of webGL uniform locations
  10344. */
  10345. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  10346. /**
  10347. * Gets the lsit of active attributes for a given webGL program
  10348. * @param shaderProgram defines the webGL program to use
  10349. * @param attributesNames defines the list of attribute names to get
  10350. * @returns an array of indices indicating the offset of each attribute
  10351. */
  10352. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  10353. /**
  10354. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  10355. * @param effect defines the effect to activate
  10356. */
  10357. enableEffect(effect: Nullable<Effect>): void;
  10358. /**
  10359. * Set the value of an uniform to an array of int32
  10360. * @param uniform defines the webGL uniform location where to store the value
  10361. * @param array defines the array of int32 to store
  10362. */
  10363. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10364. /**
  10365. * Set the value of an uniform to an array of int32 (stored as vec2)
  10366. * @param uniform defines the webGL uniform location where to store the value
  10367. * @param array defines the array of int32 to store
  10368. */
  10369. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10370. /**
  10371. * Set the value of an uniform to an array of int32 (stored as vec3)
  10372. * @param uniform defines the webGL uniform location where to store the value
  10373. * @param array defines the array of int32 to store
  10374. */
  10375. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10376. /**
  10377. * Set the value of an uniform to an array of int32 (stored as vec4)
  10378. * @param uniform defines the webGL uniform location where to store the value
  10379. * @param array defines the array of int32 to store
  10380. */
  10381. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10382. /**
  10383. * Set the value of an uniform to an array of float32
  10384. * @param uniform defines the webGL uniform location where to store the value
  10385. * @param array defines the array of float32 to store
  10386. */
  10387. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10388. /**
  10389. * Set the value of an uniform to an array of float32 (stored as vec2)
  10390. * @param uniform defines the webGL uniform location where to store the value
  10391. * @param array defines the array of float32 to store
  10392. */
  10393. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10394. /**
  10395. * Set the value of an uniform to an array of float32 (stored as vec3)
  10396. * @param uniform defines the webGL uniform location where to store the value
  10397. * @param array defines the array of float32 to store
  10398. */
  10399. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10400. /**
  10401. * Set the value of an uniform to an array of float32 (stored as vec4)
  10402. * @param uniform defines the webGL uniform location where to store the value
  10403. * @param array defines the array of float32 to store
  10404. */
  10405. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10406. /**
  10407. * Set the value of an uniform to an array of number
  10408. * @param uniform defines the webGL uniform location where to store the value
  10409. * @param array defines the array of number to store
  10410. */
  10411. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10412. /**
  10413. * Set the value of an uniform to an array of number (stored as vec2)
  10414. * @param uniform defines the webGL uniform location where to store the value
  10415. * @param array defines the array of number to store
  10416. */
  10417. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10418. /**
  10419. * Set the value of an uniform to an array of number (stored as vec3)
  10420. * @param uniform defines the webGL uniform location where to store the value
  10421. * @param array defines the array of number to store
  10422. */
  10423. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10424. /**
  10425. * Set the value of an uniform to an array of number (stored as vec4)
  10426. * @param uniform defines the webGL uniform location where to store the value
  10427. * @param array defines the array of number to store
  10428. */
  10429. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10430. /**
  10431. * Set the value of an uniform to an array of float32 (stored as matrices)
  10432. * @param uniform defines the webGL uniform location where to store the value
  10433. * @param matrices defines the array of float32 to store
  10434. */
  10435. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  10436. /**
  10437. * Set the value of an uniform to a matrix
  10438. * @param uniform defines the webGL uniform location where to store the value
  10439. * @param matrix defines the matrix to store
  10440. */
  10441. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  10442. /**
  10443. * Set the value of an uniform to a matrix (3x3)
  10444. * @param uniform defines the webGL uniform location where to store the value
  10445. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  10446. */
  10447. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10448. /**
  10449. * Set the value of an uniform to a matrix (2x2)
  10450. * @param uniform defines the webGL uniform location where to store the value
  10451. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  10452. */
  10453. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10454. /**
  10455. * Set the value of an uniform to a number (int)
  10456. * @param uniform defines the webGL uniform location where to store the value
  10457. * @param value defines the int number to store
  10458. */
  10459. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10460. /**
  10461. * Set the value of an uniform to a number (float)
  10462. * @param uniform defines the webGL uniform location where to store the value
  10463. * @param value defines the float number to store
  10464. */
  10465. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10466. /**
  10467. * Set the value of an uniform to a vec2
  10468. * @param uniform defines the webGL uniform location where to store the value
  10469. * @param x defines the 1st component of the value
  10470. * @param y defines the 2nd component of the value
  10471. */
  10472. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  10473. /**
  10474. * Set the value of an uniform to a vec3
  10475. * @param uniform defines the webGL uniform location where to store the value
  10476. * @param x defines the 1st component of the value
  10477. * @param y defines the 2nd component of the value
  10478. * @param z defines the 3rd component of the value
  10479. */
  10480. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  10481. /**
  10482. * Set the value of an uniform to a boolean
  10483. * @param uniform defines the webGL uniform location where to store the value
  10484. * @param bool defines the boolean to store
  10485. */
  10486. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  10487. /**
  10488. * Set the value of an uniform to a vec4
  10489. * @param uniform defines the webGL uniform location where to store the value
  10490. * @param x defines the 1st component of the value
  10491. * @param y defines the 2nd component of the value
  10492. * @param z defines the 3rd component of the value
  10493. * @param w defines the 4th component of the value
  10494. */
  10495. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  10496. /**
  10497. * Set the value of an uniform to a Color3
  10498. * @param uniform defines the webGL uniform location where to store the value
  10499. * @param color3 defines the color to store
  10500. */
  10501. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  10502. /**
  10503. * Set the value of an uniform to a Color3 and an alpha value
  10504. * @param uniform defines the webGL uniform location where to store the value
  10505. * @param color3 defines the color to store
  10506. * @param alpha defines the alpha component to store
  10507. */
  10508. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  10509. /**
  10510. * Sets a Color4 on a uniform variable
  10511. * @param uniform defines the uniform location
  10512. * @param color4 defines the value to be set
  10513. */
  10514. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  10515. /**
  10516. * Set various states to the webGL context
  10517. * @param culling defines backface culling state
  10518. * @param zOffset defines the value to apply to zOffset (0 by default)
  10519. * @param force defines if states must be applied even if cache is up to date
  10520. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  10521. */
  10522. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  10523. /**
  10524. * Set the z offset to apply to current rendering
  10525. * @param value defines the offset to apply
  10526. */
  10527. setZOffset(value: number): void;
  10528. /**
  10529. * Gets the current value of the zOffset
  10530. * @returns the current zOffset state
  10531. */
  10532. getZOffset(): number;
  10533. /**
  10534. * Enable or disable depth buffering
  10535. * @param enable defines the state to set
  10536. */
  10537. setDepthBuffer(enable: boolean): void;
  10538. /**
  10539. * Gets a boolean indicating if depth writing is enabled
  10540. * @returns the current depth writing state
  10541. */
  10542. getDepthWrite(): boolean;
  10543. /**
  10544. * Enable or disable depth writing
  10545. * @param enable defines the state to set
  10546. */
  10547. setDepthWrite(enable: boolean): void;
  10548. /**
  10549. * Enable or disable color writing
  10550. * @param enable defines the state to set
  10551. */
  10552. setColorWrite(enable: boolean): void;
  10553. /**
  10554. * Gets a boolean indicating if color writing is enabled
  10555. * @returns the current color writing state
  10556. */
  10557. getColorWrite(): boolean;
  10558. /**
  10559. * Sets alpha constants used by some alpha blending modes
  10560. * @param r defines the red component
  10561. * @param g defines the green component
  10562. * @param b defines the blue component
  10563. * @param a defines the alpha component
  10564. */
  10565. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  10566. /**
  10567. * Sets the current alpha mode
  10568. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  10569. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  10570. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10571. */
  10572. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  10573. /**
  10574. * Gets the current alpha mode
  10575. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10576. * @returns the current alpha mode
  10577. */
  10578. getAlphaMode(): number;
  10579. /**
  10580. * Clears the list of texture accessible through engine.
  10581. * This can help preventing texture load conflict due to name collision.
  10582. */
  10583. clearInternalTexturesCache(): void;
  10584. /**
  10585. * Force the entire cache to be cleared
  10586. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  10587. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  10588. */
  10589. wipeCaches(bruteForce?: boolean): void;
  10590. /**
  10591. * Set the compressed texture format to use, based on the formats you have, and the formats
  10592. * supported by the hardware / browser.
  10593. *
  10594. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  10595. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  10596. * to API arguments needed to compressed textures. This puts the burden on the container
  10597. * generator to house the arcane code for determining these for current & future formats.
  10598. *
  10599. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  10600. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  10601. *
  10602. * Note: The result of this call is not taken into account when a texture is base64.
  10603. *
  10604. * @param formatsAvailable defines the list of those format families you have created
  10605. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  10606. *
  10607. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  10608. * @returns The extension selected.
  10609. */
  10610. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  10611. private _getSamplingParameters;
  10612. private _partialLoadImg;
  10613. private _cascadeLoadImgs;
  10614. /** @hidden */
  10615. _createTexture(): WebGLTexture;
  10616. /**
  10617. * Usually called from BABYLON.Texture.ts.
  10618. * Passed information to create a WebGLTexture
  10619. * @param urlArg defines a value which contains one of the following:
  10620. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  10621. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  10622. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  10623. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  10624. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  10625. * @param scene needed for loading to the correct scene
  10626. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  10627. * @param onLoad optional callback to be called upon successful completion
  10628. * @param onError optional callback to be called upon failure
  10629. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  10630. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  10631. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  10632. * @param forcedExtension defines the extension to use to pick the right loader
  10633. * @returns a InternalTexture for assignment back into BABYLON.Texture
  10634. */
  10635. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  10636. private _rescaleTexture;
  10637. /**
  10638. * Update a raw texture
  10639. * @param texture defines the texture to update
  10640. * @param data defines the data to store in the texture
  10641. * @param format defines the format of the data
  10642. * @param invertY defines if data must be stored with Y axis inverted
  10643. * @param compression defines the compression used (null by default)
  10644. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10645. */
  10646. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  10647. /**
  10648. * Creates a raw texture
  10649. * @param data defines the data to store in the texture
  10650. * @param width defines the width of the texture
  10651. * @param height defines the height of the texture
  10652. * @param format defines the format of the data
  10653. * @param generateMipMaps defines if the engine should generate the mip levels
  10654. * @param invertY defines if data must be stored with Y axis inverted
  10655. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10656. * @param compression defines the compression used (null by default)
  10657. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10658. * @returns the raw texture inside an InternalTexture
  10659. */
  10660. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  10661. private _unpackFlipYCached;
  10662. /**
  10663. * In case you are sharing the context with other applications, it might
  10664. * be interested to not cache the unpack flip y state to ensure a consistent
  10665. * value would be set.
  10666. */
  10667. enableUnpackFlipYCached: boolean;
  10668. /** @hidden */
  10669. _unpackFlipY(value: boolean): void;
  10670. /** @hidden */
  10671. _getUnpackAlignement(): number;
  10672. /**
  10673. * Creates a dynamic texture
  10674. * @param width defines the width of the texture
  10675. * @param height defines the height of the texture
  10676. * @param generateMipMaps defines if the engine should generate the mip levels
  10677. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10678. * @returns the dynamic texture inside an InternalTexture
  10679. */
  10680. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10681. /**
  10682. * Update the sampling mode of a given texture
  10683. * @param samplingMode defines the required sampling mode
  10684. * @param texture defines the texture to update
  10685. */
  10686. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  10687. /**
  10688. * Update the content of a dynamic texture
  10689. * @param texture defines the texture to update
  10690. * @param canvas defines the canvas containing the source
  10691. * @param invertY defines if data must be stored with Y axis inverted
  10692. * @param premulAlpha defines if alpha is stored as premultiplied
  10693. * @param format defines the format of the data
  10694. */
  10695. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  10696. /**
  10697. * Update a video texture
  10698. * @param texture defines the texture to update
  10699. * @param video defines the video element to use
  10700. * @param invertY defines if data must be stored with Y axis inverted
  10701. */
  10702. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  10703. /**
  10704. * Updates a depth texture Comparison Mode and Function.
  10705. * If the comparison Function is equal to 0, the mode will be set to none.
  10706. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  10707. * @param texture The texture to set the comparison function for
  10708. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  10709. */
  10710. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  10711. private _setupDepthStencilTexture;
  10712. /**
  10713. * Creates a depth stencil texture.
  10714. * This is only available in WebGL 2 or with the depth texture extension available.
  10715. * @param size The size of face edge in the texture.
  10716. * @param options The options defining the texture.
  10717. * @returns The texture
  10718. */
  10719. createDepthStencilTexture(size: number | {
  10720. width: number;
  10721. height: number;
  10722. }, options: DepthTextureCreationOptions): InternalTexture;
  10723. /**
  10724. * Creates a depth stencil texture.
  10725. * This is only available in WebGL 2 or with the depth texture extension available.
  10726. * @param size The size of face edge in the texture.
  10727. * @param options The options defining the texture.
  10728. * @returns The texture
  10729. */
  10730. private _createDepthStencilTexture;
  10731. /**
  10732. * Creates a depth stencil cube texture.
  10733. * This is only available in WebGL 2.
  10734. * @param size The size of face edge in the cube texture.
  10735. * @param options The options defining the cube texture.
  10736. * @returns The cube texture
  10737. */
  10738. private _createDepthStencilCubeTexture;
  10739. /**
  10740. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  10741. * @param renderTarget The render target to set the frame buffer for
  10742. */
  10743. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  10744. /**
  10745. * Creates a new render target texture
  10746. * @param size defines the size of the texture
  10747. * @param options defines the options used to create the texture
  10748. * @returns a new render target texture stored in an InternalTexture
  10749. */
  10750. createRenderTargetTexture(size: number | {
  10751. width: number;
  10752. height: number;
  10753. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  10754. /**
  10755. * Create a multi render target texture
  10756. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  10757. * @param size defines the size of the texture
  10758. * @param options defines the creation options
  10759. * @returns the cube texture as an InternalTexture
  10760. */
  10761. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  10762. private _setupFramebufferDepthAttachments;
  10763. /**
  10764. * Updates the sample count of a render target texture
  10765. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  10766. * @param texture defines the texture to update
  10767. * @param samples defines the sample count to set
  10768. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  10769. */
  10770. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  10771. /**
  10772. * Update the sample count for a given multiple render target texture
  10773. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  10774. * @param textures defines the textures to update
  10775. * @param samples defines the sample count to set
  10776. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  10777. */
  10778. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  10779. /** @hidden */
  10780. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10781. /** @hidden */
  10782. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10783. /** @hidden */
  10784. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10785. /** @hidden */
  10786. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  10787. /**
  10788. * Creates a new render target cube texture
  10789. * @param size defines the size of the texture
  10790. * @param options defines the options used to create the texture
  10791. * @returns a new render target cube texture stored in an InternalTexture
  10792. */
  10793. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10794. /**
  10795. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  10796. * @param rootUrl defines the url where the file to load is located
  10797. * @param scene defines the current scene
  10798. * @param lodScale defines scale to apply to the mip map selection
  10799. * @param lodOffset defines offset to apply to the mip map selection
  10800. * @param onLoad defines an optional callback raised when the texture is loaded
  10801. * @param onError defines an optional callback raised if there is an issue to load the texture
  10802. * @param format defines the format of the data
  10803. * @param forcedExtension defines the extension to use to pick the right loader
  10804. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  10805. * @returns the cube texture as an InternalTexture
  10806. */
  10807. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  10808. /**
  10809. * Creates a cube texture
  10810. * @param rootUrl defines the url where the files to load is located
  10811. * @param scene defines the current scene
  10812. * @param files defines the list of files to load (1 per face)
  10813. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10814. * @param onLoad defines an optional callback raised when the texture is loaded
  10815. * @param onError defines an optional callback raised if there is an issue to load the texture
  10816. * @param format defines the format of the data
  10817. * @param forcedExtension defines the extension to use to pick the right loader
  10818. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10819. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10820. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10821. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10822. * @returns the cube texture as an InternalTexture
  10823. */
  10824. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  10825. /**
  10826. * @hidden
  10827. */
  10828. _setCubeMapTextureParams(loadMipmap: boolean): void;
  10829. /**
  10830. * Update a raw cube texture
  10831. * @param texture defines the texture to udpdate
  10832. * @param data defines the data to store
  10833. * @param format defines the data format
  10834. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10835. * @param invertY defines if data must be stored with Y axis inverted
  10836. * @param compression defines the compression used (null by default)
  10837. * @param level defines which level of the texture to update
  10838. */
  10839. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  10840. /**
  10841. * Creates a new raw cube texture
  10842. * @param data defines the array of data to use to create each face
  10843. * @param size defines the size of the textures
  10844. * @param format defines the format of the data
  10845. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  10846. * @param generateMipMaps defines if the engine should generate the mip levels
  10847. * @param invertY defines if data must be stored with Y axis inverted
  10848. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10849. * @param compression defines the compression used (null by default)
  10850. * @returns the cube texture as an InternalTexture
  10851. */
  10852. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  10853. /**
  10854. * Creates a new raw cube texture from a specified url
  10855. * @param url defines the url where the data is located
  10856. * @param scene defines the current scene
  10857. * @param size defines the size of the textures
  10858. * @param format defines the format of the data
  10859. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  10860. * @param noMipmap defines if the engine should avoid generating the mip levels
  10861. * @param callback defines a callback used to extract texture data from loaded data
  10862. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10863. * @param onLoad defines a callback called when texture is loaded
  10864. * @param onError defines a callback called if there is an error
  10865. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10866. * @param invertY defines if data must be stored with Y axis inverted
  10867. * @returns the cube texture as an InternalTexture
  10868. */
  10869. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  10870. /**
  10871. * Update a raw 3D texture
  10872. * @param texture defines the texture to update
  10873. * @param data defines the data to store
  10874. * @param format defines the data format
  10875. * @param invertY defines if data must be stored with Y axis inverted
  10876. * @param compression defines the used compression (can be null)
  10877. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10878. */
  10879. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  10880. /**
  10881. * Creates a new raw 3D texture
  10882. * @param data defines the data used to create the texture
  10883. * @param width defines the width of the texture
  10884. * @param height defines the height of the texture
  10885. * @param depth defines the depth of the texture
  10886. * @param format defines the format of the texture
  10887. * @param generateMipMaps defines if the engine must generate mip levels
  10888. * @param invertY defines if data must be stored with Y axis inverted
  10889. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10890. * @param compression defines the compressed used (can be null)
  10891. * @param textureType defines the compressed used (can be null)
  10892. * @returns a new raw 3D texture (stored in an InternalTexture)
  10893. */
  10894. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  10895. private _prepareWebGLTextureContinuation;
  10896. private _prepareWebGLTexture;
  10897. private _convertRGBtoRGBATextureData;
  10898. /** @hidden */
  10899. _releaseFramebufferObjects(texture: InternalTexture): void;
  10900. /** @hidden */
  10901. _releaseTexture(texture: InternalTexture): void;
  10902. private setProgram;
  10903. private _boundUniforms;
  10904. /**
  10905. * Binds an effect to the webGL context
  10906. * @param effect defines the effect to bind
  10907. */
  10908. bindSamplers(effect: Effect): void;
  10909. private _moveBoundTextureOnTop;
  10910. private _getCorrectTextureChannel;
  10911. private _linkTrackers;
  10912. private _removeDesignatedSlot;
  10913. private _activateCurrentTexture;
  10914. /** @hidden */
  10915. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  10916. /** @hidden */
  10917. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  10918. /**
  10919. * Sets a texture to the webGL context from a postprocess
  10920. * @param channel defines the channel to use
  10921. * @param postProcess defines the source postprocess
  10922. */
  10923. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  10924. /**
  10925. * Binds the output of the passed in post process to the texture channel specified
  10926. * @param channel The channel the texture should be bound to
  10927. * @param postProcess The post process which's output should be bound
  10928. */
  10929. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  10930. /**
  10931. * Unbind all textures from the webGL context
  10932. */
  10933. unbindAllTextures(): void;
  10934. /**
  10935. * Sets a texture to the according uniform.
  10936. * @param channel The texture channel
  10937. * @param uniform The uniform to set
  10938. * @param texture The texture to apply
  10939. */
  10940. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  10941. /**
  10942. * Sets a depth stencil texture from a render target to the according uniform.
  10943. * @param channel The texture channel
  10944. * @param uniform The uniform to set
  10945. * @param texture The render target texture containing the depth stencil texture to apply
  10946. */
  10947. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  10948. private _bindSamplerUniformToChannel;
  10949. private _getTextureWrapMode;
  10950. private _setTexture;
  10951. /**
  10952. * Sets an array of texture to the webGL context
  10953. * @param channel defines the channel where the texture array must be set
  10954. * @param uniform defines the associated uniform location
  10955. * @param textures defines the array of textures to bind
  10956. */
  10957. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  10958. /** @hidden */
  10959. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  10960. private _setTextureParameterFloat;
  10961. private _setTextureParameterInteger;
  10962. /**
  10963. * Reads pixels from the current frame buffer. Please note that this function can be slow
  10964. * @param x defines the x coordinate of the rectangle where pixels must be read
  10965. * @param y defines the y coordinate of the rectangle where pixels must be read
  10966. * @param width defines the width of the rectangle where pixels must be read
  10967. * @param height defines the height of the rectangle where pixels must be read
  10968. * @returns a Uint8Array containing RGBA colors
  10969. */
  10970. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  10971. /**
  10972. * Add an externaly attached data from its key.
  10973. * This method call will fail and return false, if such key already exists.
  10974. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  10975. * @param key the unique key that identifies the data
  10976. * @param data the data object to associate to the key for this Engine instance
  10977. * @return true if no such key were already present and the data was added successfully, false otherwise
  10978. */
  10979. addExternalData<T>(key: string, data: T): boolean;
  10980. /**
  10981. * Get an externaly attached data from its key
  10982. * @param key the unique key that identifies the data
  10983. * @return the associated data, if present (can be null), or undefined if not present
  10984. */
  10985. getExternalData<T>(key: string): T;
  10986. /**
  10987. * Get an externaly attached data from its key, create it using a factory if it's not already present
  10988. * @param key the unique key that identifies the data
  10989. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  10990. * @return the associated data, can be null if the factory returned null.
  10991. */
  10992. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  10993. /**
  10994. * Remove an externaly attached data from the Engine instance
  10995. * @param key the unique key that identifies the data
  10996. * @return true if the data was successfully removed, false if it doesn't exist
  10997. */
  10998. removeExternalData(key: string): boolean;
  10999. /**
  11000. * Unbind all vertex attributes from the webGL context
  11001. */
  11002. unbindAllAttributes(): void;
  11003. /**
  11004. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  11005. */
  11006. releaseEffects(): void;
  11007. /**
  11008. * Dispose and release all associated resources
  11009. */
  11010. dispose(): void;
  11011. /**
  11012. * Display the loading screen
  11013. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11014. */
  11015. displayLoadingUI(): void;
  11016. /**
  11017. * Hide the loading screen
  11018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11019. */
  11020. hideLoadingUI(): void;
  11021. /**
  11022. * Gets the current loading screen object
  11023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11024. */
  11025. /**
  11026. * Sets the current loading screen object
  11027. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11028. */
  11029. loadingScreen: ILoadingScreen;
  11030. /**
  11031. * Sets the current loading screen text
  11032. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11033. */
  11034. loadingUIText: string;
  11035. /**
  11036. * Sets the current loading screen background color
  11037. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11038. */
  11039. loadingUIBackgroundColor: string;
  11040. /**
  11041. * Attach a new callback raised when context lost event is fired
  11042. * @param callback defines the callback to call
  11043. */
  11044. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11045. /**
  11046. * Attach a new callback raised when context restored event is fired
  11047. * @param callback defines the callback to call
  11048. */
  11049. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11050. /**
  11051. * Gets the source code of the vertex shader associated with a specific webGL program
  11052. * @param program defines the program to use
  11053. * @returns a string containing the source code of the vertex shader associated with the program
  11054. */
  11055. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11056. /**
  11057. * Gets the source code of the fragment shader associated with a specific webGL program
  11058. * @param program defines the program to use
  11059. * @returns a string containing the source code of the fragment shader associated with the program
  11060. */
  11061. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11062. /**
  11063. * Get the current error code of the webGL context
  11064. * @returns the error code
  11065. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11066. */
  11067. getError(): number;
  11068. /**
  11069. * Gets the current framerate
  11070. * @returns a number representing the framerate
  11071. */
  11072. getFps(): number;
  11073. /**
  11074. * Gets the time spent between current and previous frame
  11075. * @returns a number representing the delta time in ms
  11076. */
  11077. getDeltaTime(): number;
  11078. private _measureFps;
  11079. /** @hidden */
  11080. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11081. private _canRenderToFloatFramebuffer;
  11082. private _canRenderToHalfFloatFramebuffer;
  11083. private _canRenderToFramebuffer;
  11084. /** @hidden */
  11085. _getWebGLTextureType(type: number): number;
  11086. private _getInternalFormat;
  11087. /** @hidden */
  11088. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11089. /** @hidden */
  11090. _getRGBAMultiSampleBufferFormat(type: number): number;
  11091. /** @hidden */
  11092. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  11093. /** @hidden */
  11094. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11095. private _partialLoadFile;
  11096. private _cascadeLoadFiles;
  11097. /**
  11098. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11099. * @returns true if the engine can be created
  11100. * @ignorenaming
  11101. */
  11102. static isSupported(): boolean;
  11103. }
  11104. }
  11105. declare module BABYLON {
  11106. /**
  11107. * Options to create the null engine
  11108. */
  11109. class NullEngineOptions {
  11110. /**
  11111. * Render width (Default: 512)
  11112. */
  11113. renderWidth: number;
  11114. /**
  11115. * Render height (Default: 256)
  11116. */
  11117. renderHeight: number;
  11118. /**
  11119. * Texture size (Default: 512)
  11120. */
  11121. textureSize: number;
  11122. /**
  11123. * If delta time between frames should be constant
  11124. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11125. */
  11126. deterministicLockstep: boolean;
  11127. /**
  11128. * Maximum about of steps between frames (Default: 4)
  11129. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11130. */
  11131. lockstepMaxSteps: number;
  11132. }
  11133. /**
  11134. * The null engine class provides support for headless version of babylon.js.
  11135. * This can be used in server side scenario or for testing purposes
  11136. */
  11137. class NullEngine extends Engine {
  11138. private _options;
  11139. /**
  11140. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11141. */
  11142. isDeterministicLockStep(): boolean;
  11143. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11144. getLockstepMaxSteps(): number;
  11145. /**
  11146. * Sets hardware scaling, used to save performance if needed
  11147. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11148. */
  11149. getHardwareScalingLevel(): number;
  11150. constructor(options?: NullEngineOptions);
  11151. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11152. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11153. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11154. getRenderWidth(useScreen?: boolean): number;
  11155. getRenderHeight(useScreen?: boolean): number;
  11156. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11157. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11158. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11159. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11160. bindSamplers(effect: Effect): void;
  11161. enableEffect(effect: Effect): void;
  11162. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11163. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11164. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11165. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11166. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11167. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11168. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11169. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11170. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11171. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11172. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11173. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11174. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11175. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11176. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11177. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11178. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11179. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11180. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11181. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11182. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11183. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11184. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11185. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11186. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11187. bindBuffers(vertexBuffers: {
  11188. [key: string]: VertexBuffer;
  11189. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11190. wipeCaches(bruteForce?: boolean): void;
  11191. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11192. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11193. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11194. /** @hidden */
  11195. _createTexture(): WebGLTexture;
  11196. /** @hidden */
  11197. _releaseTexture(texture: InternalTexture): void;
  11198. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  11199. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11200. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11201. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11202. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11203. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11204. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11205. /**
  11206. * @hidden
  11207. * Get the current error code of the webGL context
  11208. * @returns the error code
  11209. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11210. */
  11211. getError(): number;
  11212. /** @hidden */
  11213. _getUnpackAlignement(): number;
  11214. /** @hidden */
  11215. _unpackFlipY(value: boolean): void;
  11216. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11217. /**
  11218. * Updates a dynamic vertex buffer.
  11219. * @param vertexBuffer the vertex buffer to update
  11220. * @param data the data used to update the vertex buffer
  11221. * @param byteOffset the byte offset of the data (optional)
  11222. * @param byteLength the byte length of the data (optional)
  11223. */
  11224. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11225. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11226. /** @hidden */
  11227. _bindTexture(channel: number, texture: InternalTexture): void;
  11228. /** @hidden */
  11229. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11230. releaseEffects(): void;
  11231. displayLoadingUI(): void;
  11232. hideLoadingUI(): void;
  11233. /** @hidden */
  11234. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11235. /** @hidden */
  11236. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11237. /** @hidden */
  11238. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11239. /** @hidden */
  11240. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11241. }
  11242. }
  11243. interface WebGLRenderingContext {
  11244. readonly RASTERIZER_DISCARD: number;
  11245. readonly DEPTH_COMPONENT24: number;
  11246. readonly TEXTURE_3D: number;
  11247. readonly TEXTURE_2D_ARRAY: number;
  11248. readonly TEXTURE_COMPARE_FUNC: number;
  11249. readonly TEXTURE_COMPARE_MODE: number;
  11250. readonly COMPARE_REF_TO_TEXTURE: number;
  11251. readonly TEXTURE_WRAP_R: number;
  11252. readonly HALF_FLOAT: number;
  11253. readonly RGB8: number;
  11254. readonly RED_INTEGER: number;
  11255. readonly RG_INTEGER: number;
  11256. readonly RGB_INTEGER: number;
  11257. readonly RGBA_INTEGER: number;
  11258. readonly R8_SNORM: number;
  11259. readonly RG8_SNORM: number;
  11260. readonly RGB8_SNORM: number;
  11261. readonly RGBA8_SNORM: number;
  11262. readonly R8I: number;
  11263. readonly RG8I: number;
  11264. readonly RGB8I: number;
  11265. readonly RGBA8I: number;
  11266. readonly R8UI: number;
  11267. readonly RG8UI: number;
  11268. readonly RGB8UI: number;
  11269. readonly RGBA8UI: number;
  11270. readonly R16I: number;
  11271. readonly RG16I: number;
  11272. readonly RGB16I: number;
  11273. readonly RGBA16I: number;
  11274. readonly R16UI: number;
  11275. readonly RG16UI: number;
  11276. readonly RGB16UI: number;
  11277. readonly RGBA16UI: number;
  11278. readonly R32I: number;
  11279. readonly RG32I: number;
  11280. readonly RGB32I: number;
  11281. readonly RGBA32I: number;
  11282. readonly R32UI: number;
  11283. readonly RG32UI: number;
  11284. readonly RGB32UI: number;
  11285. readonly RGBA32UI: number;
  11286. readonly RGB10_A2UI: number;
  11287. readonly R11F_G11F_B10F: number;
  11288. readonly RGB9_E5: number;
  11289. readonly RGB10_A2: number;
  11290. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  11291. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  11292. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  11293. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  11294. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  11295. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  11296. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
  11297. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  11298. readonly TRANSFORM_FEEDBACK: number;
  11299. readonly INTERLEAVED_ATTRIBS: number;
  11300. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  11301. createTransformFeedback(): WebGLTransformFeedback;
  11302. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  11303. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  11304. beginTransformFeedback(primitiveMode: number): void;
  11305. endTransformFeedback(): void;
  11306. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  11307. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11308. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11309. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11310. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  11311. }
  11312. interface ImageBitmap {
  11313. readonly width: number;
  11314. readonly height: number;
  11315. close(): void;
  11316. }
  11317. interface WebGLQuery extends WebGLObject {
  11318. }
  11319. declare var WebGLQuery: {
  11320. prototype: WebGLQuery;
  11321. new (): WebGLQuery;
  11322. };
  11323. interface WebGLSampler extends WebGLObject {
  11324. }
  11325. declare var WebGLSampler: {
  11326. prototype: WebGLSampler;
  11327. new (): WebGLSampler;
  11328. };
  11329. interface WebGLSync extends WebGLObject {
  11330. }
  11331. declare var WebGLSync: {
  11332. prototype: WebGLSync;
  11333. new (): WebGLSync;
  11334. };
  11335. interface WebGLTransformFeedback extends WebGLObject {
  11336. }
  11337. declare var WebGLTransformFeedback: {
  11338. prototype: WebGLTransformFeedback;
  11339. new (): WebGLTransformFeedback;
  11340. };
  11341. interface WebGLVertexArrayObject extends WebGLObject {
  11342. }
  11343. declare var WebGLVertexArrayObject: {
  11344. prototype: WebGLVertexArrayObject;
  11345. new (): WebGLVertexArrayObject;
  11346. };
  11347. declare module BABYLON {
  11348. /**
  11349. * Class used to store bounding box information
  11350. */
  11351. class BoundingBox implements ICullable {
  11352. /**
  11353. * Gets the 8 vectors representing the bounding box in local space
  11354. */
  11355. vectors: Vector3[];
  11356. /**
  11357. * Gets the center of the bounding box in local space
  11358. */
  11359. center: Vector3;
  11360. /**
  11361. * Gets the center of the bounding box in world space
  11362. */
  11363. centerWorld: Vector3;
  11364. /**
  11365. * Gets the extend size in local space
  11366. */
  11367. extendSize: Vector3;
  11368. /**
  11369. * Gets the extend size in world space
  11370. */
  11371. extendSizeWorld: Vector3;
  11372. /**
  11373. * Gets the OBB (object bounding box) directions
  11374. */
  11375. directions: Vector3[];
  11376. /**
  11377. * Gets the 8 vectors representing the bounding box in world space
  11378. */
  11379. vectorsWorld: Vector3[];
  11380. /**
  11381. * Gets the minimum vector in world space
  11382. */
  11383. minimumWorld: Vector3;
  11384. /**
  11385. * Gets the maximum vector in world space
  11386. */
  11387. maximumWorld: Vector3;
  11388. /**
  11389. * Gets the minimum vector in local space
  11390. */
  11391. minimum: Vector3;
  11392. /**
  11393. * Gets the maximum vector in local space
  11394. */
  11395. maximum: Vector3;
  11396. private _worldMatrix;
  11397. /**
  11398. * @hidden
  11399. */
  11400. _tag: number;
  11401. /**
  11402. * Creates a new bounding box
  11403. * @param min defines the minimum vector (in local space)
  11404. * @param max defines the maximum vector (in local space)
  11405. */
  11406. constructor(min: Vector3, max: Vector3);
  11407. /**
  11408. * Recreates the entire bounding box from scratch
  11409. * @param min defines the new minimum vector (in local space)
  11410. * @param max defines the new maximum vector (in local space)
  11411. */
  11412. reConstruct(min: Vector3, max: Vector3): void;
  11413. /**
  11414. * Scale the current bounding box by applying a scale factor
  11415. * @param factor defines the scale factor to apply
  11416. * @returns the current bounding box
  11417. */
  11418. scale(factor: number): BoundingBox;
  11419. /**
  11420. * Gets the world matrix of the bounding box
  11421. * @returns a matrix
  11422. */
  11423. getWorldMatrix(): Matrix;
  11424. /**
  11425. * Sets the world matrix stored in the bounding box
  11426. * @param matrix defines the matrix to store
  11427. * @returns current bounding box
  11428. */
  11429. setWorldMatrix(matrix: Matrix): BoundingBox;
  11430. /** @hidden */
  11431. _update(world: Matrix): void;
  11432. /**
  11433. * Tests if the bounding box is intersecting the frustum planes
  11434. * @param frustumPlanes defines the frustum planes to test
  11435. * @returns true if there is an intersection
  11436. */
  11437. isInFrustum(frustumPlanes: Plane[]): boolean;
  11438. /**
  11439. * Tests if the bounding box is entirely inside the frustum planes
  11440. * @param frustumPlanes defines the frustum planes to test
  11441. * @returns true if there is an inclusion
  11442. */
  11443. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11444. /**
  11445. * Tests if a point is inside the bounding box
  11446. * @param point defines the point to test
  11447. * @returns true if the point is inside the bounding box
  11448. */
  11449. intersectsPoint(point: Vector3): boolean;
  11450. /**
  11451. * Tests if the bounding box intersects with a bounding sphere
  11452. * @param sphere defines the sphere to test
  11453. * @returns true if there is an intersection
  11454. */
  11455. intersectsSphere(sphere: BoundingSphere): boolean;
  11456. /**
  11457. * Tests if the bounding box intersects with a box defined by a min and max vectors
  11458. * @param min defines the min vector to use
  11459. * @param max defines the max vector to use
  11460. * @returns true if there is an intersection
  11461. */
  11462. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  11463. /**
  11464. * Tests if two bounding boxes are intersections
  11465. * @param box0 defines the first box to test
  11466. * @param box1 defines the second box to test
  11467. * @returns true if there is an intersection
  11468. */
  11469. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  11470. /**
  11471. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  11472. * @param minPoint defines the minimum vector of the bounding box
  11473. * @param maxPoint defines the maximum vector of the bounding box
  11474. * @param sphereCenter defines the sphere center
  11475. * @param sphereRadius defines the sphere radius
  11476. * @returns true if there is an intersection
  11477. */
  11478. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  11479. /**
  11480. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  11481. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  11482. * @param frustumPlanes defines the frustum planes to test
  11483. * @return true if there is an inclusion
  11484. */
  11485. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  11486. /**
  11487. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  11488. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  11489. * @param frustumPlanes defines the frustum planes to test
  11490. * @return true if there is an intersection
  11491. */
  11492. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  11493. }
  11494. }
  11495. declare module BABYLON {
  11496. /**
  11497. * Interface for cullable objects
  11498. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  11499. */
  11500. interface ICullable {
  11501. /**
  11502. * Checks if the object or part of the object is in the frustum
  11503. * @param frustumPlanes Camera near/planes
  11504. * @returns true if the object is in frustum otherwise false
  11505. */
  11506. isInFrustum(frustumPlanes: Plane[]): boolean;
  11507. /**
  11508. * Checks if a cullable object (mesh...) is in the camera frustum
  11509. * Unlike isInFrustum this cheks the full bounding box
  11510. * @param frustumPlanes Camera near/planes
  11511. * @returns true if the object is in frustum otherwise false
  11512. */
  11513. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11514. }
  11515. /**
  11516. * Info for a bounding data of a mesh
  11517. */
  11518. class BoundingInfo implements ICullable {
  11519. /**
  11520. * Bounding box for the mesh
  11521. */
  11522. boundingBox: BoundingBox;
  11523. /**
  11524. * Bounding sphere for the mesh
  11525. */
  11526. boundingSphere: BoundingSphere;
  11527. private _isLocked;
  11528. /**
  11529. * Constructs bounding info
  11530. * @param minimum min vector of the bounding box/sphere
  11531. * @param maximum max vector of the bounding box/sphere
  11532. */
  11533. constructor(minimum: Vector3, maximum: Vector3);
  11534. /**
  11535. * min vector of the bounding box/sphere
  11536. */
  11537. readonly minimum: Vector3;
  11538. /**
  11539. * max vector of the bounding box/sphere
  11540. */
  11541. readonly maximum: Vector3;
  11542. /**
  11543. * If the info is locked and won't be updated to avoid perf overhead
  11544. */
  11545. isLocked: boolean;
  11546. /**
  11547. * Updates the boudning sphere and box
  11548. * @param world world matrix to be used to update
  11549. */
  11550. update(world: Matrix): void;
  11551. /**
  11552. * Recreate the bounding info to be centered around a specific point given a specific extend.
  11553. * @param center New center of the bounding info
  11554. * @param extend New extend of the bounding info
  11555. * @returns the current bounding info
  11556. */
  11557. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  11558. /**
  11559. * Scale the current bounding info by applying a scale factor
  11560. * @param factor defines the scale factor to apply
  11561. * @returns the current bounding info
  11562. */
  11563. scale(factor: number): BoundingInfo;
  11564. /**
  11565. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  11566. * @param frustumPlanes defines the frustum to test
  11567. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  11568. * @returns true if the bounding info is in the frustum planes
  11569. */
  11570. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  11571. /**
  11572. * Gets the world distance between the min and max points of the bounding box
  11573. */
  11574. readonly diagonalLength: number;
  11575. /**
  11576. * Checks if a cullable object (mesh...) is in the camera frustum
  11577. * Unlike isInFrustum this cheks the full bounding box
  11578. * @param frustumPlanes Camera near/planes
  11579. * @returns true if the object is in frustum otherwise false
  11580. */
  11581. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11582. /** @hidden */
  11583. _checkCollision(collider: Collider): boolean;
  11584. /**
  11585. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  11586. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  11587. * @param point the point to check intersection with
  11588. * @returns if the point intersects
  11589. */
  11590. intersectsPoint(point: Vector3): boolean;
  11591. /**
  11592. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  11593. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  11594. * @param boundingInfo the bounding info to check intersection with
  11595. * @param precise if the intersection should be done using OBB
  11596. * @returns if the bounding info intersects
  11597. */
  11598. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  11599. }
  11600. }
  11601. declare module BABYLON {
  11602. /**
  11603. * Class used to store bounding sphere information
  11604. */
  11605. class BoundingSphere {
  11606. /**
  11607. * Gets the center of the bounding sphere in local space
  11608. */
  11609. center: Vector3;
  11610. /**
  11611. * Radius of the bounding sphere in local space
  11612. */
  11613. radius: number;
  11614. /**
  11615. * Gets the center of the bounding sphere in world space
  11616. */
  11617. centerWorld: Vector3;
  11618. /**
  11619. * Radius of the bounding sphere in world space
  11620. */
  11621. radiusWorld: number;
  11622. /**
  11623. * Gets the minimum vector in local space
  11624. */
  11625. minimum: Vector3;
  11626. /**
  11627. * Gets the maximum vector in local space
  11628. */
  11629. maximum: Vector3;
  11630. /**
  11631. * Creates a new bounding sphere
  11632. * @param min defines the minimum vector (in local space)
  11633. * @param max defines the maximum vector (in local space)
  11634. */
  11635. constructor(min: Vector3, max: Vector3);
  11636. /**
  11637. * Recreates the entire bounding sphere from scratch
  11638. * @param min defines the new minimum vector (in local space)
  11639. * @param max defines the new maximum vector (in local space)
  11640. */
  11641. reConstruct(min: Vector3, max: Vector3): void;
  11642. /**
  11643. * Scale the current bounding sphere by applying a scale factor
  11644. * @param factor defines the scale factor to apply
  11645. * @returns the current bounding box
  11646. */
  11647. scale(factor: number): BoundingSphere;
  11648. /** @hidden */
  11649. _update(world: Matrix): void;
  11650. /**
  11651. * Tests if the bounding sphere is intersecting the frustum planes
  11652. * @param frustumPlanes defines the frustum planes to test
  11653. * @returns true if there is an intersection
  11654. */
  11655. isInFrustum(frustumPlanes: Plane[]): boolean;
  11656. /**
  11657. * Tests if a point is inside the bounding sphere
  11658. * @param point defines the point to test
  11659. * @returns true if the point is inside the bounding sphere
  11660. */
  11661. intersectsPoint(point: Vector3): boolean;
  11662. /**
  11663. * Checks if two sphere intersct
  11664. * @param sphere0 sphere 0
  11665. * @param sphere1 sphere 1
  11666. * @returns true if the speres intersect
  11667. */
  11668. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  11669. }
  11670. }
  11671. declare module BABYLON {
  11672. /**
  11673. * Class representing a ray with position and direction
  11674. */
  11675. class Ray {
  11676. /** origin point */
  11677. origin: Vector3;
  11678. /** direction */
  11679. direction: Vector3;
  11680. /** length of the ray */
  11681. length: number;
  11682. private _edge1;
  11683. private _edge2;
  11684. private _pvec;
  11685. private _tvec;
  11686. private _qvec;
  11687. private _tmpRay;
  11688. /**
  11689. * Creates a new ray
  11690. * @param origin origin point
  11691. * @param direction direction
  11692. * @param length length of the ray
  11693. */
  11694. constructor(
  11695. /** origin point */
  11696. origin: Vector3,
  11697. /** direction */
  11698. direction: Vector3,
  11699. /** length of the ray */
  11700. length?: number);
  11701. /**
  11702. * Checks if the ray intersects a box
  11703. * @param minimum bound of the box
  11704. * @param maximum bound of the box
  11705. * @returns if the box was hit
  11706. */
  11707. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  11708. /**
  11709. * Checks if the ray intersects a box
  11710. * @param box the bounding box to check
  11711. * @returns if the box was hit
  11712. */
  11713. intersectsBox(box: BoundingBox): boolean;
  11714. /**
  11715. * If the ray hits a sphere
  11716. * @param sphere the bounding sphere to check
  11717. * @returns true if it hits the sphere
  11718. */
  11719. intersectsSphere(sphere: BoundingSphere): boolean;
  11720. /**
  11721. * If the ray hits a triange
  11722. * @param vertex0 triangle vertex
  11723. * @param vertex1 triangle vertex
  11724. * @param vertex2 triangle vertex
  11725. * @returns intersection information if hit
  11726. */
  11727. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  11728. /**
  11729. * Checks if ray intersects a plane
  11730. * @param plane the plane to check
  11731. * @returns the distance away it was hit
  11732. */
  11733. intersectsPlane(plane: Plane): Nullable<number>;
  11734. /**
  11735. * Checks if ray intersects a mesh
  11736. * @param mesh the mesh to check
  11737. * @param fastCheck if only the bounding box should checked
  11738. * @returns picking info of the intersecton
  11739. */
  11740. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  11741. /**
  11742. * Checks if ray intersects a mesh
  11743. * @param meshes the meshes to check
  11744. * @param fastCheck if only the bounding box should checked
  11745. * @param results array to store result in
  11746. * @returns Array of picking infos
  11747. */
  11748. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11749. private _comparePickingInfo;
  11750. private static smallnum;
  11751. private static rayl;
  11752. /**
  11753. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11754. * @param sega the first point of the segment to test the intersection against
  11755. * @param segb the second point of the segment to test the intersection against
  11756. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11757. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11758. */
  11759. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  11760. /**
  11761. * Update the ray from viewport position
  11762. * @param x position
  11763. * @param y y position
  11764. * @param viewportWidth viewport width
  11765. * @param viewportHeight viewport height
  11766. * @param world world matrix
  11767. * @param view view matrix
  11768. * @param projection projection matrix
  11769. * @returns this ray updated
  11770. */
  11771. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  11772. /**
  11773. * Creates a ray with origin and direction of 0,0,0
  11774. * @returns the new ray
  11775. */
  11776. static Zero(): Ray;
  11777. /**
  11778. * Creates a new ray from screen space and viewport
  11779. * @param x position
  11780. * @param y y position
  11781. * @param viewportWidth viewport width
  11782. * @param viewportHeight viewport height
  11783. * @param world world matrix
  11784. * @param view view matrix
  11785. * @param projection projection matrix
  11786. * @returns new ray
  11787. */
  11788. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  11789. /**
  11790. * 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
  11791. * transformed to the given world matrix.
  11792. * @param origin The origin point
  11793. * @param end The end point
  11794. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11795. * @returns the new ray
  11796. */
  11797. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  11798. /**
  11799. * Transforms a ray by a matrix
  11800. * @param ray ray to transform
  11801. * @param matrix matrix to apply
  11802. * @returns the resulting new ray
  11803. */
  11804. static Transform(ray: Ray, matrix: Matrix): Ray;
  11805. /**
  11806. * Transforms a ray by a matrix
  11807. * @param ray ray to transform
  11808. * @param matrix matrix to apply
  11809. * @param result ray to store result in
  11810. */
  11811. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  11812. }
  11813. }
  11814. declare module BABYLON {
  11815. /**
  11816. * Gather the list of keyboard event types as constants.
  11817. */
  11818. class KeyboardEventTypes {
  11819. /**
  11820. * The keydown event is fired when a key becomes active (pressed).
  11821. */
  11822. static readonly KEYDOWN: number;
  11823. /**
  11824. * The keyup event is fired when a key has been released.
  11825. */
  11826. static readonly KEYUP: number;
  11827. }
  11828. /**
  11829. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11830. */
  11831. class KeyboardInfo {
  11832. /**
  11833. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11834. */
  11835. type: number;
  11836. /**
  11837. * Defines the related dom event
  11838. */
  11839. event: KeyboardEvent;
  11840. /**
  11841. * Instantiates a new keyboard info.
  11842. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11843. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11844. * @param event Defines the related dom event
  11845. */
  11846. constructor(
  11847. /**
  11848. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11849. */
  11850. type: number,
  11851. /**
  11852. * Defines the related dom event
  11853. */
  11854. event: KeyboardEvent);
  11855. }
  11856. /**
  11857. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11858. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  11859. */
  11860. class KeyboardInfoPre extends KeyboardInfo {
  11861. /**
  11862. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11863. */
  11864. type: number;
  11865. /**
  11866. * Defines the related dom event
  11867. */
  11868. event: KeyboardEvent;
  11869. /**
  11870. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  11871. */
  11872. skipOnPointerObservable: boolean;
  11873. /**
  11874. * Instantiates a new keyboard pre info.
  11875. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11876. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11877. * @param event Defines the related dom event
  11878. */
  11879. constructor(
  11880. /**
  11881. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11882. */
  11883. type: number,
  11884. /**
  11885. * Defines the related dom event
  11886. */
  11887. event: KeyboardEvent);
  11888. }
  11889. }
  11890. declare module BABYLON {
  11891. /**
  11892. * Gather the list of pointer event types as constants.
  11893. */
  11894. class PointerEventTypes {
  11895. /**
  11896. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11897. */
  11898. static readonly POINTERDOWN: number;
  11899. /**
  11900. * The pointerup event is fired when a pointer is no longer active.
  11901. */
  11902. static readonly POINTERUP: number;
  11903. /**
  11904. * The pointermove event is fired when a pointer changes coordinates.
  11905. */
  11906. static readonly POINTERMOVE: number;
  11907. /**
  11908. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11909. */
  11910. static readonly POINTERWHEEL: number;
  11911. /**
  11912. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11913. */
  11914. static readonly POINTERPICK: number;
  11915. /**
  11916. * The pointertap event is fired when a the object has been touched and released without drag.
  11917. */
  11918. static readonly POINTERTAP: number;
  11919. /**
  11920. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11921. */
  11922. static readonly POINTERDOUBLETAP: number;
  11923. }
  11924. /**
  11925. * Base class of pointer info types.
  11926. */
  11927. class PointerInfoBase {
  11928. /**
  11929. * Defines the type of event (BABYLON.PointerEventTypes)
  11930. */
  11931. type: number;
  11932. /**
  11933. * Defines the related dom event
  11934. */
  11935. event: PointerEvent | MouseWheelEvent;
  11936. /**
  11937. * Instantiates the base class of pointers info.
  11938. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11939. * @param event Defines the related dom event
  11940. */
  11941. constructor(
  11942. /**
  11943. * Defines the type of event (BABYLON.PointerEventTypes)
  11944. */
  11945. type: number,
  11946. /**
  11947. * Defines the related dom event
  11948. */
  11949. event: PointerEvent | MouseWheelEvent);
  11950. }
  11951. /**
  11952. * This class is used to store pointer related info for the onPrePointerObservable event.
  11953. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11954. */
  11955. class PointerInfoPre extends PointerInfoBase {
  11956. /**
  11957. * Ray from a pointer if availible (eg. 6dof controller)
  11958. */
  11959. ray: Nullable<Ray>;
  11960. /**
  11961. * Defines the local position of the pointer on the canvas.
  11962. */
  11963. localPosition: Vector2;
  11964. /**
  11965. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11966. */
  11967. skipOnPointerObservable: boolean;
  11968. /**
  11969. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11970. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11971. * @param event Defines the related dom event
  11972. * @param localX Defines the local x coordinates of the pointer when the event occured
  11973. * @param localY Defines the local y coordinates of the pointer when the event occured
  11974. */
  11975. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11976. }
  11977. /**
  11978. * This type contains all the data related to a pointer event in Babylon.js.
  11979. * 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.
  11980. */
  11981. class PointerInfo extends PointerInfoBase {
  11982. /**
  11983. * Defines the picking info associated to the info (if any)\
  11984. */
  11985. pickInfo: Nullable<PickingInfo>;
  11986. /**
  11987. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11988. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11989. * @param event Defines the related dom event
  11990. * @param pickInfo Defines the picking info associated to the info (if any)\
  11991. */
  11992. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11993. /**
  11994. * Defines the picking info associated to the info (if any)\
  11995. */
  11996. pickInfo: Nullable<PickingInfo>);
  11997. }
  11998. }
  11999. declare module BABYLON {
  12000. /**
  12001. * Represents a gamepad control stick position
  12002. */
  12003. class StickValues {
  12004. /**
  12005. * The x component of the control stick
  12006. */
  12007. x: number;
  12008. /**
  12009. * The y component of the control stick
  12010. */
  12011. y: number;
  12012. /**
  12013. * Initializes the gamepad x and y control stick values
  12014. * @param x The x component of the gamepad control stick value
  12015. * @param y The y component of the gamepad control stick value
  12016. */
  12017. constructor(
  12018. /**
  12019. * The x component of the control stick
  12020. */
  12021. x: number,
  12022. /**
  12023. * The y component of the control stick
  12024. */
  12025. y: number);
  12026. }
  12027. /**
  12028. * An interface which manages callbacks for gamepad button changes
  12029. */
  12030. interface GamepadButtonChanges {
  12031. /**
  12032. * Called when a gamepad has been changed
  12033. */
  12034. changed: boolean;
  12035. /**
  12036. * Called when a gamepad press event has been triggered
  12037. */
  12038. pressChanged: boolean;
  12039. /**
  12040. * Called when a touch event has been triggered
  12041. */
  12042. touchChanged: boolean;
  12043. /**
  12044. * Called when a value has changed
  12045. */
  12046. valueChanged: boolean;
  12047. }
  12048. /**
  12049. * Represents a gamepad
  12050. */
  12051. class Gamepad {
  12052. /**
  12053. * The id of the gamepad
  12054. */
  12055. id: string;
  12056. /**
  12057. * The index of the gamepad
  12058. */
  12059. index: number;
  12060. /**
  12061. * The browser gamepad
  12062. */
  12063. browserGamepad: any;
  12064. /**
  12065. * Specifies what type of gamepad this represents
  12066. */
  12067. type: number;
  12068. private _leftStick;
  12069. private _rightStick;
  12070. /** @hidden */
  12071. _isConnected: boolean;
  12072. private _leftStickAxisX;
  12073. private _leftStickAxisY;
  12074. private _rightStickAxisX;
  12075. private _rightStickAxisY;
  12076. /**
  12077. * Triggered when the left control stick has been changed
  12078. */
  12079. private _onleftstickchanged;
  12080. /**
  12081. * Triggered when the right control stick has been changed
  12082. */
  12083. private _onrightstickchanged;
  12084. /**
  12085. * Represents a gamepad controller
  12086. */
  12087. static GAMEPAD: number;
  12088. /**
  12089. * Represents a generic controller
  12090. */
  12091. static GENERIC: number;
  12092. /**
  12093. * Represents an XBox controller
  12094. */
  12095. static XBOX: number;
  12096. /**
  12097. * Represents a pose-enabled controller
  12098. */
  12099. static POSE_ENABLED: number;
  12100. /**
  12101. * Specifies whether the left control stick should be Y-inverted
  12102. */
  12103. protected _invertLeftStickY: boolean;
  12104. /**
  12105. * Specifies if the gamepad has been connected
  12106. */
  12107. readonly isConnected: boolean;
  12108. /**
  12109. * Initializes the gamepad
  12110. * @param id The id of the gamepad
  12111. * @param index The index of the gamepad
  12112. * @param browserGamepad The browser gamepad
  12113. * @param leftStickX The x component of the left joystick
  12114. * @param leftStickY The y component of the left joystick
  12115. * @param rightStickX The x component of the right joystick
  12116. * @param rightStickY The y component of the right joystick
  12117. */
  12118. constructor(
  12119. /**
  12120. * The id of the gamepad
  12121. */
  12122. id: string,
  12123. /**
  12124. * The index of the gamepad
  12125. */
  12126. index: number,
  12127. /**
  12128. * The browser gamepad
  12129. */
  12130. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12131. /**
  12132. * Callback triggered when the left joystick has changed
  12133. * @param callback
  12134. */
  12135. onleftstickchanged(callback: (values: StickValues) => void): void;
  12136. /**
  12137. * Callback triggered when the right joystick has changed
  12138. * @param callback
  12139. */
  12140. onrightstickchanged(callback: (values: StickValues) => void): void;
  12141. /**
  12142. * Gets the left joystick
  12143. */
  12144. /**
  12145. * Sets the left joystick values
  12146. */
  12147. leftStick: StickValues;
  12148. /**
  12149. * Gets the right joystick
  12150. */
  12151. /**
  12152. * Sets the right joystick value
  12153. */
  12154. rightStick: StickValues;
  12155. /**
  12156. * Updates the gamepad joystick positions
  12157. */
  12158. update(): void;
  12159. /**
  12160. * Disposes the gamepad
  12161. */
  12162. dispose(): void;
  12163. }
  12164. /**
  12165. * Represents a generic gamepad
  12166. */
  12167. class GenericPad extends Gamepad {
  12168. private _buttons;
  12169. private _onbuttondown;
  12170. private _onbuttonup;
  12171. /**
  12172. * Observable triggered when a button has been pressed
  12173. */
  12174. onButtonDownObservable: Observable<number>;
  12175. /**
  12176. * Observable triggered when a button has been released
  12177. */
  12178. onButtonUpObservable: Observable<number>;
  12179. /**
  12180. * Callback triggered when a button has been pressed
  12181. * @param callback Called when a button has been pressed
  12182. */
  12183. onbuttondown(callback: (buttonPressed: number) => void): void;
  12184. /**
  12185. * Callback triggered when a button has been released
  12186. * @param callback Called when a button has been released
  12187. */
  12188. onbuttonup(callback: (buttonReleased: number) => void): void;
  12189. /**
  12190. * Initializes the generic gamepad
  12191. * @param id The id of the generic gamepad
  12192. * @param index The index of the generic gamepad
  12193. * @param browserGamepad The browser gamepad
  12194. */
  12195. constructor(id: string, index: number, browserGamepad: any);
  12196. private _setButtonValue;
  12197. /**
  12198. * Updates the generic gamepad
  12199. */
  12200. update(): void;
  12201. /**
  12202. * Disposes the generic gamepad
  12203. */
  12204. dispose(): void;
  12205. }
  12206. }
  12207. declare module BABYLON {
  12208. /**
  12209. * Manager for handling gamepads
  12210. */
  12211. class GamepadManager {
  12212. private _scene?;
  12213. private _babylonGamepads;
  12214. private _oneGamepadConnected;
  12215. /** @hidden */
  12216. _isMonitoring: boolean;
  12217. private _gamepadEventSupported;
  12218. private _gamepadSupport;
  12219. /**
  12220. * observable to be triggered when the gamepad controller has been connected
  12221. */
  12222. onGamepadConnectedObservable: Observable<Gamepad>;
  12223. /**
  12224. * observable to be triggered when the gamepad controller has been disconnected
  12225. */
  12226. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12227. private _onGamepadConnectedEvent;
  12228. private _onGamepadDisconnectedEvent;
  12229. /**
  12230. * Initializes the gamepad manager
  12231. * @param _scene BabylonJS scene
  12232. */
  12233. constructor(_scene?: Scene | undefined);
  12234. /**
  12235. * The gamepads in the game pad manager
  12236. */
  12237. readonly gamepads: Gamepad[];
  12238. /**
  12239. * Get the gamepad controllers based on type
  12240. * @param type The type of gamepad controller
  12241. * @returns Nullable gamepad
  12242. */
  12243. getGamepadByType(type?: number): Nullable<Gamepad>;
  12244. /**
  12245. * Disposes the gamepad manager
  12246. */
  12247. dispose(): void;
  12248. private _addNewGamepad;
  12249. private _startMonitoringGamepads;
  12250. private _stopMonitoringGamepads;
  12251. /** @hidden */
  12252. _checkGamepadsStatus(): void;
  12253. private _updateGamepadObjects;
  12254. }
  12255. }
  12256. declare module BABYLON {
  12257. interface Scene {
  12258. /** @hidden */
  12259. _gamepadManager: Nullable<GamepadManager>;
  12260. /**
  12261. * Gets the gamepad manager associated with the scene
  12262. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12263. */
  12264. gamepadManager: GamepadManager;
  12265. }
  12266. /**
  12267. * Interface representing a free camera inputs manager
  12268. */
  12269. interface FreeCameraInputsManager {
  12270. /**
  12271. * Adds gamepad input support to the FreeCameraInputsManager.
  12272. * @returns the FreeCameraInputsManager
  12273. */
  12274. addGamepad(): FreeCameraInputsManager;
  12275. }
  12276. /**
  12277. * Interface representing an arc rotate camera inputs manager
  12278. */
  12279. interface ArcRotateCameraInputsManager {
  12280. /**
  12281. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12282. * @returns the camera inputs manager
  12283. */
  12284. addGamepad(): ArcRotateCameraInputsManager;
  12285. }
  12286. /**
  12287. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12288. */
  12289. class GamepadSystemSceneComponent implements ISceneComponent {
  12290. /**
  12291. * The component name helpfull to identify the component in the list of scene components.
  12292. */
  12293. readonly name: string;
  12294. /**
  12295. * The scene the component belongs to.
  12296. */
  12297. scene: Scene;
  12298. /**
  12299. * Creates a new instance of the component for the given scene
  12300. * @param scene Defines the scene to register the component in
  12301. */
  12302. constructor(scene: Scene);
  12303. /**
  12304. * Registers the component in a given scene
  12305. */
  12306. register(): void;
  12307. /**
  12308. * Rebuilds the elements related to this component in case of
  12309. * context lost for instance.
  12310. */
  12311. rebuild(): void;
  12312. /**
  12313. * Disposes the component and the associated ressources
  12314. */
  12315. dispose(): void;
  12316. private _beforeCameraUpdate;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /**
  12321. * Defines supported buttons for XBox360 compatible gamepads
  12322. */
  12323. enum Xbox360Button {
  12324. /** A */
  12325. A = 0,
  12326. /** B */
  12327. B = 1,
  12328. /** X */
  12329. X = 2,
  12330. /** Y */
  12331. Y = 3,
  12332. /** Start */
  12333. Start = 4,
  12334. /** Back */
  12335. Back = 5,
  12336. /** Left button */
  12337. LB = 6,
  12338. /** Right button */
  12339. RB = 7,
  12340. /** Left stick */
  12341. LeftStick = 8,
  12342. /** Right stick */
  12343. RightStick = 9
  12344. }
  12345. /** Defines values for XBox360 DPad */
  12346. enum Xbox360Dpad {
  12347. /** Up */
  12348. Up = 0,
  12349. /** Down */
  12350. Down = 1,
  12351. /** Left */
  12352. Left = 2,
  12353. /** Right */
  12354. Right = 3
  12355. }
  12356. /**
  12357. * Defines a XBox360 gamepad
  12358. */
  12359. class Xbox360Pad extends Gamepad {
  12360. private _leftTrigger;
  12361. private _rightTrigger;
  12362. private _onlefttriggerchanged;
  12363. private _onrighttriggerchanged;
  12364. private _onbuttondown;
  12365. private _onbuttonup;
  12366. private _ondpaddown;
  12367. private _ondpadup;
  12368. /** Observable raised when a button is pressed */
  12369. onButtonDownObservable: Observable<Xbox360Button>;
  12370. /** Observable raised when a button is released */
  12371. onButtonUpObservable: Observable<Xbox360Button>;
  12372. /** Observable raised when a pad is pressed */
  12373. onPadDownObservable: Observable<Xbox360Dpad>;
  12374. /** Observable raised when a pad is released */
  12375. onPadUpObservable: Observable<Xbox360Dpad>;
  12376. private _buttonA;
  12377. private _buttonB;
  12378. private _buttonX;
  12379. private _buttonY;
  12380. private _buttonBack;
  12381. private _buttonStart;
  12382. private _buttonLB;
  12383. private _buttonRB;
  12384. private _buttonLeftStick;
  12385. private _buttonRightStick;
  12386. private _dPadUp;
  12387. private _dPadDown;
  12388. private _dPadLeft;
  12389. private _dPadRight;
  12390. private _isXboxOnePad;
  12391. /**
  12392. * Creates a new XBox360 gamepad object
  12393. * @param id defines the id of this gamepad
  12394. * @param index defines its index
  12395. * @param gamepad defines the internal HTML gamepad object
  12396. * @param xboxOne defines if it is a XBox One gamepad
  12397. */
  12398. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12399. /**
  12400. * Defines the callback to call when left trigger is pressed
  12401. * @param callback defines the callback to use
  12402. */
  12403. onlefttriggerchanged(callback: (value: number) => void): void;
  12404. /**
  12405. * Defines the callback to call when right trigger is pressed
  12406. * @param callback defines the callback to use
  12407. */
  12408. onrighttriggerchanged(callback: (value: number) => void): void;
  12409. /**
  12410. * Gets the left trigger value
  12411. */
  12412. /**
  12413. * Sets the left trigger value
  12414. */
  12415. leftTrigger: number;
  12416. /**
  12417. * Gets the right trigger value
  12418. */
  12419. /**
  12420. * Sets the right trigger value
  12421. */
  12422. rightTrigger: number;
  12423. /**
  12424. * Defines the callback to call when a button is pressed
  12425. * @param callback defines the callback to use
  12426. */
  12427. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12428. /**
  12429. * Defines the callback to call when a button is released
  12430. * @param callback defines the callback to use
  12431. */
  12432. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12433. /**
  12434. * Defines the callback to call when a pad is pressed
  12435. * @param callback defines the callback to use
  12436. */
  12437. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12438. /**
  12439. * Defines the callback to call when a pad is released
  12440. * @param callback defines the callback to use
  12441. */
  12442. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12443. private _setButtonValue;
  12444. private _setDPadValue;
  12445. /**
  12446. * Gets the value of the `A` button
  12447. */
  12448. /**
  12449. * Sets the value of the `A` button
  12450. */
  12451. buttonA: number;
  12452. /**
  12453. * Gets the value of the `B` button
  12454. */
  12455. /**
  12456. * Sets the value of the `B` button
  12457. */
  12458. buttonB: number;
  12459. /**
  12460. * Gets the value of the `X` button
  12461. */
  12462. /**
  12463. * Sets the value of the `X` button
  12464. */
  12465. buttonX: number;
  12466. /**
  12467. * Gets the value of the `Y` button
  12468. */
  12469. /**
  12470. * Sets the value of the `Y` button
  12471. */
  12472. buttonY: number;
  12473. /**
  12474. * Gets the value of the `Start` button
  12475. */
  12476. /**
  12477. * Sets the value of the `Start` button
  12478. */
  12479. buttonStart: number;
  12480. /**
  12481. * Gets the value of the `Back` button
  12482. */
  12483. /**
  12484. * Sets the value of the `Back` button
  12485. */
  12486. buttonBack: number;
  12487. /**
  12488. * Gets the value of the `Left` button
  12489. */
  12490. /**
  12491. * Sets the value of the `Left` button
  12492. */
  12493. buttonLB: number;
  12494. /**
  12495. * Gets the value of the `Right` button
  12496. */
  12497. /**
  12498. * Sets the value of the `Right` button
  12499. */
  12500. buttonRB: number;
  12501. /**
  12502. * Gets the value of the Left joystick
  12503. */
  12504. /**
  12505. * Sets the value of the Left joystick
  12506. */
  12507. buttonLeftStick: number;
  12508. /**
  12509. * Gets the value of the Right joystick
  12510. */
  12511. /**
  12512. * Sets the value of the Right joystick
  12513. */
  12514. buttonRightStick: number;
  12515. /**
  12516. * Gets the value of D-pad up
  12517. */
  12518. /**
  12519. * Sets the value of D-pad up
  12520. */
  12521. dPadUp: number;
  12522. /**
  12523. * Gets the value of D-pad down
  12524. */
  12525. /**
  12526. * Sets the value of D-pad down
  12527. */
  12528. dPadDown: number;
  12529. /**
  12530. * Gets the value of D-pad left
  12531. */
  12532. /**
  12533. * Sets the value of D-pad left
  12534. */
  12535. dPadLeft: number;
  12536. /**
  12537. * Gets the value of D-pad right
  12538. */
  12539. /**
  12540. * Sets the value of D-pad right
  12541. */
  12542. dPadRight: number;
  12543. /**
  12544. * Force the gamepad to synchronize with device values
  12545. */
  12546. update(): void;
  12547. /**
  12548. * Disposes the gamepad
  12549. */
  12550. dispose(): void;
  12551. }
  12552. }
  12553. declare module BABYLON {
  12554. /**
  12555. * Single axis drag gizmo
  12556. */
  12557. class AxisDragGizmo extends Gizmo {
  12558. /**
  12559. * Drag behavior responsible for the gizmos dragging interactions
  12560. */
  12561. dragBehavior: PointerDragBehavior;
  12562. private _pointerObserver;
  12563. /**
  12564. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12565. */
  12566. snapDistance: number;
  12567. /**
  12568. * Event that fires each time the gizmo snaps to a new location.
  12569. * * snapDistance is the the change in distance
  12570. */
  12571. onSnapObservable: Observable<{
  12572. snapDistance: number;
  12573. }>;
  12574. /**
  12575. * Creates an AxisDragGizmo
  12576. * @param gizmoLayer The utility layer the gizmo will be added to
  12577. * @param dragAxis The axis which the gizmo will be able to drag on
  12578. * @param color The color of the gizmo
  12579. */
  12580. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12581. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12582. /**
  12583. * Disposes of the gizmo
  12584. */
  12585. dispose(): void;
  12586. }
  12587. }
  12588. declare module BABYLON {
  12589. /**
  12590. * Single axis scale gizmo
  12591. */
  12592. class AxisScaleGizmo extends Gizmo {
  12593. private _coloredMaterial;
  12594. /**
  12595. * Drag behavior responsible for the gizmos dragging interactions
  12596. */
  12597. dragBehavior: PointerDragBehavior;
  12598. private _pointerObserver;
  12599. /**
  12600. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12601. */
  12602. snapDistance: number;
  12603. /**
  12604. * Event that fires each time the gizmo snaps to a new location.
  12605. * * snapDistance is the the change in distance
  12606. */
  12607. onSnapObservable: Observable<{
  12608. snapDistance: number;
  12609. }>;
  12610. /**
  12611. * If the scaling operation should be done on all axis (default: false)
  12612. */
  12613. uniformScaling: boolean;
  12614. /**
  12615. * Creates an AxisScaleGizmo
  12616. * @param gizmoLayer The utility layer the gizmo will be added to
  12617. * @param dragAxis The axis which the gizmo will be able to scale on
  12618. * @param color The color of the gizmo
  12619. */
  12620. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12621. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12622. /**
  12623. * Disposes of the gizmo
  12624. */
  12625. dispose(): void;
  12626. /**
  12627. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12628. * @param mesh The mesh to replace the default mesh of the gizmo
  12629. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12630. */
  12631. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12632. }
  12633. }
  12634. declare module BABYLON {
  12635. /**
  12636. * Bounding box gizmo
  12637. */
  12638. class BoundingBoxGizmo extends Gizmo {
  12639. private _lineBoundingBox;
  12640. private _rotateSpheresParent;
  12641. private _scaleBoxesParent;
  12642. private _boundingDimensions;
  12643. private _renderObserver;
  12644. private _pointerObserver;
  12645. private _scaleDragSpeed;
  12646. private _tmpQuaternion;
  12647. private _tmpVector;
  12648. private _tmpRotationMatrix;
  12649. /**
  12650. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  12651. */
  12652. ignoreChildren: boolean;
  12653. /**
  12654. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  12655. */
  12656. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12657. /**
  12658. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12659. */
  12660. rotationSphereSize: number;
  12661. /**
  12662. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12663. */
  12664. scaleBoxSize: number;
  12665. /**
  12666. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  12667. */
  12668. fixedDragMeshScreenSize: boolean;
  12669. /**
  12670. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12671. */
  12672. fixedDragMeshScreenSizeDistanceFactor: number;
  12673. /**
  12674. * Fired when a rotation sphere or scale box is dragged
  12675. */
  12676. onDragStartObservable: Observable<{}>;
  12677. /**
  12678. * Fired when a scale box is dragged
  12679. */
  12680. onScaleBoxDragObservable: Observable<{}>;
  12681. /**
  12682. * Fired when a scale box drag is ended
  12683. */
  12684. onScaleBoxDragEndObservable: Observable<{}>;
  12685. /**
  12686. * Fired when a rotation sphere is dragged
  12687. */
  12688. onRotationSphereDragObservable: Observable<{}>;
  12689. /**
  12690. * Fired when a rotation sphere drag is ended
  12691. */
  12692. onRotationSphereDragEndObservable: Observable<{}>;
  12693. /**
  12694. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  12695. */
  12696. scalePivot: Nullable<Vector3>;
  12697. private _anchorMesh;
  12698. private _existingMeshScale;
  12699. private static _PivotCached;
  12700. private static _OldPivotPoint;
  12701. private static _PivotTranslation;
  12702. private static _PivotTmpVector;
  12703. /** @hidden */
  12704. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  12705. /** @hidden */
  12706. static _RestorePivotPoint(mesh: AbstractMesh): void;
  12707. /**
  12708. * Creates an BoundingBoxGizmo
  12709. * @param gizmoLayer The utility layer the gizmo will be added to
  12710. * @param color The color of the gizmo
  12711. */
  12712. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12713. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12714. private _selectNode;
  12715. /**
  12716. * Updates the bounding box information for the Gizmo
  12717. */
  12718. updateBoundingBox(): void;
  12719. /**
  12720. * Enables rotation on the specified axis and disables rotation on the others
  12721. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  12722. */
  12723. setEnabledRotationAxis(axis: string): void;
  12724. /**
  12725. * Disposes of the gizmo
  12726. */
  12727. dispose(): void;
  12728. /**
  12729. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  12730. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  12731. * @returns the bounding box mesh with the passed in mesh as a child
  12732. */
  12733. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  12734. /**
  12735. * CustomMeshes are not supported by this gizmo
  12736. * @param mesh The mesh to replace the default mesh of the gizmo
  12737. */
  12738. setCustomMesh(mesh: Mesh): void;
  12739. }
  12740. }
  12741. declare module BABYLON {
  12742. /**
  12743. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  12744. */
  12745. class Gizmo implements IDisposable {
  12746. /** The utility layer the gizmo will be added to */
  12747. gizmoLayer: UtilityLayerRenderer;
  12748. /**
  12749. * The root mesh of the gizmo
  12750. */
  12751. protected _rootMesh: Mesh;
  12752. private _attachedMesh;
  12753. /**
  12754. * Ratio for the scale of the gizmo (Default: 1)
  12755. */
  12756. scaleRatio: number;
  12757. private _tmpMatrix;
  12758. /**
  12759. * If a custom mesh has been set (Default: false)
  12760. */
  12761. protected _customMeshSet: boolean;
  12762. /**
  12763. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  12764. * * When set, interactions will be enabled
  12765. */
  12766. attachedMesh: Nullable<AbstractMesh>;
  12767. /**
  12768. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12769. * @param mesh The mesh to replace the default mesh of the gizmo
  12770. */
  12771. setCustomMesh(mesh: Mesh): void;
  12772. /**
  12773. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  12774. */
  12775. updateGizmoRotationToMatchAttachedMesh: boolean;
  12776. /**
  12777. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  12778. */
  12779. updateGizmoPositionToMatchAttachedMesh: boolean;
  12780. /**
  12781. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  12782. */
  12783. protected _updateScale: boolean;
  12784. protected _interactionsEnabled: boolean;
  12785. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12786. private _beforeRenderObserver;
  12787. /**
  12788. * Creates a gizmo
  12789. * @param gizmoLayer The utility layer the gizmo will be added to
  12790. */
  12791. constructor(
  12792. /** The utility layer the gizmo will be added to */
  12793. gizmoLayer?: UtilityLayerRenderer);
  12794. private _tempVector;
  12795. /**
  12796. * @hidden
  12797. * Updates the gizmo to match the attached mesh's position/rotation
  12798. */
  12799. protected _update(): void;
  12800. /**
  12801. * Disposes of the gizmo
  12802. */
  12803. dispose(): void;
  12804. }
  12805. }
  12806. declare module BABYLON {
  12807. /**
  12808. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  12809. */
  12810. class GizmoManager implements IDisposable {
  12811. private scene;
  12812. /**
  12813. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  12814. */
  12815. gizmos: {
  12816. positionGizmo: Nullable<PositionGizmo>;
  12817. rotationGizmo: Nullable<RotationGizmo>;
  12818. scaleGizmo: Nullable<ScaleGizmo>;
  12819. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  12820. };
  12821. private _gizmosEnabled;
  12822. private _pointerObserver;
  12823. private _attachedMesh;
  12824. private _boundingBoxColor;
  12825. private _defaultUtilityLayer;
  12826. private _defaultKeepDepthUtilityLayer;
  12827. /**
  12828. * When bounding box gizmo is enabled, this can be used to track drag/end events
  12829. */
  12830. boundingBoxDragBehavior: SixDofDragBehavior;
  12831. /**
  12832. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  12833. */
  12834. attachableMeshes: Nullable<Array<AbstractMesh>>;
  12835. /**
  12836. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  12837. */
  12838. usePointerToAttachGizmos: boolean;
  12839. /**
  12840. * Instatiates a gizmo manager
  12841. * @param scene the scene to overlay the gizmos on top of
  12842. */
  12843. constructor(scene: Scene);
  12844. /**
  12845. * Attaches a set of gizmos to the specified mesh
  12846. * @param mesh The mesh the gizmo's should be attached to
  12847. */
  12848. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  12849. /**
  12850. * If the position gizmo is enabled
  12851. */
  12852. positionGizmoEnabled: boolean;
  12853. /**
  12854. * If the rotation gizmo is enabled
  12855. */
  12856. rotationGizmoEnabled: boolean;
  12857. /**
  12858. * If the scale gizmo is enabled
  12859. */
  12860. scaleGizmoEnabled: boolean;
  12861. /**
  12862. * If the boundingBox gizmo is enabled
  12863. */
  12864. boundingBoxGizmoEnabled: boolean;
  12865. /**
  12866. * Disposes of the gizmo manager
  12867. */
  12868. dispose(): void;
  12869. }
  12870. }
  12871. declare module BABYLON {
  12872. /**
  12873. * Single plane rotation gizmo
  12874. */
  12875. class PlaneRotationGizmo extends Gizmo {
  12876. /**
  12877. * Drag behavior responsible for the gizmos dragging interactions
  12878. */
  12879. dragBehavior: PointerDragBehavior;
  12880. private _pointerObserver;
  12881. /**
  12882. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  12883. */
  12884. snapDistance: number;
  12885. /**
  12886. * Event that fires each time the gizmo snaps to a new location.
  12887. * * snapDistance is the the change in distance
  12888. */
  12889. onSnapObservable: Observable<{
  12890. snapDistance: number;
  12891. }>;
  12892. /**
  12893. * Creates a PlaneRotationGizmo
  12894. * @param gizmoLayer The utility layer the gizmo will be added to
  12895. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  12896. * @param color The color of the gizmo
  12897. * @param tessellation Amount of tessellation to be used when creating rotation circles
  12898. */
  12899. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  12900. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12901. /**
  12902. * Disposes of the gizmo
  12903. */
  12904. dispose(): void;
  12905. }
  12906. }
  12907. declare module BABYLON {
  12908. /**
  12909. * Gizmo that enables dragging a mesh along 3 axis
  12910. */
  12911. class PositionGizmo extends Gizmo {
  12912. /**
  12913. * Internal gizmo used for interactions on the x axis
  12914. */
  12915. xGizmo: AxisDragGizmo;
  12916. /**
  12917. * Internal gizmo used for interactions on the y axis
  12918. */
  12919. yGizmo: AxisDragGizmo;
  12920. /**
  12921. * Internal gizmo used for interactions on the z axis
  12922. */
  12923. zGizmo: AxisDragGizmo;
  12924. /** Fires an event when any of it's sub gizmos are dragged */
  12925. onDragStartObservable: Observable<{}>;
  12926. /** Fires an event when any of it's sub gizmos are released from dragging */
  12927. onDragEndObservable: Observable<{}>;
  12928. attachedMesh: Nullable<AbstractMesh>;
  12929. /**
  12930. * Creates a PositionGizmo
  12931. * @param gizmoLayer The utility layer the gizmo will be added to
  12932. */
  12933. constructor(gizmoLayer?: UtilityLayerRenderer);
  12934. updateGizmoRotationToMatchAttachedMesh: boolean;
  12935. /**
  12936. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12937. */
  12938. snapDistance: number;
  12939. /**
  12940. * Ratio for the scale of the gizmo (Default: 1)
  12941. */
  12942. scaleRatio: number;
  12943. /**
  12944. * Disposes of the gizmo
  12945. */
  12946. dispose(): void;
  12947. /**
  12948. * CustomMeshes are not supported by this gizmo
  12949. * @param mesh The mesh to replace the default mesh of the gizmo
  12950. */
  12951. setCustomMesh(mesh: Mesh): void;
  12952. }
  12953. }
  12954. declare module BABYLON {
  12955. /**
  12956. * Gizmo that enables rotating a mesh along 3 axis
  12957. */
  12958. class RotationGizmo extends Gizmo {
  12959. /**
  12960. * Internal gizmo used for interactions on the x axis
  12961. */
  12962. xGizmo: PlaneRotationGizmo;
  12963. /**
  12964. * Internal gizmo used for interactions on the y axis
  12965. */
  12966. yGizmo: PlaneRotationGizmo;
  12967. /**
  12968. * Internal gizmo used for interactions on the z axis
  12969. */
  12970. zGizmo: PlaneRotationGizmo;
  12971. /** Fires an event when any of it's sub gizmos are dragged */
  12972. onDragStartObservable: Observable<{}>;
  12973. /** Fires an event when any of it's sub gizmos are released from dragging */
  12974. onDragEndObservable: Observable<{}>;
  12975. attachedMesh: Nullable<AbstractMesh>;
  12976. /**
  12977. * Creates a RotationGizmo
  12978. * @param gizmoLayer The utility layer the gizmo will be added to
  12979. * @param tessellation Amount of tessellation to be used when creating rotation circles
  12980. */
  12981. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  12982. updateGizmoRotationToMatchAttachedMesh: boolean;
  12983. /**
  12984. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12985. */
  12986. snapDistance: number;
  12987. /**
  12988. * Ratio for the scale of the gizmo (Default: 1)
  12989. */
  12990. scaleRatio: number;
  12991. /**
  12992. * Disposes of the gizmo
  12993. */
  12994. dispose(): void;
  12995. /**
  12996. * CustomMeshes are not supported by this gizmo
  12997. * @param mesh The mesh to replace the default mesh of the gizmo
  12998. */
  12999. setCustomMesh(mesh: Mesh): void;
  13000. }
  13001. }
  13002. declare module BABYLON {
  13003. /**
  13004. * Gizmo that enables scaling a mesh along 3 axis
  13005. */
  13006. class ScaleGizmo extends Gizmo {
  13007. /**
  13008. * Internal gizmo used for interactions on the x axis
  13009. */
  13010. xGizmo: AxisScaleGizmo;
  13011. /**
  13012. * Internal gizmo used for interactions on the y axis
  13013. */
  13014. yGizmo: AxisScaleGizmo;
  13015. /**
  13016. * Internal gizmo used for interactions on the z axis
  13017. */
  13018. zGizmo: AxisScaleGizmo;
  13019. /**
  13020. * Internal gizmo used to scale all axis equally
  13021. */
  13022. uniformScaleGizmo: AxisScaleGizmo;
  13023. /** Fires an event when any of it's sub gizmos are dragged */
  13024. onDragStartObservable: Observable<{}>;
  13025. /** Fires an event when any of it's sub gizmos are released from dragging */
  13026. onDragEndObservable: Observable<{}>;
  13027. attachedMesh: Nullable<AbstractMesh>;
  13028. /**
  13029. * Creates a ScaleGizmo
  13030. * @param gizmoLayer The utility layer the gizmo will be added to
  13031. */
  13032. constructor(gizmoLayer?: UtilityLayerRenderer);
  13033. updateGizmoRotationToMatchAttachedMesh: boolean;
  13034. /**
  13035. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13036. */
  13037. snapDistance: number;
  13038. /**
  13039. * Ratio for the scale of the gizmo (Default: 1)
  13040. */
  13041. scaleRatio: number;
  13042. /**
  13043. * Disposes of the gizmo
  13044. */
  13045. dispose(): void;
  13046. }
  13047. }
  13048. declare module BABYLON {
  13049. /**
  13050. * This class can be used to get instrumentation data from a Babylon engine
  13051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13052. */
  13053. class EngineInstrumentation implements IDisposable {
  13054. /**
  13055. * Define the instrumented engine.
  13056. */
  13057. engine: Engine;
  13058. private _captureGPUFrameTime;
  13059. private _gpuFrameTimeToken;
  13060. private _gpuFrameTime;
  13061. private _captureShaderCompilationTime;
  13062. private _shaderCompilationTime;
  13063. private _onBeginFrameObserver;
  13064. private _onEndFrameObserver;
  13065. private _onBeforeShaderCompilationObserver;
  13066. private _onAfterShaderCompilationObserver;
  13067. /**
  13068. * Gets the perf counter used for GPU frame time
  13069. */
  13070. readonly gpuFrameTimeCounter: PerfCounter;
  13071. /**
  13072. * Gets the GPU frame time capture status
  13073. */
  13074. /**
  13075. * Enable or disable the GPU frame time capture
  13076. */
  13077. captureGPUFrameTime: boolean;
  13078. /**
  13079. * Gets the perf counter used for shader compilation time
  13080. */
  13081. readonly shaderCompilationTimeCounter: PerfCounter;
  13082. /**
  13083. * Gets the shader compilation time capture status
  13084. */
  13085. /**
  13086. * Enable or disable the shader compilation time capture
  13087. */
  13088. captureShaderCompilationTime: boolean;
  13089. /**
  13090. * Instantiates a new engine instrumentation.
  13091. * This class can be used to get instrumentation data from a Babylon engine
  13092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13093. * @param engine Defines the engine to instrument
  13094. */
  13095. constructor(
  13096. /**
  13097. * Define the instrumented engine.
  13098. */
  13099. engine: Engine);
  13100. /**
  13101. * Dispose and release associated resources.
  13102. */
  13103. dispose(): void;
  13104. }
  13105. }
  13106. declare module BABYLON {
  13107. /**
  13108. * This class can be used to get instrumentation data from a Babylon engine
  13109. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13110. */
  13111. class SceneInstrumentation implements IDisposable {
  13112. /**
  13113. * Defines the scene to instrument
  13114. */
  13115. scene: Scene;
  13116. private _captureActiveMeshesEvaluationTime;
  13117. private _activeMeshesEvaluationTime;
  13118. private _captureRenderTargetsRenderTime;
  13119. private _renderTargetsRenderTime;
  13120. private _captureFrameTime;
  13121. private _frameTime;
  13122. private _captureRenderTime;
  13123. private _renderTime;
  13124. private _captureInterFrameTime;
  13125. private _interFrameTime;
  13126. private _captureParticlesRenderTime;
  13127. private _particlesRenderTime;
  13128. private _captureSpritesRenderTime;
  13129. private _spritesRenderTime;
  13130. private _capturePhysicsTime;
  13131. private _physicsTime;
  13132. private _captureAnimationsTime;
  13133. private _animationsTime;
  13134. private _captureCameraRenderTime;
  13135. private _cameraRenderTime;
  13136. private _onBeforeActiveMeshesEvaluationObserver;
  13137. private _onAfterActiveMeshesEvaluationObserver;
  13138. private _onBeforeRenderTargetsRenderObserver;
  13139. private _onAfterRenderTargetsRenderObserver;
  13140. private _onAfterRenderObserver;
  13141. private _onBeforeDrawPhaseObserver;
  13142. private _onAfterDrawPhaseObserver;
  13143. private _onBeforeAnimationsObserver;
  13144. private _onBeforeParticlesRenderingObserver;
  13145. private _onAfterParticlesRenderingObserver;
  13146. private _onBeforeSpritesRenderingObserver;
  13147. private _onAfterSpritesRenderingObserver;
  13148. private _onBeforePhysicsObserver;
  13149. private _onAfterPhysicsObserver;
  13150. private _onAfterAnimationsObserver;
  13151. private _onBeforeCameraRenderObserver;
  13152. private _onAfterCameraRenderObserver;
  13153. /**
  13154. * Gets the perf counter used for active meshes evaluation time
  13155. */
  13156. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13157. /**
  13158. * Gets the active meshes evaluation time capture status
  13159. */
  13160. /**
  13161. * Enable or disable the active meshes evaluation time capture
  13162. */
  13163. captureActiveMeshesEvaluationTime: boolean;
  13164. /**
  13165. * Gets the perf counter used for render targets render time
  13166. */
  13167. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13168. /**
  13169. * Gets the render targets render time capture status
  13170. */
  13171. /**
  13172. * Enable or disable the render targets render time capture
  13173. */
  13174. captureRenderTargetsRenderTime: boolean;
  13175. /**
  13176. * Gets the perf counter used for particles render time
  13177. */
  13178. readonly particlesRenderTimeCounter: PerfCounter;
  13179. /**
  13180. * Gets the particles render time capture status
  13181. */
  13182. /**
  13183. * Enable or disable the particles render time capture
  13184. */
  13185. captureParticlesRenderTime: boolean;
  13186. /**
  13187. * Gets the perf counter used for sprites render time
  13188. */
  13189. readonly spritesRenderTimeCounter: PerfCounter;
  13190. /**
  13191. * Gets the sprites render time capture status
  13192. */
  13193. /**
  13194. * Enable or disable the sprites render time capture
  13195. */
  13196. captureSpritesRenderTime: boolean;
  13197. /**
  13198. * Gets the perf counter used for physics time
  13199. */
  13200. readonly physicsTimeCounter: PerfCounter;
  13201. /**
  13202. * Gets the physics time capture status
  13203. */
  13204. /**
  13205. * Enable or disable the physics time capture
  13206. */
  13207. capturePhysicsTime: boolean;
  13208. /**
  13209. * Gets the perf counter used for animations time
  13210. */
  13211. readonly animationsTimeCounter: PerfCounter;
  13212. /**
  13213. * Gets the animations time capture status
  13214. */
  13215. /**
  13216. * Enable or disable the animations time capture
  13217. */
  13218. captureAnimationsTime: boolean;
  13219. /**
  13220. * Gets the perf counter used for frame time capture
  13221. */
  13222. readonly frameTimeCounter: PerfCounter;
  13223. /**
  13224. * Gets the frame time capture status
  13225. */
  13226. /**
  13227. * Enable or disable the frame time capture
  13228. */
  13229. captureFrameTime: boolean;
  13230. /**
  13231. * Gets the perf counter used for inter-frames time capture
  13232. */
  13233. readonly interFrameTimeCounter: PerfCounter;
  13234. /**
  13235. * Gets the inter-frames time capture status
  13236. */
  13237. /**
  13238. * Enable or disable the inter-frames time capture
  13239. */
  13240. captureInterFrameTime: boolean;
  13241. /**
  13242. * Gets the perf counter used for render time capture
  13243. */
  13244. readonly renderTimeCounter: PerfCounter;
  13245. /**
  13246. * Gets the render time capture status
  13247. */
  13248. /**
  13249. * Enable or disable the render time capture
  13250. */
  13251. captureRenderTime: boolean;
  13252. /**
  13253. * Gets the perf counter used for camera render time capture
  13254. */
  13255. readonly cameraRenderTimeCounter: PerfCounter;
  13256. /**
  13257. * Gets the camera render time capture status
  13258. */
  13259. /**
  13260. * Enable or disable the camera render time capture
  13261. */
  13262. captureCameraRenderTime: boolean;
  13263. /**
  13264. * Gets the perf counter used for draw calls
  13265. */
  13266. readonly drawCallsCounter: PerfCounter;
  13267. /**
  13268. * Gets the perf counter used for texture collisions
  13269. */
  13270. readonly textureCollisionsCounter: PerfCounter;
  13271. /**
  13272. * Instantiates a new scene instrumentation.
  13273. * This class can be used to get instrumentation data from a Babylon engine
  13274. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13275. * @param scene Defines the scene to instrument
  13276. */
  13277. constructor(
  13278. /**
  13279. * Defines the scene to instrument
  13280. */
  13281. scene: Scene);
  13282. /**
  13283. * Dispose and release associated resources.
  13284. */
  13285. dispose(): void;
  13286. }
  13287. }
  13288. declare module BABYLON {
  13289. /**
  13290. * @hidden
  13291. **/
  13292. class _TimeToken {
  13293. _startTimeQuery: Nullable<WebGLQuery>;
  13294. _endTimeQuery: Nullable<WebGLQuery>;
  13295. _timeElapsedQuery: Nullable<WebGLQuery>;
  13296. _timeElapsedQueryEnded: boolean;
  13297. }
  13298. }
  13299. declare module BABYLON {
  13300. /**
  13301. * Represents the different options available during the creation of
  13302. * a Environment helper.
  13303. *
  13304. * This can control the default ground, skybox and image processing setup of your scene.
  13305. */
  13306. interface IEnvironmentHelperOptions {
  13307. /**
  13308. * Specifies wether or not to create a ground.
  13309. * True by default.
  13310. */
  13311. createGround: boolean;
  13312. /**
  13313. * Specifies the ground size.
  13314. * 15 by default.
  13315. */
  13316. groundSize: number;
  13317. /**
  13318. * The texture used on the ground for the main color.
  13319. * Comes from the BabylonJS CDN by default.
  13320. *
  13321. * Remarks: Can be either a texture or a url.
  13322. */
  13323. groundTexture: string | BaseTexture;
  13324. /**
  13325. * The color mixed in the ground texture by default.
  13326. * BabylonJS clearColor by default.
  13327. */
  13328. groundColor: Color3;
  13329. /**
  13330. * Specifies the ground opacity.
  13331. * 1 by default.
  13332. */
  13333. groundOpacity: number;
  13334. /**
  13335. * Enables the ground to receive shadows.
  13336. * True by default.
  13337. */
  13338. enableGroundShadow: boolean;
  13339. /**
  13340. * Helps preventing the shadow to be fully black on the ground.
  13341. * 0.5 by default.
  13342. */
  13343. groundShadowLevel: number;
  13344. /**
  13345. * Creates a mirror texture attach to the ground.
  13346. * false by default.
  13347. */
  13348. enableGroundMirror: boolean;
  13349. /**
  13350. * Specifies the ground mirror size ratio.
  13351. * 0.3 by default as the default kernel is 64.
  13352. */
  13353. groundMirrorSizeRatio: number;
  13354. /**
  13355. * Specifies the ground mirror blur kernel size.
  13356. * 64 by default.
  13357. */
  13358. groundMirrorBlurKernel: number;
  13359. /**
  13360. * Specifies the ground mirror visibility amount.
  13361. * 1 by default
  13362. */
  13363. groundMirrorAmount: number;
  13364. /**
  13365. * Specifies the ground mirror reflectance weight.
  13366. * This uses the standard weight of the background material to setup the fresnel effect
  13367. * of the mirror.
  13368. * 1 by default.
  13369. */
  13370. groundMirrorFresnelWeight: number;
  13371. /**
  13372. * Specifies the ground mirror Falloff distance.
  13373. * This can helps reducing the size of the reflection.
  13374. * 0 by Default.
  13375. */
  13376. groundMirrorFallOffDistance: number;
  13377. /**
  13378. * Specifies the ground mirror texture type.
  13379. * Unsigned Int by Default.
  13380. */
  13381. groundMirrorTextureType: number;
  13382. /**
  13383. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13384. * the shown objects.
  13385. */
  13386. groundYBias: number;
  13387. /**
  13388. * Specifies wether or not to create a skybox.
  13389. * True by default.
  13390. */
  13391. createSkybox: boolean;
  13392. /**
  13393. * Specifies the skybox size.
  13394. * 20 by default.
  13395. */
  13396. skyboxSize: number;
  13397. /**
  13398. * The texture used on the skybox for the main color.
  13399. * Comes from the BabylonJS CDN by default.
  13400. *
  13401. * Remarks: Can be either a texture or a url.
  13402. */
  13403. skyboxTexture: string | BaseTexture;
  13404. /**
  13405. * The color mixed in the skybox texture by default.
  13406. * BabylonJS clearColor by default.
  13407. */
  13408. skyboxColor: Color3;
  13409. /**
  13410. * The background rotation around the Y axis of the scene.
  13411. * This helps aligning the key lights of your scene with the background.
  13412. * 0 by default.
  13413. */
  13414. backgroundYRotation: number;
  13415. /**
  13416. * Compute automatically the size of the elements to best fit with the scene.
  13417. */
  13418. sizeAuto: boolean;
  13419. /**
  13420. * Default position of the rootMesh if autoSize is not true.
  13421. */
  13422. rootPosition: Vector3;
  13423. /**
  13424. * Sets up the image processing in the scene.
  13425. * true by default.
  13426. */
  13427. setupImageProcessing: boolean;
  13428. /**
  13429. * The texture used as your environment texture in the scene.
  13430. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13431. *
  13432. * Remarks: Can be either a texture or a url.
  13433. */
  13434. environmentTexture: string | BaseTexture;
  13435. /**
  13436. * The value of the exposure to apply to the scene.
  13437. * 0.6 by default if setupImageProcessing is true.
  13438. */
  13439. cameraExposure: number;
  13440. /**
  13441. * The value of the contrast to apply to the scene.
  13442. * 1.6 by default if setupImageProcessing is true.
  13443. */
  13444. cameraContrast: number;
  13445. /**
  13446. * Specifies wether or not tonemapping should be enabled in the scene.
  13447. * true by default if setupImageProcessing is true.
  13448. */
  13449. toneMappingEnabled: boolean;
  13450. }
  13451. /**
  13452. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13453. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13454. * It also helps with the default setup of your imageProcessing configuration.
  13455. */
  13456. class EnvironmentHelper {
  13457. /**
  13458. * Default ground texture URL.
  13459. */
  13460. private static _groundTextureCDNUrl;
  13461. /**
  13462. * Default skybox texture URL.
  13463. */
  13464. private static _skyboxTextureCDNUrl;
  13465. /**
  13466. * Default environment texture URL.
  13467. */
  13468. private static _environmentTextureCDNUrl;
  13469. /**
  13470. * Creates the default options for the helper.
  13471. */
  13472. private static _getDefaultOptions;
  13473. private _rootMesh;
  13474. /**
  13475. * Gets the root mesh created by the helper.
  13476. */
  13477. readonly rootMesh: Mesh;
  13478. private _skybox;
  13479. /**
  13480. * Gets the skybox created by the helper.
  13481. */
  13482. readonly skybox: Nullable<Mesh>;
  13483. private _skyboxTexture;
  13484. /**
  13485. * Gets the skybox texture created by the helper.
  13486. */
  13487. readonly skyboxTexture: Nullable<BaseTexture>;
  13488. private _skyboxMaterial;
  13489. /**
  13490. * Gets the skybox material created by the helper.
  13491. */
  13492. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13493. private _ground;
  13494. /**
  13495. * Gets the ground mesh created by the helper.
  13496. */
  13497. readonly ground: Nullable<Mesh>;
  13498. private _groundTexture;
  13499. /**
  13500. * Gets the ground texture created by the helper.
  13501. */
  13502. readonly groundTexture: Nullable<BaseTexture>;
  13503. private _groundMirror;
  13504. /**
  13505. * Gets the ground mirror created by the helper.
  13506. */
  13507. readonly groundMirror: Nullable<MirrorTexture>;
  13508. /**
  13509. * Gets the ground mirror render list to helps pushing the meshes
  13510. * you wish in the ground reflection.
  13511. */
  13512. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13513. private _groundMaterial;
  13514. /**
  13515. * Gets the ground material created by the helper.
  13516. */
  13517. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13518. /**
  13519. * Stores the creation options.
  13520. */
  13521. private readonly _scene;
  13522. private _options;
  13523. /**
  13524. * This observable will be notified with any error during the creation of the environment,
  13525. * mainly texture creation errors.
  13526. */
  13527. onErrorObservable: Observable<{
  13528. message?: string;
  13529. exception?: any;
  13530. }>;
  13531. /**
  13532. * constructor
  13533. * @param options
  13534. * @param scene The scene to add the material to
  13535. */
  13536. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13537. /**
  13538. * Updates the background according to the new options
  13539. * @param options
  13540. */
  13541. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13542. /**
  13543. * Sets the primary color of all the available elements.
  13544. * @param color the main color to affect to the ground and the background
  13545. */
  13546. setMainColor(color: Color3): void;
  13547. /**
  13548. * Setup the image processing according to the specified options.
  13549. */
  13550. private _setupImageProcessing;
  13551. /**
  13552. * Setup the environment texture according to the specified options.
  13553. */
  13554. private _setupEnvironmentTexture;
  13555. /**
  13556. * Setup the background according to the specified options.
  13557. */
  13558. private _setupBackground;
  13559. /**
  13560. * Get the scene sizes according to the setup.
  13561. */
  13562. private _getSceneSize;
  13563. /**
  13564. * Setup the ground according to the specified options.
  13565. */
  13566. private _setupGround;
  13567. /**
  13568. * Setup the ground material according to the specified options.
  13569. */
  13570. private _setupGroundMaterial;
  13571. /**
  13572. * Setup the ground diffuse texture according to the specified options.
  13573. */
  13574. private _setupGroundDiffuseTexture;
  13575. /**
  13576. * Setup the ground mirror texture according to the specified options.
  13577. */
  13578. private _setupGroundMirrorTexture;
  13579. /**
  13580. * Setup the ground to receive the mirror texture.
  13581. */
  13582. private _setupMirrorInGroundMaterial;
  13583. /**
  13584. * Setup the skybox according to the specified options.
  13585. */
  13586. private _setupSkybox;
  13587. /**
  13588. * Setup the skybox material according to the specified options.
  13589. */
  13590. private _setupSkyboxMaterial;
  13591. /**
  13592. * Setup the skybox reflection texture according to the specified options.
  13593. */
  13594. private _setupSkyboxReflectionTexture;
  13595. private _errorHandler;
  13596. /**
  13597. * Dispose all the elements created by the Helper.
  13598. */
  13599. dispose(): void;
  13600. }
  13601. }
  13602. declare module BABYLON {
  13603. /**
  13604. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13605. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13606. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13607. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13608. */
  13609. class PhotoDome extends TransformNode {
  13610. private _useDirectMapping;
  13611. /**
  13612. * The texture being displayed on the sphere
  13613. */
  13614. protected _photoTexture: Texture;
  13615. /**
  13616. * Gets or sets the texture being displayed on the sphere
  13617. */
  13618. photoTexture: Texture;
  13619. /**
  13620. * Observable raised when an error occured while loading the 360 image
  13621. */
  13622. onLoadErrorObservable: Observable<string>;
  13623. /**
  13624. * The skybox material
  13625. */
  13626. protected _material: BackgroundMaterial;
  13627. /**
  13628. * The surface used for the skybox
  13629. */
  13630. protected _mesh: Mesh;
  13631. /**
  13632. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13633. * Also see the options.resolution property.
  13634. */
  13635. fovMultiplier: number;
  13636. /**
  13637. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13638. * @param name Element's name, child elements will append suffixes for their own names.
  13639. * @param urlsOfPhoto defines the url of the photo to display
  13640. * @param options defines an object containing optional or exposed sub element properties
  13641. * @param onError defines a callback called when an error occured while loading the texture
  13642. */
  13643. constructor(name: string, urlOfPhoto: string, options: {
  13644. resolution?: number;
  13645. size?: number;
  13646. useDirectMapping?: boolean;
  13647. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13648. /**
  13649. * Releases resources associated with this node.
  13650. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13651. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13652. */
  13653. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13654. }
  13655. }
  13656. declare module BABYLON {
  13657. interface Scene {
  13658. /**
  13659. * Creates a default light for the scene.
  13660. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13661. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13662. */
  13663. createDefaultLight(replace?: boolean): void;
  13664. /**
  13665. * Creates a default camera for the scene.
  13666. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13667. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13668. * @param replace has default false, when true replaces the active camera in the scene
  13669. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13670. */
  13671. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13672. /**
  13673. * Creates a default camera and a default light.
  13674. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13675. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13676. * @param replace has the default false, when true replaces the active camera/light in the scene
  13677. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13678. */
  13679. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13680. /**
  13681. * Creates a new sky box
  13682. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13683. * @param environmentTexture defines the texture to use as environment texture
  13684. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13685. * @param scale defines the overall scale of the skybox
  13686. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13687. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13688. * @returns a new mesh holding the sky box
  13689. */
  13690. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13691. /**
  13692. * Creates a new environment
  13693. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13694. * @param options defines the options you can use to configure the environment
  13695. * @returns the new EnvironmentHelper
  13696. */
  13697. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13698. /**
  13699. * Creates a new VREXperienceHelper
  13700. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13701. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13702. * @returns a new VREXperienceHelper
  13703. */
  13704. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13705. }
  13706. }
  13707. declare module BABYLON {
  13708. /**
  13709. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13710. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13711. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13712. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13713. */
  13714. class VideoDome extends TransformNode {
  13715. private _useDirectMapping;
  13716. /**
  13717. * The video texture being displayed on the sphere
  13718. */
  13719. protected _videoTexture: VideoTexture;
  13720. /**
  13721. * Gets the video texture being displayed on the sphere
  13722. */
  13723. readonly videoTexture: VideoTexture;
  13724. /**
  13725. * The skybox material
  13726. */
  13727. protected _material: BackgroundMaterial;
  13728. /**
  13729. * The surface used for the skybox
  13730. */
  13731. protected _mesh: Mesh;
  13732. /**
  13733. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13734. * Also see the options.resolution property.
  13735. */
  13736. fovMultiplier: number;
  13737. /**
  13738. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13739. * @param name Element's name, child elements will append suffixes for their own names.
  13740. * @param urlsOrVideo defines the url(s) or the video element to use
  13741. * @param options An object containing optional or exposed sub element properties
  13742. */
  13743. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13744. resolution?: number;
  13745. clickToPlay?: boolean;
  13746. autoPlay?: boolean;
  13747. loop?: boolean;
  13748. size?: number;
  13749. poster?: string;
  13750. useDirectMapping?: boolean;
  13751. }, scene: Scene);
  13752. /**
  13753. * Releases resources associated with this node.
  13754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13756. */
  13757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13758. }
  13759. }
  13760. declare module BABYLON {
  13761. /**
  13762. * Effect layer options. This helps customizing the behaviour
  13763. * of the effect layer.
  13764. */
  13765. interface IEffectLayerOptions {
  13766. /**
  13767. * Multiplication factor apply to the canvas size to compute the render target size
  13768. * used to generated the objects (the smaller the faster).
  13769. */
  13770. mainTextureRatio: number;
  13771. /**
  13772. * Enforces a fixed size texture to ensure effect stability across devices.
  13773. */
  13774. mainTextureFixedSize?: number;
  13775. /**
  13776. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  13777. */
  13778. alphaBlendingMode: number;
  13779. /**
  13780. * The camera attached to the layer.
  13781. */
  13782. camera: Nullable<Camera>;
  13783. /**
  13784. * The rendering group to draw the layer in.
  13785. */
  13786. renderingGroupId: number;
  13787. }
  13788. /**
  13789. * The effect layer Helps adding post process effect blended with the main pass.
  13790. *
  13791. * This can be for instance use to generate glow or higlight effects on the scene.
  13792. *
  13793. * The effect layer class can not be used directly and is intented to inherited from to be
  13794. * customized per effects.
  13795. */
  13796. abstract class EffectLayer {
  13797. private _vertexBuffers;
  13798. private _indexBuffer;
  13799. private _cachedDefines;
  13800. private _effectLayerMapGenerationEffect;
  13801. private _effectLayerOptions;
  13802. private _mergeEffect;
  13803. protected _scene: Scene;
  13804. protected _engine: Engine;
  13805. protected _maxSize: number;
  13806. protected _mainTextureDesiredSize: ISize;
  13807. protected _mainTexture: RenderTargetTexture;
  13808. protected _shouldRender: boolean;
  13809. protected _postProcesses: PostProcess[];
  13810. protected _textures: BaseTexture[];
  13811. protected _emissiveTextureAndColor: {
  13812. texture: Nullable<BaseTexture>;
  13813. color: Color4;
  13814. };
  13815. /**
  13816. * The name of the layer
  13817. */
  13818. name: string;
  13819. /**
  13820. * The clear color of the texture used to generate the glow map.
  13821. */
  13822. neutralColor: Color4;
  13823. /**
  13824. * Specifies wether the highlight layer is enabled or not.
  13825. */
  13826. isEnabled: boolean;
  13827. /**
  13828. * Gets the camera attached to the layer.
  13829. */
  13830. readonly camera: Nullable<Camera>;
  13831. /**
  13832. * Gets the rendering group id the layer should render in.
  13833. */
  13834. readonly renderingGroupId: number;
  13835. /**
  13836. * An event triggered when the effect layer has been disposed.
  13837. */
  13838. onDisposeObservable: Observable<EffectLayer>;
  13839. /**
  13840. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  13841. */
  13842. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  13843. /**
  13844. * An event triggered when the generated texture is being merged in the scene.
  13845. */
  13846. onBeforeComposeObservable: Observable<EffectLayer>;
  13847. /**
  13848. * An event triggered when the generated texture has been merged in the scene.
  13849. */
  13850. onAfterComposeObservable: Observable<EffectLayer>;
  13851. /**
  13852. * An event triggered when the efffect layer changes its size.
  13853. */
  13854. onSizeChangedObservable: Observable<EffectLayer>;
  13855. /**
  13856. * Instantiates a new effect Layer and references it in the scene.
  13857. * @param name The name of the layer
  13858. * @param scene The scene to use the layer in
  13859. */
  13860. constructor(
  13861. /** The Friendly of the effect in the scene */
  13862. name: string, scene: Scene);
  13863. /**
  13864. * Get the effect name of the layer.
  13865. * @return The effect name
  13866. */
  13867. abstract getEffectName(): string;
  13868. /**
  13869. * Checks for the readiness of the element composing the layer.
  13870. * @param subMesh the mesh to check for
  13871. * @param useInstances specify wether or not to use instances to render the mesh
  13872. * @return true if ready otherwise, false
  13873. */
  13874. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13875. /**
  13876. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13877. * @returns true if the effect requires stencil during the main canvas render pass.
  13878. */
  13879. abstract needStencil(): boolean;
  13880. /**
  13881. * Create the merge effect. This is the shader use to blit the information back
  13882. * to the main canvas at the end of the scene rendering.
  13883. * @returns The effect containing the shader used to merge the effect on the main canvas
  13884. */
  13885. protected abstract _createMergeEffect(): Effect;
  13886. /**
  13887. * Creates the render target textures and post processes used in the effect layer.
  13888. */
  13889. protected abstract _createTextureAndPostProcesses(): void;
  13890. /**
  13891. * Implementation specific of rendering the generating effect on the main canvas.
  13892. * @param effect The effect used to render through
  13893. */
  13894. protected abstract _internalRender(effect: Effect): void;
  13895. /**
  13896. * Sets the required values for both the emissive texture and and the main color.
  13897. */
  13898. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13899. /**
  13900. * Free any resources and references associated to a mesh.
  13901. * Internal use
  13902. * @param mesh The mesh to free.
  13903. */
  13904. abstract _disposeMesh(mesh: Mesh): void;
  13905. /**
  13906. * Serializes this layer (Glow or Highlight for example)
  13907. * @returns a serialized layer object
  13908. */
  13909. abstract serialize?(): any;
  13910. /**
  13911. * Initializes the effect layer with the required options.
  13912. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  13913. */
  13914. protected _init(options: Partial<IEffectLayerOptions>): void;
  13915. /**
  13916. * Generates the index buffer of the full screen quad blending to the main canvas.
  13917. */
  13918. private _generateIndexBuffer;
  13919. /**
  13920. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  13921. */
  13922. private _genrateVertexBuffer;
  13923. /**
  13924. * Sets the main texture desired size which is the closest power of two
  13925. * of the engine canvas size.
  13926. */
  13927. private _setMainTextureSize;
  13928. /**
  13929. * Creates the main texture for the effect layer.
  13930. */
  13931. protected _createMainTexture(): void;
  13932. /**
  13933. * Checks for the readiness of the element composing the layer.
  13934. * @param subMesh the mesh to check for
  13935. * @param useInstances specify wether or not to use instances to render the mesh
  13936. * @param emissiveTexture the associated emissive texture used to generate the glow
  13937. * @return true if ready otherwise, false
  13938. */
  13939. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  13940. /**
  13941. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  13942. */
  13943. render(): void;
  13944. /**
  13945. * Determine if a given mesh will be used in the current effect.
  13946. * @param mesh mesh to test
  13947. * @returns true if the mesh will be used
  13948. */
  13949. hasMesh(mesh: AbstractMesh): boolean;
  13950. /**
  13951. * Returns true if the layer contains information to display, otherwise false.
  13952. * @returns true if the glow layer should be rendered
  13953. */
  13954. shouldRender(): boolean;
  13955. /**
  13956. * Returns true if the mesh should render, otherwise false.
  13957. * @param mesh The mesh to render
  13958. * @returns true if it should render otherwise false
  13959. */
  13960. protected _shouldRenderMesh(mesh: Mesh): boolean;
  13961. /**
  13962. * Returns true if the mesh should render, otherwise false.
  13963. * @param mesh The mesh to render
  13964. * @returns true if it should render otherwise false
  13965. */
  13966. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  13967. /**
  13968. * Renders the submesh passed in parameter to the generation map.
  13969. */
  13970. protected _renderSubMesh(subMesh: SubMesh): void;
  13971. /**
  13972. * Rebuild the required buffers.
  13973. * @hidden Internal use only.
  13974. */
  13975. _rebuild(): void;
  13976. /**
  13977. * Dispose only the render target textures and post process.
  13978. */
  13979. private _disposeTextureAndPostProcesses;
  13980. /**
  13981. * Dispose the highlight layer and free resources.
  13982. */
  13983. dispose(): void;
  13984. /**
  13985. * Gets the class name of the effect layer
  13986. * @returns the string with the class name of the effect layer
  13987. */
  13988. getClassName(): string;
  13989. /**
  13990. * Creates an effect layer from parsed effect layer data
  13991. * @param parsedEffectLayer defines effect layer data
  13992. * @param scene defines the current scene
  13993. * @param rootUrl defines the root URL containing the effect layer information
  13994. * @returns a parsed effect Layer
  13995. */
  13996. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  13997. }
  13998. }
  13999. declare module BABYLON {
  14000. interface AbstractScene {
  14001. /**
  14002. * The list of effect layers (highlights/glow) added to the scene
  14003. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14004. * @see http://doc.babylonjs.com/how_to/glow_layer
  14005. */
  14006. effectLayers: Array<EffectLayer>;
  14007. /**
  14008. * Removes the given effect layer from this scene.
  14009. * @param toRemove defines the effect layer to remove
  14010. * @returns the index of the removed effect layer
  14011. */
  14012. removeEffectLayer(toRemove: EffectLayer): number;
  14013. /**
  14014. * Adds the given effect layer to this scene
  14015. * @param newEffectLayer defines the effect layer to add
  14016. */
  14017. addEffectLayer(newEffectLayer: EffectLayer): void;
  14018. }
  14019. /**
  14020. * Defines the layer scene component responsible to manage any effect layers
  14021. * in a given scene.
  14022. */
  14023. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14024. /**
  14025. * The component name helpfull to identify the component in the list of scene components.
  14026. */
  14027. readonly name: string;
  14028. /**
  14029. * The scene the component belongs to.
  14030. */
  14031. scene: Scene;
  14032. private _engine;
  14033. private _renderEffects;
  14034. private _needStencil;
  14035. private _previousStencilState;
  14036. /**
  14037. * Creates a new instance of the component for the given scene
  14038. * @param scene Defines the scene to register the component in
  14039. */
  14040. constructor(scene: Scene);
  14041. /**
  14042. * Registers the component in a given scene
  14043. */
  14044. register(): void;
  14045. /**
  14046. * Rebuilds the elements related to this component in case of
  14047. * context lost for instance.
  14048. */
  14049. rebuild(): void;
  14050. /**
  14051. * Serializes the component data to the specified json object
  14052. * @param serializationObject The object to serialize to
  14053. */
  14054. serialize(serializationObject: any): void;
  14055. /**
  14056. * Adds all the element from the container to the scene
  14057. * @param container the container holding the elements
  14058. */
  14059. addFromContainer(container: AbstractScene): void;
  14060. /**
  14061. * Removes all the elements in the container from the scene
  14062. * @param container contains the elements to remove
  14063. */
  14064. removeFromContainer(container: AbstractScene): void;
  14065. /**
  14066. * Disposes the component and the associated ressources.
  14067. */
  14068. dispose(): void;
  14069. private _isReadyForMesh;
  14070. private _renderMainTexture;
  14071. private _setStencil;
  14072. private _setStencilBack;
  14073. private _draw;
  14074. private _drawCamera;
  14075. private _drawRenderingGroup;
  14076. }
  14077. }
  14078. declare module BABYLON {
  14079. interface AbstractScene {
  14080. /**
  14081. * Return a the first highlight layer of the scene with a given name.
  14082. * @param name The name of the highlight layer to look for.
  14083. * @return The highlight layer if found otherwise null.
  14084. */
  14085. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14086. }
  14087. /**
  14088. * Glow layer options. This helps customizing the behaviour
  14089. * of the glow layer.
  14090. */
  14091. interface IGlowLayerOptions {
  14092. /**
  14093. * Multiplication factor apply to the canvas size to compute the render target size
  14094. * used to generated the glowing objects (the smaller the faster).
  14095. */
  14096. mainTextureRatio: number;
  14097. /**
  14098. * Enforces a fixed size texture to ensure resize independant blur.
  14099. */
  14100. mainTextureFixedSize?: number;
  14101. /**
  14102. * How big is the kernel of the blur texture.
  14103. */
  14104. blurKernelSize: number;
  14105. /**
  14106. * The camera attached to the layer.
  14107. */
  14108. camera: Nullable<Camera>;
  14109. /**
  14110. * Enable MSAA by chosing the number of samples.
  14111. */
  14112. mainTextureSamples?: number;
  14113. /**
  14114. * The rendering group to draw the layer in.
  14115. */
  14116. renderingGroupId: number;
  14117. }
  14118. /**
  14119. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14120. *
  14121. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14122. * glowy meshes to your scene.
  14123. *
  14124. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14125. */
  14126. class GlowLayer extends EffectLayer {
  14127. /**
  14128. * Effect Name of the layer.
  14129. */
  14130. static readonly EffectName: string;
  14131. /**
  14132. * The default blur kernel size used for the glow.
  14133. */
  14134. static DefaultBlurKernelSize: number;
  14135. /**
  14136. * The default texture size ratio used for the glow.
  14137. */
  14138. static DefaultTextureRatio: number;
  14139. /**
  14140. * Sets the kernel size of the blur.
  14141. */
  14142. /**
  14143. * Gets the kernel size of the blur.
  14144. */
  14145. blurKernelSize: number;
  14146. /**
  14147. * Sets the glow intensity.
  14148. */
  14149. /**
  14150. * Gets the glow intensity.
  14151. */
  14152. intensity: number;
  14153. private _options;
  14154. private _intensity;
  14155. private _horizontalBlurPostprocess1;
  14156. private _verticalBlurPostprocess1;
  14157. private _horizontalBlurPostprocess2;
  14158. private _verticalBlurPostprocess2;
  14159. private _blurTexture1;
  14160. private _blurTexture2;
  14161. private _postProcesses1;
  14162. private _postProcesses2;
  14163. private _includedOnlyMeshes;
  14164. private _excludedMeshes;
  14165. /**
  14166. * Callback used to let the user override the color selection on a per mesh basis
  14167. */
  14168. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14169. /**
  14170. * Callback used to let the user override the texture selection on a per mesh basis
  14171. */
  14172. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14173. /**
  14174. * Instantiates a new glow Layer and references it to the scene.
  14175. * @param name The name of the layer
  14176. * @param scene The scene to use the layer in
  14177. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14178. */
  14179. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14180. /**
  14181. * Get the effect name of the layer.
  14182. * @return The effect name
  14183. */
  14184. getEffectName(): string;
  14185. /**
  14186. * Create the merge effect. This is the shader use to blit the information back
  14187. * to the main canvas at the end of the scene rendering.
  14188. */
  14189. protected _createMergeEffect(): Effect;
  14190. /**
  14191. * Creates the render target textures and post processes used in the glow layer.
  14192. */
  14193. protected _createTextureAndPostProcesses(): void;
  14194. /**
  14195. * Checks for the readiness of the element composing the layer.
  14196. * @param subMesh the mesh to check for
  14197. * @param useInstances specify wether or not to use instances to render the mesh
  14198. * @param emissiveTexture the associated emissive texture used to generate the glow
  14199. * @return true if ready otherwise, false
  14200. */
  14201. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14202. /**
  14203. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14204. */
  14205. needStencil(): boolean;
  14206. /**
  14207. * Implementation specific of rendering the generating effect on the main canvas.
  14208. * @param effect The effect used to render through
  14209. */
  14210. protected _internalRender(effect: Effect): void;
  14211. /**
  14212. * Sets the required values for both the emissive texture and and the main color.
  14213. */
  14214. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14215. /**
  14216. * Returns true if the mesh should render, otherwise false.
  14217. * @param mesh The mesh to render
  14218. * @returns true if it should render otherwise false
  14219. */
  14220. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14221. /**
  14222. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14223. * @param mesh The mesh to exclude from the glow layer
  14224. */
  14225. addExcludedMesh(mesh: Mesh): void;
  14226. /**
  14227. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14228. * @param mesh The mesh to remove
  14229. */
  14230. removeExcludedMesh(mesh: Mesh): void;
  14231. /**
  14232. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14233. * @param mesh The mesh to include in the glow layer
  14234. */
  14235. addIncludedOnlyMesh(mesh: Mesh): void;
  14236. /**
  14237. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14238. * @param mesh The mesh to remove
  14239. */
  14240. removeIncludedOnlyMesh(mesh: Mesh): void;
  14241. /**
  14242. * Determine if a given mesh will be used in the glow layer
  14243. * @param mesh The mesh to test
  14244. * @returns true if the mesh will be highlighted by the current glow layer
  14245. */
  14246. hasMesh(mesh: AbstractMesh): boolean;
  14247. /**
  14248. * Free any resources and references associated to a mesh.
  14249. * Internal use
  14250. * @param mesh The mesh to free.
  14251. * @hidden
  14252. */
  14253. _disposeMesh(mesh: Mesh): void;
  14254. /**
  14255. * Gets the class name of the effect layer
  14256. * @returns the string with the class name of the effect layer
  14257. */
  14258. getClassName(): string;
  14259. /**
  14260. * Serializes this glow layer
  14261. * @returns a serialized glow layer object
  14262. */
  14263. serialize(): any;
  14264. /**
  14265. * Creates a Glow Layer from parsed glow layer data
  14266. * @param parsedGlowLayer defines glow layer data
  14267. * @param scene defines the current scene
  14268. * @param rootUrl defines the root URL containing the glow layer information
  14269. * @returns a parsed Glow Layer
  14270. */
  14271. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14272. }
  14273. }
  14274. declare module BABYLON {
  14275. interface AbstractScene {
  14276. /**
  14277. * Return a the first highlight layer of the scene with a given name.
  14278. * @param name The name of the highlight layer to look for.
  14279. * @return The highlight layer if found otherwise null.
  14280. */
  14281. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14282. }
  14283. /**
  14284. * Highlight layer options. This helps customizing the behaviour
  14285. * of the highlight layer.
  14286. */
  14287. interface IHighlightLayerOptions {
  14288. /**
  14289. * Multiplication factor apply to the canvas size to compute the render target size
  14290. * used to generated the glowing objects (the smaller the faster).
  14291. */
  14292. mainTextureRatio: number;
  14293. /**
  14294. * Enforces a fixed size texture to ensure resize independant blur.
  14295. */
  14296. mainTextureFixedSize?: number;
  14297. /**
  14298. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14299. * of the picture to blur (the smaller the faster).
  14300. */
  14301. blurTextureSizeRatio: number;
  14302. /**
  14303. * How big in texel of the blur texture is the vertical blur.
  14304. */
  14305. blurVerticalSize: number;
  14306. /**
  14307. * How big in texel of the blur texture is the horizontal blur.
  14308. */
  14309. blurHorizontalSize: number;
  14310. /**
  14311. * Alpha blending mode used to apply the blur. Default is combine.
  14312. */
  14313. alphaBlendingMode: number;
  14314. /**
  14315. * The camera attached to the layer.
  14316. */
  14317. camera: Nullable<Camera>;
  14318. /**
  14319. * Should we display highlight as a solid stroke?
  14320. */
  14321. isStroke?: boolean;
  14322. /**
  14323. * The rendering group to draw the layer in.
  14324. */
  14325. renderingGroupId: number;
  14326. }
  14327. /**
  14328. * The highlight layer Helps adding a glow effect around a mesh.
  14329. *
  14330. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14331. * glowy meshes to your scene.
  14332. *
  14333. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14334. */
  14335. class HighlightLayer extends EffectLayer {
  14336. name: string;
  14337. /**
  14338. * Effect Name of the highlight layer.
  14339. */
  14340. static readonly EffectName: string;
  14341. /**
  14342. * The neutral color used during the preparation of the glow effect.
  14343. * This is black by default as the blend operation is a blend operation.
  14344. */
  14345. static NeutralColor: Color4;
  14346. /**
  14347. * Stencil value used for glowing meshes.
  14348. */
  14349. static GlowingMeshStencilReference: number;
  14350. /**
  14351. * Stencil value used for the other meshes in the scene.
  14352. */
  14353. static NormalMeshStencilReference: number;
  14354. /**
  14355. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14356. */
  14357. innerGlow: boolean;
  14358. /**
  14359. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14360. */
  14361. outerGlow: boolean;
  14362. /**
  14363. * Specifies the horizontal size of the blur.
  14364. */
  14365. /**
  14366. * Gets the horizontal size of the blur.
  14367. */
  14368. blurHorizontalSize: number;
  14369. /**
  14370. * Specifies the vertical size of the blur.
  14371. */
  14372. /**
  14373. * Gets the vertical size of the blur.
  14374. */
  14375. blurVerticalSize: number;
  14376. /**
  14377. * An event triggered when the highlight layer is being blurred.
  14378. */
  14379. onBeforeBlurObservable: Observable<HighlightLayer>;
  14380. /**
  14381. * An event triggered when the highlight layer has been blurred.
  14382. */
  14383. onAfterBlurObservable: Observable<HighlightLayer>;
  14384. private _instanceGlowingMeshStencilReference;
  14385. private _options;
  14386. private _downSamplePostprocess;
  14387. private _horizontalBlurPostprocess;
  14388. private _verticalBlurPostprocess;
  14389. private _blurTexture;
  14390. private _meshes;
  14391. private _excludedMeshes;
  14392. /**
  14393. * Instantiates a new highlight Layer and references it to the scene..
  14394. * @param name The name of the layer
  14395. * @param scene The scene to use the layer in
  14396. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14397. */
  14398. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14399. /**
  14400. * Get the effect name of the layer.
  14401. * @return The effect name
  14402. */
  14403. getEffectName(): string;
  14404. /**
  14405. * Create the merge effect. This is the shader use to blit the information back
  14406. * to the main canvas at the end of the scene rendering.
  14407. */
  14408. protected _createMergeEffect(): Effect;
  14409. /**
  14410. * Creates the render target textures and post processes used in the highlight layer.
  14411. */
  14412. protected _createTextureAndPostProcesses(): void;
  14413. /**
  14414. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14415. */
  14416. needStencil(): boolean;
  14417. /**
  14418. * Checks for the readiness of the element composing the layer.
  14419. * @param subMesh the mesh to check for
  14420. * @param useInstances specify wether or not to use instances to render the mesh
  14421. * @param emissiveTexture the associated emissive texture used to generate the glow
  14422. * @return true if ready otherwise, false
  14423. */
  14424. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14425. /**
  14426. * Implementation specific of rendering the generating effect on the main canvas.
  14427. * @param effect The effect used to render through
  14428. */
  14429. protected _internalRender(effect: Effect): void;
  14430. /**
  14431. * Returns true if the layer contains information to display, otherwise false.
  14432. */
  14433. shouldRender(): boolean;
  14434. /**
  14435. * Returns true if the mesh should render, otherwise false.
  14436. * @param mesh The mesh to render
  14437. * @returns true if it should render otherwise false
  14438. */
  14439. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14440. /**
  14441. * Sets the required values for both the emissive texture and and the main color.
  14442. */
  14443. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14444. /**
  14445. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14446. * @param mesh The mesh to exclude from the highlight layer
  14447. */
  14448. addExcludedMesh(mesh: Mesh): void;
  14449. /**
  14450. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14451. * @param mesh The mesh to highlight
  14452. */
  14453. removeExcludedMesh(mesh: Mesh): void;
  14454. /**
  14455. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14456. * @param mesh mesh to test
  14457. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14458. */
  14459. hasMesh(mesh: AbstractMesh): boolean;
  14460. /**
  14461. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14462. * @param mesh The mesh to highlight
  14463. * @param color The color of the highlight
  14464. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14465. */
  14466. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14467. /**
  14468. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14469. * @param mesh The mesh to highlight
  14470. */
  14471. removeMesh(mesh: Mesh): void;
  14472. /**
  14473. * Force the stencil to the normal expected value for none glowing parts
  14474. */
  14475. private _defaultStencilReference;
  14476. /**
  14477. * Free any resources and references associated to a mesh.
  14478. * Internal use
  14479. * @param mesh The mesh to free.
  14480. * @hidden
  14481. */
  14482. _disposeMesh(mesh: Mesh): void;
  14483. /**
  14484. * Dispose the highlight layer and free resources.
  14485. */
  14486. dispose(): void;
  14487. /**
  14488. * Gets the class name of the effect layer
  14489. * @returns the string with the class name of the effect layer
  14490. */
  14491. getClassName(): string;
  14492. /**
  14493. * Serializes this Highlight layer
  14494. * @returns a serialized Highlight layer object
  14495. */
  14496. serialize(): any;
  14497. /**
  14498. * Creates a Highlight layer from parsed Highlight layer data
  14499. * @param parsedHightlightLayer defines the Highlight layer data
  14500. * @param scene defines the current scene
  14501. * @param rootUrl defines the root URL containing the Highlight layer information
  14502. * @returns a parsed Highlight layer
  14503. */
  14504. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14505. }
  14506. }
  14507. declare module BABYLON {
  14508. /**
  14509. * This represents a full screen 2d layer.
  14510. * This can be usefull to display a picture in the background of your scene for instance.
  14511. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14512. */
  14513. class Layer {
  14514. /**
  14515. * Define the name of the layer.
  14516. */
  14517. name: string;
  14518. /**
  14519. * Define the texture the layer should display.
  14520. */
  14521. texture: Nullable<Texture>;
  14522. /**
  14523. * Is the layer in background or foreground.
  14524. */
  14525. isBackground: boolean;
  14526. /**
  14527. * Define the color of the layer (instead of texture).
  14528. */
  14529. color: Color4;
  14530. /**
  14531. * Define the scale of the layer in order to zoom in out of the texture.
  14532. */
  14533. scale: Vector2;
  14534. /**
  14535. * Define an offset for the layer in order to shift the texture.
  14536. */
  14537. offset: Vector2;
  14538. /**
  14539. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14540. */
  14541. alphaBlendingMode: number;
  14542. /**
  14543. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14544. * Alpha test will not mix with the background color in case of transparency.
  14545. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14546. */
  14547. alphaTest: boolean;
  14548. /**
  14549. * Define a mask to restrict the layer to only some of the scene cameras.
  14550. */
  14551. layerMask: number;
  14552. private _scene;
  14553. private _vertexBuffers;
  14554. private _indexBuffer;
  14555. private _effect;
  14556. private _alphaTestEffect;
  14557. /**
  14558. * An event triggered when the layer is disposed.
  14559. */
  14560. onDisposeObservable: Observable<Layer>;
  14561. private _onDisposeObserver;
  14562. /**
  14563. * Back compatibility with callback before the onDisposeObservable existed.
  14564. * The set callback will be triggered when the layer has been disposed.
  14565. */
  14566. onDispose: () => void;
  14567. /**
  14568. * An event triggered before rendering the scene
  14569. */
  14570. onBeforeRenderObservable: Observable<Layer>;
  14571. private _onBeforeRenderObserver;
  14572. /**
  14573. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14574. * The set callback will be triggered just before rendering the layer.
  14575. */
  14576. onBeforeRender: () => void;
  14577. /**
  14578. * An event triggered after rendering the scene
  14579. */
  14580. onAfterRenderObservable: Observable<Layer>;
  14581. private _onAfterRenderObserver;
  14582. /**
  14583. * Back compatibility with callback before the onAfterRenderObservable existed.
  14584. * The set callback will be triggered just after rendering the layer.
  14585. */
  14586. onAfterRender: () => void;
  14587. /**
  14588. * Instantiates a new layer.
  14589. * This represents a full screen 2d layer.
  14590. * This can be usefull to display a picture in the background of your scene for instance.
  14591. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14592. * @param name Define the name of the layer in the scene
  14593. * @param imgUrl Define the url of the texture to display in the layer
  14594. * @param scene Define the scene the layer belongs to
  14595. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14596. * @param color Defines a color for the layer
  14597. */
  14598. constructor(
  14599. /**
  14600. * Define the name of the layer.
  14601. */
  14602. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14603. private _createIndexBuffer;
  14604. /** @hidden */
  14605. _rebuild(): void;
  14606. /**
  14607. * Renders the layer in the scene.
  14608. */
  14609. render(): void;
  14610. /**
  14611. * Disposes and releases the associated ressources.
  14612. */
  14613. dispose(): void;
  14614. }
  14615. }
  14616. declare module BABYLON {
  14617. interface AbstractScene {
  14618. /**
  14619. * The list of layers (background and foreground) of the scene
  14620. */
  14621. layers: Array<Layer>;
  14622. }
  14623. /**
  14624. * Defines the layer scene component responsible to manage any layers
  14625. * in a given scene.
  14626. */
  14627. class LayerSceneComponent implements ISceneComponent {
  14628. /**
  14629. * The component name helpfull to identify the component in the list of scene components.
  14630. */
  14631. readonly name: string;
  14632. /**
  14633. * The scene the component belongs to.
  14634. */
  14635. scene: Scene;
  14636. private _engine;
  14637. /**
  14638. * Creates a new instance of the component for the given scene
  14639. * @param scene Defines the scene to register the component in
  14640. */
  14641. constructor(scene: Scene);
  14642. /**
  14643. * Registers the component in a given scene
  14644. */
  14645. register(): void;
  14646. /**
  14647. * Rebuilds the elements related to this component in case of
  14648. * context lost for instance.
  14649. */
  14650. rebuild(): void;
  14651. /**
  14652. * Disposes the component and the associated ressources.
  14653. */
  14654. dispose(): void;
  14655. private _draw;
  14656. private _drawBackground;
  14657. private _drawForeground;
  14658. }
  14659. }
  14660. declare module BABYLON {
  14661. /**
  14662. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14663. * It controls one of the indiviual texture used in the effect.
  14664. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14665. */
  14666. class LensFlare {
  14667. /**
  14668. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14669. */
  14670. size: number;
  14671. /**
  14672. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  14673. */
  14674. position: number;
  14675. /**
  14676. * Define the lens color.
  14677. */
  14678. color: Color3;
  14679. /**
  14680. * Define the lens texture.
  14681. */
  14682. texture: Nullable<Texture>;
  14683. /**
  14684. * Define the alpha mode to render this particular lens.
  14685. */
  14686. alphaMode: number;
  14687. private _system;
  14688. /**
  14689. * Creates a new Lens Flare.
  14690. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14691. * It controls one of the indiviual texture used in the effect.
  14692. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14693. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14694. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  14695. * @param color Define the lens color
  14696. * @param imgUrl Define the lens texture url
  14697. * @param system Define the `lensFlareSystem` this flare is part of
  14698. * @returns The newly created Lens Flare
  14699. */
  14700. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14701. /**
  14702. * Instantiates a new Lens Flare.
  14703. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14704. * It controls one of the indiviual texture used in the effect.
  14705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14706. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14707. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  14708. * @param color Define the lens color
  14709. * @param imgUrl Define the lens texture url
  14710. * @param system Define the `lensFlareSystem` this flare is part of
  14711. */
  14712. constructor(
  14713. /**
  14714. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14715. */
  14716. size: number,
  14717. /**
  14718. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  14719. */
  14720. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14721. /**
  14722. * Dispose and release the lens flare with its associated resources.
  14723. */
  14724. dispose(): void;
  14725. }
  14726. }
  14727. declare module BABYLON {
  14728. /**
  14729. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14730. * It is usually composed of several `BABYLON.lensFlare`.
  14731. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14732. */
  14733. class LensFlareSystem {
  14734. /**
  14735. * Define the name of the lens flare system
  14736. */
  14737. name: string;
  14738. /**
  14739. * List of lens flares used in this system.
  14740. */
  14741. lensFlares: LensFlare[];
  14742. /**
  14743. * Define a limit from the border the lens flare can be visible.
  14744. */
  14745. borderLimit: number;
  14746. /**
  14747. * Define a viewport border we do not want to see the lens flare in.
  14748. */
  14749. viewportBorder: number;
  14750. /**
  14751. * Define a predicate which could limit the list of meshes able to occlude the effect.
  14752. */
  14753. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  14754. /**
  14755. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  14756. */
  14757. layerMask: number;
  14758. /**
  14759. * Define the id of the lens flare system in the scene.
  14760. * (equal to name by default)
  14761. */
  14762. id: string;
  14763. private _scene;
  14764. private _emitter;
  14765. private _vertexBuffers;
  14766. private _indexBuffer;
  14767. private _effect;
  14768. private _positionX;
  14769. private _positionY;
  14770. private _isEnabled;
  14771. /**
  14772. * Instantiates a lens flare system.
  14773. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14774. * It is usually composed of several `BABYLON.lensFlare`.
  14775. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14776. * @param name Define the name of the lens flare system in the scene
  14777. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  14778. * @param scene Define the scene the lens flare system belongs to
  14779. */
  14780. constructor(
  14781. /**
  14782. * Define the name of the lens flare system
  14783. */
  14784. name: string, emitter: any, scene: Scene);
  14785. /**
  14786. * Define if the lens flare system is enabled.
  14787. */
  14788. isEnabled: boolean;
  14789. /**
  14790. * Get the scene the effects belongs to.
  14791. * @returns the scene holding the lens flare system
  14792. */
  14793. getScene(): Scene;
  14794. /**
  14795. * Get the emitter of the lens flare system.
  14796. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14797. * @returns the emitter of the lens flare system
  14798. */
  14799. getEmitter(): any;
  14800. /**
  14801. * Set the emitter of the lens flare system.
  14802. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14803. * @param newEmitter Define the new emitter of the system
  14804. */
  14805. setEmitter(newEmitter: any): void;
  14806. /**
  14807. * Get the lens flare system emitter position.
  14808. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  14809. * @returns the position
  14810. */
  14811. getEmitterPosition(): Vector3;
  14812. /**
  14813. * @hidden
  14814. */
  14815. computeEffectivePosition(globalViewport: Viewport): boolean;
  14816. /** @hidden */
  14817. _isVisible(): boolean;
  14818. /**
  14819. * @hidden
  14820. */
  14821. render(): boolean;
  14822. /**
  14823. * Dispose and release the lens flare with its associated resources.
  14824. */
  14825. dispose(): void;
  14826. /**
  14827. * Parse a lens flare system from a JSON repressentation
  14828. * @param parsedLensFlareSystem Define the JSON to parse
  14829. * @param scene Define the scene the parsed system should be instantiated in
  14830. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  14831. * @returns the parsed system
  14832. */
  14833. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  14834. /**
  14835. * Serialize the current Lens Flare System into a JSON representation.
  14836. * @returns the serialized JSON
  14837. */
  14838. serialize(): any;
  14839. }
  14840. }
  14841. declare module BABYLON {
  14842. interface AbstractScene {
  14843. /**
  14844. * The list of lens flare system added to the scene
  14845. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14846. */
  14847. lensFlareSystems: Array<LensFlareSystem>;
  14848. /**
  14849. * Removes the given lens flare system from this scene.
  14850. * @param toRemove The lens flare system to remove
  14851. * @returns The index of the removed lens flare system
  14852. */
  14853. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  14854. /**
  14855. * Adds the given lens flare system to this scene
  14856. * @param newLensFlareSystem The lens flare system to add
  14857. */
  14858. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  14859. /**
  14860. * Gets a lens flare system using its name
  14861. * @param name defines the name to look for
  14862. * @returns the lens flare system or null if not found
  14863. */
  14864. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  14865. /**
  14866. * Gets a lens flare system using its id
  14867. * @param id defines the id to look for
  14868. * @returns the lens flare system or null if not found
  14869. */
  14870. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  14871. }
  14872. /**
  14873. * Defines the lens flare scene component responsible to manage any lens flares
  14874. * in a given scene.
  14875. */
  14876. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  14877. /**
  14878. * The component name helpfull to identify the component in the list of scene components.
  14879. */
  14880. readonly name: string;
  14881. /**
  14882. * The scene the component belongs to.
  14883. */
  14884. scene: Scene;
  14885. /**
  14886. * Creates a new instance of the component for the given scene
  14887. * @param scene Defines the scene to register the component in
  14888. */
  14889. constructor(scene: Scene);
  14890. /**
  14891. * Registers the component in a given scene
  14892. */
  14893. register(): void;
  14894. /**
  14895. * Rebuilds the elements related to this component in case of
  14896. * context lost for instance.
  14897. */
  14898. rebuild(): void;
  14899. /**
  14900. * Adds all the element from the container to the scene
  14901. * @param container the container holding the elements
  14902. */
  14903. addFromContainer(container: AbstractScene): void;
  14904. /**
  14905. * Removes all the elements in the container from the scene
  14906. * @param container contains the elements to remove
  14907. */
  14908. removeFromContainer(container: AbstractScene): void;
  14909. /**
  14910. * Serializes the component data to the specified json object
  14911. * @param serializationObject The object to serialize to
  14912. */
  14913. serialize(serializationObject: any): void;
  14914. /**
  14915. * Disposes the component and the associated ressources.
  14916. */
  14917. dispose(): void;
  14918. private _draw;
  14919. }
  14920. }
  14921. declare module BABYLON {
  14922. /**
  14923. * A directional light is defined by a direction (what a surprise!).
  14924. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  14925. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  14926. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14927. */
  14928. class DirectionalLight extends ShadowLight {
  14929. private _shadowFrustumSize;
  14930. /**
  14931. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  14932. */
  14933. /**
  14934. * Specifies a fix frustum size for the shadow generation.
  14935. */
  14936. shadowFrustumSize: number;
  14937. private _shadowOrthoScale;
  14938. /**
  14939. * Gets the shadow projection scale against the optimal computed one.
  14940. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14941. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14942. */
  14943. /**
  14944. * Sets the shadow projection scale against the optimal computed one.
  14945. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14946. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14947. */
  14948. shadowOrthoScale: number;
  14949. /**
  14950. * Automatically compute the projection matrix to best fit (including all the casters)
  14951. * on each frame.
  14952. */
  14953. autoUpdateExtends: boolean;
  14954. private _orthoLeft;
  14955. private _orthoRight;
  14956. private _orthoTop;
  14957. private _orthoBottom;
  14958. /**
  14959. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  14960. * The directional light is emitted from everywhere in the given direction.
  14961. * It can cast shadows.
  14962. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14963. * @param name The friendly name of the light
  14964. * @param direction The direction of the light
  14965. * @param scene The scene the light belongs to
  14966. */
  14967. constructor(name: string, direction: Vector3, scene: Scene);
  14968. /**
  14969. * Returns the string "DirectionalLight".
  14970. * @return The class name
  14971. */
  14972. getClassName(): string;
  14973. /**
  14974. * Returns the integer 1.
  14975. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14976. */
  14977. getTypeID(): number;
  14978. /**
  14979. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  14980. * Returns the DirectionalLight Shadow projection matrix.
  14981. */
  14982. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14983. /**
  14984. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  14985. * Returns the DirectionalLight Shadow projection matrix.
  14986. */
  14987. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  14988. /**
  14989. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  14990. * Returns the DirectionalLight Shadow projection matrix.
  14991. */
  14992. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14993. protected _buildUniformLayout(): void;
  14994. /**
  14995. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  14996. * @param effect The effect to update
  14997. * @param lightIndex The index of the light in the effect to update
  14998. * @returns The directional light
  14999. */
  15000. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15001. /**
  15002. * Gets the minZ used for shadow according to both the scene and the light.
  15003. *
  15004. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15005. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15006. * @param activeCamera The camera we are returning the min for
  15007. * @returns the depth min z
  15008. */
  15009. getDepthMinZ(activeCamera: Camera): number;
  15010. /**
  15011. * Gets the maxZ used for shadow according to both the scene and the light.
  15012. *
  15013. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15014. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15015. * @param activeCamera The camera we are returning the max for
  15016. * @returns the depth max z
  15017. */
  15018. getDepthMaxZ(activeCamera: Camera): number;
  15019. /**
  15020. * Prepares the list of defines specific to the light type.
  15021. * @param defines the list of defines
  15022. * @param lightIndex defines the index of the light for the effect
  15023. */
  15024. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15025. }
  15026. }
  15027. declare module BABYLON {
  15028. /**
  15029. * The HemisphericLight simulates the ambient environment light,
  15030. * so the passed direction is the light reflection direction, not the incoming direction.
  15031. */
  15032. class HemisphericLight extends Light {
  15033. /**
  15034. * The groundColor is the light in the opposite direction to the one specified during creation.
  15035. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  15036. */
  15037. groundColor: Color3;
  15038. /**
  15039. * The light reflection direction, not the incoming direction.
  15040. */
  15041. direction: Vector3;
  15042. /**
  15043. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15044. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15045. * The HemisphericLight can't cast shadows.
  15046. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15047. * @param name The friendly name of the light
  15048. * @param direction The direction of the light reflection
  15049. * @param scene The scene the light belongs to
  15050. */
  15051. constructor(name: string, direction: Vector3, scene: Scene);
  15052. protected _buildUniformLayout(): void;
  15053. /**
  15054. * Returns the string "HemisphericLight".
  15055. * @return The class name
  15056. */
  15057. getClassName(): string;
  15058. /**
  15059. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15060. * Returns the updated direction.
  15061. * @param target The target the direction should point to
  15062. * @return The computed direction
  15063. */
  15064. setDirectionToTarget(target: Vector3): Vector3;
  15065. /**
  15066. * Returns the shadow generator associated to the light.
  15067. * @returns Always null for hemispheric lights because it does not support shadows.
  15068. */
  15069. getShadowGenerator(): Nullable<IShadowGenerator>;
  15070. /**
  15071. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15072. * @param effect The effect to update
  15073. * @param lightIndex The index of the light in the effect to update
  15074. * @returns The hemispheric light
  15075. */
  15076. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15077. /**
  15078. * Computes the world matrix of the node
  15079. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15080. * @param useWasUpdatedFlag defines a reserved property
  15081. * @returns the world matrix
  15082. */
  15083. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15084. /**
  15085. * Returns the integer 3.
  15086. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15087. */
  15088. getTypeID(): number;
  15089. /**
  15090. * Prepares the list of defines specific to the light type.
  15091. * @param defines the list of defines
  15092. * @param lightIndex defines the index of the light for the effect
  15093. */
  15094. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15095. }
  15096. }
  15097. declare module BABYLON {
  15098. /**
  15099. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15100. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15101. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  15102. */
  15103. abstract class Light extends Node {
  15104. /**
  15105. * Falloff Default: light is falling off following the material specification:
  15106. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15107. */
  15108. static readonly FALLOFF_DEFAULT: number;
  15109. /**
  15110. * Falloff Physical: light is falling off following the inverse squared distance law.
  15111. */
  15112. static readonly FALLOFF_PHYSICAL: number;
  15113. /**
  15114. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15115. * to enhance interoperability with other engines.
  15116. */
  15117. static readonly FALLOFF_GLTF: number;
  15118. /**
  15119. * Falloff Standard: light is falling off like in the standard material
  15120. * to enhance interoperability with other materials.
  15121. */
  15122. static readonly FALLOFF_STANDARD: number;
  15123. /**
  15124. * If every light affecting the material is in this lightmapMode,
  15125. * material.lightmapTexture adds or multiplies
  15126. * (depends on material.useLightmapAsShadowmap)
  15127. * after every other light calculations.
  15128. */
  15129. static readonly LIGHTMAP_DEFAULT: number;
  15130. /**
  15131. * material.lightmapTexture as only diffuse lighting from this light
  15132. * adds only specular lighting from this light
  15133. * adds dynamic shadows
  15134. */
  15135. static readonly LIGHTMAP_SPECULAR: number;
  15136. /**
  15137. * material.lightmapTexture as only lighting
  15138. * no light calculation from this light
  15139. * only adds dynamic shadows from this light
  15140. */
  15141. static readonly LIGHTMAP_SHADOWSONLY: number;
  15142. /**
  15143. * Each light type uses the default quantity according to its type:
  15144. * point/spot lights use luminous intensity
  15145. * directional lights use illuminance
  15146. */
  15147. static readonly INTENSITYMODE_AUTOMATIC: number;
  15148. /**
  15149. * lumen (lm)
  15150. */
  15151. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15152. /**
  15153. * candela (lm/sr)
  15154. */
  15155. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15156. /**
  15157. * lux (lm/m^2)
  15158. */
  15159. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15160. /**
  15161. * nit (cd/m^2)
  15162. */
  15163. static readonly INTENSITYMODE_LUMINANCE: number;
  15164. /**
  15165. * Light type const id of the point light.
  15166. */
  15167. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15168. /**
  15169. * Light type const id of the directional light.
  15170. */
  15171. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15172. /**
  15173. * Light type const id of the spot light.
  15174. */
  15175. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15176. /**
  15177. * Light type const id of the hemispheric light.
  15178. */
  15179. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15180. /**
  15181. * Diffuse gives the basic color to an object.
  15182. */
  15183. diffuse: Color3;
  15184. /**
  15185. * Specular produces a highlight color on an object.
  15186. * Note: This is note affecting PBR materials.
  15187. */
  15188. specular: Color3;
  15189. /**
  15190. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15191. * falling off base on range or angle.
  15192. * This can be set to any values in Light.FALLOFF_x.
  15193. *
  15194. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15195. * other types of materials.
  15196. */
  15197. falloffType: number;
  15198. /**
  15199. * Strength of the light.
  15200. * Note: By default it is define in the framework own unit.
  15201. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15202. */
  15203. intensity: number;
  15204. private _range;
  15205. protected _inverseSquaredRange: number;
  15206. /**
  15207. * Defines how far from the source the light is impacting in scene units.
  15208. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15209. */
  15210. /**
  15211. * Defines how far from the source the light is impacting in scene units.
  15212. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15213. */
  15214. range: number;
  15215. /**
  15216. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15217. * of light.
  15218. */
  15219. private _photometricScale;
  15220. private _intensityMode;
  15221. /**
  15222. * Gets the photometric scale used to interpret the intensity.
  15223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15224. */
  15225. /**
  15226. * Sets the photometric scale used to interpret the intensity.
  15227. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15228. */
  15229. intensityMode: number;
  15230. private _radius;
  15231. /**
  15232. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15233. */
  15234. /**
  15235. * sets the light radius used by PBR Materials to simulate soft area lights.
  15236. */
  15237. radius: number;
  15238. private _renderPriority;
  15239. /**
  15240. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15241. * exceeding the number allowed of the materials.
  15242. */
  15243. renderPriority: number;
  15244. private _shadowEnabled;
  15245. /**
  15246. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15247. * the current shadow generator.
  15248. */
  15249. /**
  15250. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15251. * the current shadow generator.
  15252. */
  15253. shadowEnabled: boolean;
  15254. private _includedOnlyMeshes;
  15255. /**
  15256. * Gets the only meshes impacted by this light.
  15257. */
  15258. /**
  15259. * Sets the only meshes impacted by this light.
  15260. */
  15261. includedOnlyMeshes: AbstractMesh[];
  15262. private _excludedMeshes;
  15263. /**
  15264. * Gets the meshes not impacted by this light.
  15265. */
  15266. /**
  15267. * Sets the meshes not impacted by this light.
  15268. */
  15269. excludedMeshes: AbstractMesh[];
  15270. private _excludeWithLayerMask;
  15271. /**
  15272. * Gets the layer id use to find what meshes are not impacted by the light.
  15273. * Inactive if 0
  15274. */
  15275. /**
  15276. * Sets the layer id use to find what meshes are not impacted by the light.
  15277. * Inactive if 0
  15278. */
  15279. excludeWithLayerMask: number;
  15280. private _includeOnlyWithLayerMask;
  15281. /**
  15282. * Gets the layer id use to find what meshes are impacted by the light.
  15283. * Inactive if 0
  15284. */
  15285. /**
  15286. * Sets the layer id use to find what meshes are impacted by the light.
  15287. * Inactive if 0
  15288. */
  15289. includeOnlyWithLayerMask: number;
  15290. private _lightmapMode;
  15291. /**
  15292. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15293. */
  15294. /**
  15295. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15296. */
  15297. lightmapMode: number;
  15298. /**
  15299. * Shadow generator associted to the light.
  15300. * @hidden Internal use only.
  15301. */
  15302. _shadowGenerator: Nullable<IShadowGenerator>;
  15303. /**
  15304. * @hidden Internal use only.
  15305. */
  15306. _excludedMeshesIds: string[];
  15307. /**
  15308. * @hidden Internal use only.
  15309. */
  15310. _includedOnlyMeshesIds: string[];
  15311. /**
  15312. * The current light unifom buffer.
  15313. * @hidden Internal use only.
  15314. */
  15315. _uniformBuffer: UniformBuffer;
  15316. /**
  15317. * Creates a Light object in the scene.
  15318. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15319. * @param name The firendly name of the light
  15320. * @param scene The scene the light belongs too
  15321. */
  15322. constructor(name: string, scene: Scene);
  15323. protected abstract _buildUniformLayout(): void;
  15324. /**
  15325. * Sets the passed Effect "effect" with the Light information.
  15326. * @param effect The effect to update
  15327. * @param lightIndex The index of the light in the effect to update
  15328. * @returns The light
  15329. */
  15330. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15331. /**
  15332. * Returns the string "Light".
  15333. * @returns the class name
  15334. */
  15335. getClassName(): string;
  15336. /**
  15337. * Converts the light information to a readable string for debug purpose.
  15338. * @param fullDetails Supports for multiple levels of logging within scene loading
  15339. * @returns the human readable light info
  15340. */
  15341. toString(fullDetails?: boolean): string;
  15342. /** @hidden */
  15343. protected _syncParentEnabledState(): void;
  15344. /**
  15345. * Set the enabled state of this node.
  15346. * @param value - the new enabled state
  15347. */
  15348. setEnabled(value: boolean): void;
  15349. /**
  15350. * Returns the Light associated shadow generator if any.
  15351. * @return the associated shadow generator.
  15352. */
  15353. getShadowGenerator(): Nullable<IShadowGenerator>;
  15354. /**
  15355. * Returns a Vector3, the absolute light position in the World.
  15356. * @returns the world space position of the light
  15357. */
  15358. getAbsolutePosition(): Vector3;
  15359. /**
  15360. * Specifies if the light will affect the passed mesh.
  15361. * @param mesh The mesh to test against the light
  15362. * @return true the mesh is affected otherwise, false.
  15363. */
  15364. canAffectMesh(mesh: AbstractMesh): boolean;
  15365. /**
  15366. * Sort function to order lights for rendering.
  15367. * @param a First Light object to compare to second.
  15368. * @param b Second Light object to compare first.
  15369. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15370. */
  15371. static CompareLightsPriority(a: Light, b: Light): number;
  15372. /**
  15373. * Releases resources associated with this node.
  15374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15376. */
  15377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15378. /**
  15379. * Returns the light type ID (integer).
  15380. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15381. */
  15382. getTypeID(): number;
  15383. /**
  15384. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15385. * @returns the scaled intensity in intensity mode unit
  15386. */
  15387. getScaledIntensity(): number;
  15388. /**
  15389. * Returns a new Light object, named "name", from the current one.
  15390. * @param name The name of the cloned light
  15391. * @returns the new created light
  15392. */
  15393. clone(name: string): Nullable<Light>;
  15394. /**
  15395. * Serializes the current light into a Serialization object.
  15396. * @returns the serialized object.
  15397. */
  15398. serialize(): any;
  15399. /**
  15400. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15401. * This new light is named "name" and added to the passed scene.
  15402. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15403. * @param name The friendly name of the light
  15404. * @param scene The scene the new light will belong to
  15405. * @returns the constructor function
  15406. */
  15407. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15408. /**
  15409. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15410. * @param parsedLight The JSON representation of the light
  15411. * @param scene The scene to create the parsed light in
  15412. * @returns the created light after parsing
  15413. */
  15414. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15415. private _hookArrayForExcluded;
  15416. private _hookArrayForIncludedOnly;
  15417. private _resyncMeshes;
  15418. /**
  15419. * Forces the meshes to update their light related information in their rendering used effects
  15420. * @hidden Internal Use Only
  15421. */
  15422. _markMeshesAsLightDirty(): void;
  15423. /**
  15424. * Recomputes the cached photometric scale if needed.
  15425. */
  15426. private _computePhotometricScale;
  15427. /**
  15428. * Returns the Photometric Scale according to the light type and intensity mode.
  15429. */
  15430. private _getPhotometricScale;
  15431. /**
  15432. * Reorder the light in the scene according to their defined priority.
  15433. * @hidden Internal Use Only
  15434. */
  15435. _reorderLightsInScene(): void;
  15436. /**
  15437. * Prepares the list of defines specific to the light type.
  15438. * @param defines the list of defines
  15439. * @param lightIndex defines the index of the light for the effect
  15440. */
  15441. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15442. }
  15443. }
  15444. declare module BABYLON {
  15445. /**
  15446. * A point light is a light defined by an unique point in world space.
  15447. * The light is emitted in every direction from this point.
  15448. * A good example of a point light is a standard light bulb.
  15449. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15450. */
  15451. class PointLight extends ShadowLight {
  15452. private _shadowAngle;
  15453. /**
  15454. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15455. * This specifies what angle the shadow will use to be created.
  15456. *
  15457. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15458. */
  15459. /**
  15460. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15461. * This specifies what angle the shadow will use to be created.
  15462. *
  15463. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15464. */
  15465. shadowAngle: number;
  15466. /**
  15467. * Gets the direction if it has been set.
  15468. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15469. */
  15470. /**
  15471. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15472. */
  15473. direction: Vector3;
  15474. /**
  15475. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15476. * A PointLight emits the light in every direction.
  15477. * It can cast shadows.
  15478. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15479. * ```javascript
  15480. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15481. * ```
  15482. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15483. * @param name The light friendly name
  15484. * @param position The position of the point light in the scene
  15485. * @param scene The scene the lights belongs to
  15486. */
  15487. constructor(name: string, position: Vector3, scene: Scene);
  15488. /**
  15489. * Returns the string "PointLight"
  15490. * @returns the class name
  15491. */
  15492. getClassName(): string;
  15493. /**
  15494. * Returns the integer 0.
  15495. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15496. */
  15497. getTypeID(): number;
  15498. /**
  15499. * Specifies wether or not the shadowmap should be a cube texture.
  15500. * @returns true if the shadowmap needs to be a cube texture.
  15501. */
  15502. needCube(): boolean;
  15503. /**
  15504. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15505. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15506. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15507. */
  15508. getShadowDirection(faceIndex?: number): Vector3;
  15509. /**
  15510. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15511. * - fov = PI / 2
  15512. * - aspect ratio : 1.0
  15513. * - z-near and far equal to the active camera minZ and maxZ.
  15514. * Returns the PointLight.
  15515. */
  15516. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15517. protected _buildUniformLayout(): void;
  15518. /**
  15519. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15520. * @param effect The effect to update
  15521. * @param lightIndex The index of the light in the effect to update
  15522. * @returns The point light
  15523. */
  15524. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15525. /**
  15526. * Prepares the list of defines specific to the light type.
  15527. * @param defines the list of defines
  15528. * @param lightIndex defines the index of the light for the effect
  15529. */
  15530. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15531. }
  15532. }
  15533. declare module BABYLON {
  15534. /**
  15535. * Interface describing all the common properties and methods a shadow light needs to implement.
  15536. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15537. * as well as binding the different shadow properties to the effects.
  15538. */
  15539. interface IShadowLight extends Light {
  15540. /**
  15541. * The light id in the scene (used in scene.findLighById for instance)
  15542. */
  15543. id: string;
  15544. /**
  15545. * The position the shdow will be casted from.
  15546. */
  15547. position: Vector3;
  15548. /**
  15549. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15550. */
  15551. direction: Vector3;
  15552. /**
  15553. * The transformed position. Position of the light in world space taking parenting in account.
  15554. */
  15555. transformedPosition: Vector3;
  15556. /**
  15557. * The transformed direction. Direction of the light in world space taking parenting in account.
  15558. */
  15559. transformedDirection: Vector3;
  15560. /**
  15561. * The friendly name of the light in the scene.
  15562. */
  15563. name: string;
  15564. /**
  15565. * Defines the shadow projection clipping minimum z value.
  15566. */
  15567. shadowMinZ: number;
  15568. /**
  15569. * Defines the shadow projection clipping maximum z value.
  15570. */
  15571. shadowMaxZ: number;
  15572. /**
  15573. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15574. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15575. */
  15576. computeTransformedInformation(): boolean;
  15577. /**
  15578. * Gets the scene the light belongs to.
  15579. * @returns The scene
  15580. */
  15581. getScene(): Scene;
  15582. /**
  15583. * Callback defining a custom Projection Matrix Builder.
  15584. * This can be used to override the default projection matrix computation.
  15585. */
  15586. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15587. /**
  15588. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15589. * @param matrix The materix to updated with the projection information
  15590. * @param viewMatrix The transform matrix of the light
  15591. * @param renderList The list of mesh to render in the map
  15592. * @returns The current light
  15593. */
  15594. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15595. /**
  15596. * Gets the current depth scale used in ESM.
  15597. * @returns The scale
  15598. */
  15599. getDepthScale(): number;
  15600. /**
  15601. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15602. * @returns true if a cube texture needs to be use
  15603. */
  15604. needCube(): boolean;
  15605. /**
  15606. * Detects if the projection matrix requires to be recomputed this frame.
  15607. * @returns true if it requires to be recomputed otherwise, false.
  15608. */
  15609. needProjectionMatrixCompute(): boolean;
  15610. /**
  15611. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15612. */
  15613. forceProjectionMatrixCompute(): void;
  15614. /**
  15615. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15616. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15617. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15618. */
  15619. getShadowDirection(faceIndex?: number): Vector3;
  15620. /**
  15621. * Gets the minZ used for shadow according to both the scene and the light.
  15622. * @param activeCamera The camera we are returning the min for
  15623. * @returns the depth min z
  15624. */
  15625. getDepthMinZ(activeCamera: Camera): number;
  15626. /**
  15627. * Gets the maxZ used for shadow according to both the scene and the light.
  15628. * @param activeCamera The camera we are returning the max for
  15629. * @returns the depth max z
  15630. */
  15631. getDepthMaxZ(activeCamera: Camera): number;
  15632. }
  15633. /**
  15634. * Base implementation IShadowLight
  15635. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15636. */
  15637. abstract class ShadowLight extends Light implements IShadowLight {
  15638. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15639. protected _position: Vector3;
  15640. protected _setPosition(value: Vector3): void;
  15641. /**
  15642. * Sets the position the shadow will be casted from. Also use as the light position for both
  15643. * point and spot lights.
  15644. */
  15645. /**
  15646. * Sets the position the shadow will be casted from. Also use as the light position for both
  15647. * point and spot lights.
  15648. */
  15649. position: Vector3;
  15650. protected _direction: Vector3;
  15651. protected _setDirection(value: Vector3): void;
  15652. /**
  15653. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15654. * Also use as the light direction on spot and directional lights.
  15655. */
  15656. /**
  15657. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15658. * Also use as the light direction on spot and directional lights.
  15659. */
  15660. direction: Vector3;
  15661. private _shadowMinZ;
  15662. /**
  15663. * Gets the shadow projection clipping minimum z value.
  15664. */
  15665. /**
  15666. * Sets the shadow projection clipping minimum z value.
  15667. */
  15668. shadowMinZ: number;
  15669. private _shadowMaxZ;
  15670. /**
  15671. * Sets the shadow projection clipping maximum z value.
  15672. */
  15673. /**
  15674. * Gets the shadow projection clipping maximum z value.
  15675. */
  15676. shadowMaxZ: number;
  15677. /**
  15678. * Callback defining a custom Projection Matrix Builder.
  15679. * This can be used to override the default projection matrix computation.
  15680. */
  15681. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15682. /**
  15683. * The transformed position. Position of the light in world space taking parenting in account.
  15684. */
  15685. transformedPosition: Vector3;
  15686. /**
  15687. * The transformed direction. Direction of the light in world space taking parenting in account.
  15688. */
  15689. transformedDirection: Vector3;
  15690. private _needProjectionMatrixCompute;
  15691. /**
  15692. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15693. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15694. */
  15695. computeTransformedInformation(): boolean;
  15696. /**
  15697. * Return the depth scale used for the shadow map.
  15698. * @returns the depth scale.
  15699. */
  15700. getDepthScale(): number;
  15701. /**
  15702. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15703. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15704. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15705. */
  15706. getShadowDirection(faceIndex?: number): Vector3;
  15707. /**
  15708. * Returns the ShadowLight absolute position in the World.
  15709. * @returns the position vector in world space
  15710. */
  15711. getAbsolutePosition(): Vector3;
  15712. /**
  15713. * Sets the ShadowLight direction toward the passed target.
  15714. * @param target The point tot target in local space
  15715. * @returns the updated ShadowLight direction
  15716. */
  15717. setDirectionToTarget(target: Vector3): Vector3;
  15718. /**
  15719. * Returns the light rotation in euler definition.
  15720. * @returns the x y z rotation in local space.
  15721. */
  15722. getRotation(): Vector3;
  15723. /**
  15724. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15725. * @returns true if a cube texture needs to be use
  15726. */
  15727. needCube(): boolean;
  15728. /**
  15729. * Detects if the projection matrix requires to be recomputed this frame.
  15730. * @returns true if it requires to be recomputed otherwise, false.
  15731. */
  15732. needProjectionMatrixCompute(): boolean;
  15733. /**
  15734. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15735. */
  15736. forceProjectionMatrixCompute(): void;
  15737. /** @hidden */
  15738. _initCache(): void;
  15739. /** @hidden */
  15740. _isSynchronized(): boolean;
  15741. /**
  15742. * Computes the world matrix of the node
  15743. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15744. * @returns the world matrix
  15745. */
  15746. computeWorldMatrix(force?: boolean): Matrix;
  15747. /**
  15748. * Gets the minZ used for shadow according to both the scene and the light.
  15749. * @param activeCamera The camera we are returning the min for
  15750. * @returns the depth min z
  15751. */
  15752. getDepthMinZ(activeCamera: Camera): number;
  15753. /**
  15754. * Gets the maxZ used for shadow according to both the scene and the light.
  15755. * @param activeCamera The camera we are returning the max for
  15756. * @returns the depth max z
  15757. */
  15758. getDepthMaxZ(activeCamera: Camera): number;
  15759. /**
  15760. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15761. * @param matrix The materix to updated with the projection information
  15762. * @param viewMatrix The transform matrix of the light
  15763. * @param renderList The list of mesh to render in the map
  15764. * @returns The current light
  15765. */
  15766. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15767. }
  15768. }
  15769. declare module BABYLON {
  15770. /**
  15771. * A spot light is defined by a position, a direction, an angle, and an exponent.
  15772. * These values define a cone of light starting from the position, emitting toward the direction.
  15773. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  15774. * and the exponent defines the speed of the decay of the light with distance (reach).
  15775. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15776. */
  15777. class SpotLight extends ShadowLight {
  15778. private _angle;
  15779. private _innerAngle;
  15780. private _cosHalfAngle;
  15781. private _lightAngleScale;
  15782. private _lightAngleOffset;
  15783. /**
  15784. * Gets the cone angle of the spot light in Radians.
  15785. */
  15786. /**
  15787. * Sets the cone angle of the spot light in Radians.
  15788. */
  15789. angle: number;
  15790. /**
  15791. * Only used in gltf falloff mode, this defines the angle where
  15792. * the directional falloff will start before cutting at angle which could be seen
  15793. * as outer angle.
  15794. */
  15795. /**
  15796. * Only used in gltf falloff mode, this defines the angle where
  15797. * the directional falloff will start before cutting at angle which could be seen
  15798. * as outer angle.
  15799. */
  15800. innerAngle: number;
  15801. private _shadowAngleScale;
  15802. /**
  15803. * Allows scaling the angle of the light for shadow generation only.
  15804. */
  15805. /**
  15806. * Allows scaling the angle of the light for shadow generation only.
  15807. */
  15808. shadowAngleScale: number;
  15809. /**
  15810. * The light decay speed with the distance from the emission spot.
  15811. */
  15812. exponent: number;
  15813. private _projectionTextureMatrix;
  15814. /**
  15815. * Allows reading the projecton texture
  15816. */
  15817. readonly projectionTextureMatrix: Matrix;
  15818. protected _projectionTextureLightNear: number;
  15819. /**
  15820. * Gets the near clip of the Spotlight for texture projection.
  15821. */
  15822. /**
  15823. * Sets the near clip of the Spotlight for texture projection.
  15824. */
  15825. projectionTextureLightNear: number;
  15826. protected _projectionTextureLightFar: number;
  15827. /**
  15828. * Gets the far clip of the Spotlight for texture projection.
  15829. */
  15830. /**
  15831. * Sets the far clip of the Spotlight for texture projection.
  15832. */
  15833. projectionTextureLightFar: number;
  15834. protected _projectionTextureUpDirection: Vector3;
  15835. /**
  15836. * Gets the Up vector of the Spotlight for texture projection.
  15837. */
  15838. /**
  15839. * Sets the Up vector of the Spotlight for texture projection.
  15840. */
  15841. projectionTextureUpDirection: Vector3;
  15842. private _projectionTexture;
  15843. /**
  15844. * Gets the projection texture of the light.
  15845. */
  15846. /**
  15847. * Sets the projection texture of the light.
  15848. */
  15849. projectionTexture: Nullable<BaseTexture>;
  15850. private _projectionTextureViewLightDirty;
  15851. private _projectionTextureProjectionLightDirty;
  15852. private _projectionTextureDirty;
  15853. private _projectionTextureViewTargetVector;
  15854. private _projectionTextureViewLightMatrix;
  15855. private _projectionTextureProjectionLightMatrix;
  15856. private _projectionTextureScalingMatrix;
  15857. /**
  15858. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  15859. * It can cast shadows.
  15860. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15861. * @param name The light friendly name
  15862. * @param position The position of the spot light in the scene
  15863. * @param direction The direction of the light in the scene
  15864. * @param angle The cone angle of the light in Radians
  15865. * @param exponent The light decay speed with the distance from the emission spot
  15866. * @param scene The scene the lights belongs to
  15867. */
  15868. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  15869. /**
  15870. * Returns the string "SpotLight".
  15871. * @returns the class name
  15872. */
  15873. getClassName(): string;
  15874. /**
  15875. * Returns the integer 2.
  15876. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15877. */
  15878. getTypeID(): number;
  15879. /**
  15880. * Overrides the direction setter to recompute the projection texture view light Matrix.
  15881. */
  15882. protected _setDirection(value: Vector3): void;
  15883. /**
  15884. * Overrides the position setter to recompute the projection texture view light Matrix.
  15885. */
  15886. protected _setPosition(value: Vector3): void;
  15887. /**
  15888. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  15889. * Returns the SpotLight.
  15890. */
  15891. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15892. protected _computeProjectionTextureViewLightMatrix(): void;
  15893. protected _computeProjectionTextureProjectionLightMatrix(): void;
  15894. /**
  15895. * Main function for light texture projection matrix computing.
  15896. */
  15897. protected _computeProjectionTextureMatrix(): void;
  15898. protected _buildUniformLayout(): void;
  15899. private _computeAngleValues;
  15900. /**
  15901. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  15902. * @param effect The effect to update
  15903. * @param lightIndex The index of the light in the effect to update
  15904. * @returns The spot light
  15905. */
  15906. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  15907. /**
  15908. * Disposes the light and the associated resources.
  15909. */
  15910. dispose(): void;
  15911. /**
  15912. * Prepares the list of defines specific to the light type.
  15913. * @param defines the list of defines
  15914. * @param lightIndex defines the index of the light for the effect
  15915. */
  15916. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15917. }
  15918. }
  15919. declare module BABYLON {
  15920. /**
  15921. * Interface used to present a loading screen while loading a scene
  15922. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  15923. */
  15924. interface ILoadingScreen {
  15925. /**
  15926. * Function called to display the loading screen
  15927. */
  15928. displayLoadingUI: () => void;
  15929. /**
  15930. * Function called to hide the loading screen
  15931. */
  15932. hideLoadingUI: () => void;
  15933. /**
  15934. * Gets or sets the color to use for the background
  15935. */
  15936. loadingUIBackgroundColor: string;
  15937. /**
  15938. * Gets or sets the text to display while loading
  15939. */
  15940. loadingUIText: string;
  15941. }
  15942. /**
  15943. * Class used for the default loading screen
  15944. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  15945. */
  15946. class DefaultLoadingScreen implements ILoadingScreen {
  15947. private _renderingCanvas;
  15948. private _loadingText;
  15949. private _loadingDivBackgroundColor;
  15950. private _loadingDiv;
  15951. private _loadingTextDiv;
  15952. /**
  15953. * Creates a new default loading screen
  15954. * @param _renderingCanvas defines the canvas used to render the scene
  15955. * @param _loadingText defines the default text to display
  15956. * @param _loadingDivBackgroundColor defines the default background color
  15957. */
  15958. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  15959. /**
  15960. * Function called to display the loading screen
  15961. */
  15962. displayLoadingUI(): void;
  15963. /**
  15964. * Function called to hide the loading screen
  15965. */
  15966. hideLoadingUI(): void;
  15967. /**
  15968. * Gets or sets the text to display while loading
  15969. */
  15970. loadingUIText: string;
  15971. /**
  15972. * Gets or sets the color to use for the background
  15973. */
  15974. loadingUIBackgroundColor: string;
  15975. private _resizeLoadingUI;
  15976. }
  15977. }
  15978. declare module BABYLON {
  15979. /**
  15980. * Class used to represent data loading progression
  15981. */
  15982. class SceneLoaderProgressEvent {
  15983. /** defines if data length to load can be evaluated */
  15984. readonly lengthComputable: boolean;
  15985. /** defines the loaded data length */
  15986. readonly loaded: number;
  15987. /** defines the data length to load */
  15988. readonly total: number;
  15989. /**
  15990. * Create a new progress event
  15991. * @param lengthComputable defines if data length to load can be evaluated
  15992. * @param loaded defines the loaded data length
  15993. * @param total defines the data length to load
  15994. */
  15995. constructor(
  15996. /** defines if data length to load can be evaluated */
  15997. lengthComputable: boolean,
  15998. /** defines the loaded data length */
  15999. loaded: number,
  16000. /** defines the data length to load */
  16001. total: number);
  16002. /**
  16003. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16004. * @param event defines the source event
  16005. * @returns a new SceneLoaderProgressEvent
  16006. */
  16007. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16008. }
  16009. /**
  16010. * Interface used by SceneLoader plugins to define supported file extensions
  16011. */
  16012. interface ISceneLoaderPluginExtensions {
  16013. /**
  16014. * Defines the list of supported extensions
  16015. */
  16016. [extension: string]: {
  16017. isBinary: boolean;
  16018. };
  16019. }
  16020. /**
  16021. * Interface used by SceneLoader plugin factory
  16022. */
  16023. interface ISceneLoaderPluginFactory {
  16024. /**
  16025. * Defines the name of the factory
  16026. */
  16027. name: string;
  16028. /**
  16029. * Function called to create a new plugin
  16030. * @return the new plugin
  16031. */
  16032. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16033. /**
  16034. * Boolean indicating if the plugin can direct load specific data
  16035. */
  16036. canDirectLoad?: (data: string) => boolean;
  16037. }
  16038. /**
  16039. * Interface used to define a SceneLoader plugin
  16040. */
  16041. interface ISceneLoaderPlugin {
  16042. /**
  16043. * The friendly name of this plugin.
  16044. */
  16045. name: string;
  16046. /**
  16047. * The file extensions supported by this plugin.
  16048. */
  16049. extensions: string | ISceneLoaderPluginExtensions;
  16050. /**
  16051. * Import meshes into a scene.
  16052. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16053. * @param scene The scene to import into
  16054. * @param data The data to import
  16055. * @param rootUrl The root url for scene and resources
  16056. * @param meshes The meshes array to import into
  16057. * @param particleSystems The particle systems array to import into
  16058. * @param skeletons The skeletons array to import into
  16059. * @param onError The callback when import fails
  16060. * @returns True if successful or false otherwise
  16061. */
  16062. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16063. /**
  16064. * Load into a scene.
  16065. * @param scene The scene to load into
  16066. * @param data The data to import
  16067. * @param rootUrl The root url for scene and resources
  16068. * @param onError The callback when import fails
  16069. * @returns true if successful or false otherwise
  16070. */
  16071. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16072. /**
  16073. * The callback that returns true if the data can be directly loaded.
  16074. */
  16075. canDirectLoad?: (data: string) => boolean;
  16076. /**
  16077. * The callback that allows custom handling of the root url based on the response url.
  16078. */
  16079. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16080. /**
  16081. * Load into an asset container.
  16082. * @param scene The scene to load into
  16083. * @param data The data to import
  16084. * @param rootUrl The root url for scene and resources
  16085. * @param onError The callback when import fails
  16086. * @returns The loaded asset container
  16087. */
  16088. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16089. }
  16090. /**
  16091. * Interface used to define an async SceneLoader plugin
  16092. */
  16093. interface ISceneLoaderPluginAsync {
  16094. /**
  16095. * The friendly name of this plugin.
  16096. */
  16097. name: string;
  16098. /**
  16099. * The file extensions supported by this plugin.
  16100. */
  16101. extensions: string | ISceneLoaderPluginExtensions;
  16102. /**
  16103. * Import meshes into a scene.
  16104. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16105. * @param scene The scene to import into
  16106. * @param data The data to import
  16107. * @param rootUrl The root url for scene and resources
  16108. * @param onProgress The callback when the load progresses
  16109. * @param fileName Defines the name of the file to load
  16110. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16111. */
  16112. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16113. meshes: AbstractMesh[];
  16114. particleSystems: IParticleSystem[];
  16115. skeletons: Skeleton[];
  16116. animationGroups: AnimationGroup[];
  16117. }>;
  16118. /**
  16119. * Load into a scene.
  16120. * @param scene The scene to load into
  16121. * @param data The data to import
  16122. * @param rootUrl The root url for scene and resources
  16123. * @param onProgress The callback when the load progresses
  16124. * @param fileName Defines the name of the file to load
  16125. * @returns Nothing
  16126. */
  16127. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16128. /**
  16129. * The callback that returns true if the data can be directly loaded.
  16130. */
  16131. canDirectLoad?: (data: string) => boolean;
  16132. /**
  16133. * The callback that allows custom handling of the root url based on the response url.
  16134. */
  16135. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16136. /**
  16137. * Load into an asset container.
  16138. * @param scene The scene to load into
  16139. * @param data The data to import
  16140. * @param rootUrl The root url for scene and resources
  16141. * @param onProgress The callback when the load progresses
  16142. * @param fileName Defines the name of the file to load
  16143. * @returns The loaded asset container
  16144. */
  16145. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16146. }
  16147. /**
  16148. * Class used to load scene from various file formats using registered plugins
  16149. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16150. */
  16151. class SceneLoader {
  16152. private static _ForceFullSceneLoadingForIncremental;
  16153. private static _ShowLoadingScreen;
  16154. private static _CleanBoneMatrixWeights;
  16155. /**
  16156. * No logging while loading
  16157. */
  16158. static readonly NO_LOGGING: number;
  16159. /**
  16160. * Minimal logging while loading
  16161. */
  16162. static readonly MINIMAL_LOGGING: number;
  16163. /**
  16164. * Summary logging while loading
  16165. */
  16166. static readonly SUMMARY_LOGGING: number;
  16167. /**
  16168. * Detailled logging while loading
  16169. */
  16170. static readonly DETAILED_LOGGING: number;
  16171. private static _loggingLevel;
  16172. /**
  16173. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16174. */
  16175. static ForceFullSceneLoadingForIncremental: boolean;
  16176. /**
  16177. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16178. */
  16179. static ShowLoadingScreen: boolean;
  16180. /**
  16181. * Defines the current logging level (while loading the scene)
  16182. * @ignorenaming
  16183. */
  16184. static loggingLevel: number;
  16185. /**
  16186. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16187. */
  16188. static CleanBoneMatrixWeights: boolean;
  16189. /**
  16190. * Event raised when a plugin is used to load a scene
  16191. */
  16192. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16193. private static _registeredPlugins;
  16194. private static _getDefaultPlugin;
  16195. private static _getPluginForExtension;
  16196. private static _getPluginForDirectLoad;
  16197. private static _getPluginForFilename;
  16198. private static _getDirectLoad;
  16199. private static _loadData;
  16200. private static _getFileInfo;
  16201. /**
  16202. * Gets a plugin that can load the given extension
  16203. * @param extension defines the extension to load
  16204. * @returns a plugin or null if none works
  16205. */
  16206. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16207. /**
  16208. * Gets a boolean indicating that the given extension can be loaded
  16209. * @param extension defines the extension to load
  16210. * @returns true if the extension is supported
  16211. */
  16212. static IsPluginForExtensionAvailable(extension: string): boolean;
  16213. /**
  16214. * Adds a new plugin to the list of registered plugins
  16215. * @param plugin defines the plugin to add
  16216. */
  16217. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16218. /**
  16219. * Import meshes into a scene
  16220. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16221. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16222. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16223. * @param scene the instance of BABYLON.Scene to append to
  16224. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16225. * @param onProgress a callback with a progress event for each file being loaded
  16226. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16227. * @param pluginExtension the extension used to determine the plugin
  16228. * @returns The loaded plugin
  16229. */
  16230. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16231. /**
  16232. * Import meshes into a scene
  16233. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16234. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16235. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16236. * @param scene the instance of BABYLON.Scene to append to
  16237. * @param onProgress a callback with a progress event for each file being loaded
  16238. * @param pluginExtension the extension used to determine the plugin
  16239. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16240. */
  16241. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16242. meshes: AbstractMesh[];
  16243. particleSystems: IParticleSystem[];
  16244. skeletons: Skeleton[];
  16245. animationGroups: AnimationGroup[];
  16246. }>;
  16247. /**
  16248. * Load a scene
  16249. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16250. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16251. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16252. * @param onSuccess a callback with the scene when import succeeds
  16253. * @param onProgress a callback with a progress event for each file being loaded
  16254. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16255. * @param pluginExtension the extension used to determine the plugin
  16256. * @returns The loaded plugin
  16257. */
  16258. static Load(rootUrl: string, sceneFilename: string, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16259. /**
  16260. * Load a scene
  16261. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16262. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16263. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16264. * @param onProgress a callback with a progress event for each file being loaded
  16265. * @param pluginExtension the extension used to determine the plugin
  16266. * @returns The loaded scene
  16267. */
  16268. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16269. /**
  16270. * Append a scene
  16271. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16272. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16273. * @param scene is the instance of BABYLON.Scene to append to
  16274. * @param onSuccess a callback with the scene when import succeeds
  16275. * @param onProgress a callback with a progress event for each file being loaded
  16276. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16277. * @param pluginExtension the extension used to determine the plugin
  16278. * @returns The loaded plugin
  16279. */
  16280. static Append(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16281. /**
  16282. * Append a scene
  16283. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16284. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16285. * @param scene is the instance of BABYLON.Scene to append to
  16286. * @param onProgress a callback with a progress event for each file being loaded
  16287. * @param pluginExtension the extension used to determine the plugin
  16288. * @returns The given scene
  16289. */
  16290. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16291. /**
  16292. * Load a scene into an asset container
  16293. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16294. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16295. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16296. * @param onSuccess a callback with the scene when import succeeds
  16297. * @param onProgress a callback with a progress event for each file being loaded
  16298. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16299. * @param pluginExtension the extension used to determine the plugin
  16300. * @returns The loaded plugin
  16301. */
  16302. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16303. /**
  16304. * Load a scene into an asset container
  16305. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16306. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16307. * @param scene is the instance of BABYLON.Scene to append to
  16308. * @param onProgress a callback with a progress event for each file being loaded
  16309. * @param pluginExtension the extension used to determine the plugin
  16310. * @returns The loaded asset container
  16311. */
  16312. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16313. }
  16314. }
  16315. declare module BABYLON {
  16316. /**
  16317. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16318. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16319. * 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;
  16320. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16321. */
  16322. class ColorCurves {
  16323. private _dirty;
  16324. private _tempColor;
  16325. private _globalCurve;
  16326. private _highlightsCurve;
  16327. private _midtonesCurve;
  16328. private _shadowsCurve;
  16329. private _positiveCurve;
  16330. private _negativeCurve;
  16331. private _globalHue;
  16332. private _globalDensity;
  16333. private _globalSaturation;
  16334. private _globalExposure;
  16335. /**
  16336. * Gets the global Hue value.
  16337. * 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).
  16338. */
  16339. /**
  16340. * Sets the global Hue value.
  16341. * 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).
  16342. */
  16343. globalHue: number;
  16344. /**
  16345. * Gets the global Density value.
  16346. * 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.
  16347. * Values less than zero provide a filter of opposite hue.
  16348. */
  16349. /**
  16350. * Sets the global Density value.
  16351. * 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.
  16352. * Values less than zero provide a filter of opposite hue.
  16353. */
  16354. globalDensity: number;
  16355. /**
  16356. * Gets the global Saturation value.
  16357. * 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.
  16358. */
  16359. /**
  16360. * Sets the global Saturation value.
  16361. * 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.
  16362. */
  16363. globalSaturation: number;
  16364. /**
  16365. * Gets the global Exposure value.
  16366. * 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.
  16367. */
  16368. /**
  16369. * Sets the global Exposure value.
  16370. * 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.
  16371. */
  16372. globalExposure: number;
  16373. private _highlightsHue;
  16374. private _highlightsDensity;
  16375. private _highlightsSaturation;
  16376. private _highlightsExposure;
  16377. /**
  16378. * Gets the highlights Hue value.
  16379. * 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).
  16380. */
  16381. /**
  16382. * Sets the highlights Hue value.
  16383. * 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).
  16384. */
  16385. highlightsHue: number;
  16386. /**
  16387. * Gets the highlights Density value.
  16388. * 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.
  16389. * Values less than zero provide a filter of opposite hue.
  16390. */
  16391. /**
  16392. * Sets the highlights Density value.
  16393. * 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.
  16394. * Values less than zero provide a filter of opposite hue.
  16395. */
  16396. highlightsDensity: number;
  16397. /**
  16398. * Gets the highlights Saturation value.
  16399. * 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.
  16400. */
  16401. /**
  16402. * Sets the highlights Saturation value.
  16403. * 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.
  16404. */
  16405. highlightsSaturation: number;
  16406. /**
  16407. * Gets the highlights Exposure value.
  16408. * 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.
  16409. */
  16410. /**
  16411. * Sets the highlights Exposure value.
  16412. * 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.
  16413. */
  16414. highlightsExposure: number;
  16415. private _midtonesHue;
  16416. private _midtonesDensity;
  16417. private _midtonesSaturation;
  16418. private _midtonesExposure;
  16419. /**
  16420. * Gets the midtones Hue value.
  16421. * 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).
  16422. */
  16423. /**
  16424. * Sets the midtones Hue value.
  16425. * 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).
  16426. */
  16427. midtonesHue: number;
  16428. /**
  16429. * Gets the midtones Density value.
  16430. * 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.
  16431. * Values less than zero provide a filter of opposite hue.
  16432. */
  16433. /**
  16434. * Sets the midtones Density value.
  16435. * 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.
  16436. * Values less than zero provide a filter of opposite hue.
  16437. */
  16438. midtonesDensity: number;
  16439. /**
  16440. * Gets the midtones Saturation value.
  16441. * 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.
  16442. */
  16443. /**
  16444. * Sets the midtones Saturation value.
  16445. * 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.
  16446. */
  16447. midtonesSaturation: number;
  16448. /**
  16449. * Gets the midtones Exposure value.
  16450. * 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.
  16451. */
  16452. /**
  16453. * Sets the midtones Exposure value.
  16454. * 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.
  16455. */
  16456. midtonesExposure: number;
  16457. private _shadowsHue;
  16458. private _shadowsDensity;
  16459. private _shadowsSaturation;
  16460. private _shadowsExposure;
  16461. /**
  16462. * Gets the shadows Hue value.
  16463. * 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).
  16464. */
  16465. /**
  16466. * Sets the shadows Hue value.
  16467. * 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).
  16468. */
  16469. shadowsHue: number;
  16470. /**
  16471. * Gets the shadows Density value.
  16472. * 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.
  16473. * Values less than zero provide a filter of opposite hue.
  16474. */
  16475. /**
  16476. * Sets the shadows Density value.
  16477. * 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.
  16478. * Values less than zero provide a filter of opposite hue.
  16479. */
  16480. shadowsDensity: number;
  16481. /**
  16482. * Gets the shadows Saturation value.
  16483. * 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.
  16484. */
  16485. /**
  16486. * Sets the shadows Saturation value.
  16487. * 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.
  16488. */
  16489. shadowsSaturation: number;
  16490. /**
  16491. * Gets the shadows Exposure value.
  16492. * 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.
  16493. */
  16494. /**
  16495. * Sets the shadows Exposure value.
  16496. * 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.
  16497. */
  16498. shadowsExposure: number;
  16499. /**
  16500. * Returns the class name
  16501. * @returns The class name
  16502. */
  16503. getClassName(): string;
  16504. /**
  16505. * Binds the color curves to the shader.
  16506. * @param colorCurves The color curve to bind
  16507. * @param effect The effect to bind to
  16508. * @param positiveUniform The positive uniform shader parameter
  16509. * @param neutralUniform The neutral uniform shader parameter
  16510. * @param negativeUniform The negative uniform shader parameter
  16511. */
  16512. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16513. /**
  16514. * Prepare the list of uniforms associated with the ColorCurves effects.
  16515. * @param uniformsList The list of uniforms used in the effect
  16516. */
  16517. static PrepareUniforms(uniformsList: string[]): void;
  16518. /**
  16519. * Returns color grading data based on a hue, density, saturation and exposure value.
  16520. * @param filterHue The hue of the color filter.
  16521. * @param filterDensity The density of the color filter.
  16522. * @param saturation The saturation.
  16523. * @param exposure The exposure.
  16524. * @param result The result data container.
  16525. */
  16526. private getColorGradingDataToRef;
  16527. /**
  16528. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16529. * @param value The input slider value in range [-100,100].
  16530. * @returns Adjusted value.
  16531. */
  16532. private static applyColorGradingSliderNonlinear;
  16533. /**
  16534. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16535. * @param hue The hue (H) input.
  16536. * @param saturation The saturation (S) input.
  16537. * @param brightness The brightness (B) input.
  16538. * @result An RGBA color represented as Vector4.
  16539. */
  16540. private static fromHSBToRef;
  16541. /**
  16542. * Returns a value clamped between min and max
  16543. * @param value The value to clamp
  16544. * @param min The minimum of value
  16545. * @param max The maximum of value
  16546. * @returns The clamped value.
  16547. */
  16548. private static clamp;
  16549. /**
  16550. * Clones the current color curve instance.
  16551. * @return The cloned curves
  16552. */
  16553. clone(): ColorCurves;
  16554. /**
  16555. * Serializes the current color curve instance to a json representation.
  16556. * @return a JSON representation
  16557. */
  16558. serialize(): any;
  16559. /**
  16560. * Parses the color curve from a json representation.
  16561. * @param source the JSON source to parse
  16562. * @return The parsed curves
  16563. */
  16564. static Parse(source: any): ColorCurves;
  16565. }
  16566. }
  16567. declare module BABYLON {
  16568. /**
  16569. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16570. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16571. */
  16572. class EffectFallbacks {
  16573. private _defines;
  16574. private _currentRank;
  16575. private _maxRank;
  16576. private _mesh;
  16577. /**
  16578. * Removes the fallback from the bound mesh.
  16579. */
  16580. unBindMesh(): void;
  16581. /**
  16582. * Adds a fallback on the specified property.
  16583. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16584. * @param define The name of the define in the shader
  16585. */
  16586. addFallback(rank: number, define: string): void;
  16587. /**
  16588. * Sets the mesh to use CPU skinning when needing to fallback.
  16589. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16590. * @param mesh The mesh to use the fallbacks.
  16591. */
  16592. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16593. /**
  16594. * Checks to see if more fallbacks are still availible.
  16595. */
  16596. readonly isMoreFallbacks: boolean;
  16597. /**
  16598. * Removes the defines that shoould be removed when falling back.
  16599. * @param currentDefines defines the current define statements for the shader.
  16600. * @param effect defines the current effect we try to compile
  16601. * @returns The resulting defines with defines of the current rank removed.
  16602. */
  16603. reduce(currentDefines: string, effect: Effect): string;
  16604. }
  16605. /**
  16606. * Options to be used when creating an effect.
  16607. */
  16608. class EffectCreationOptions {
  16609. /**
  16610. * Atrributes that will be used in the shader.
  16611. */
  16612. attributes: string[];
  16613. /**
  16614. * Uniform varible names that will be set in the shader.
  16615. */
  16616. uniformsNames: string[];
  16617. /**
  16618. * Uniform buffer varible names that will be set in the shader.
  16619. */
  16620. uniformBuffersNames: string[];
  16621. /**
  16622. * Sampler texture variable names that will be set in the shader.
  16623. */
  16624. samplers: string[];
  16625. /**
  16626. * Define statements that will be set in the shader.
  16627. */
  16628. defines: any;
  16629. /**
  16630. * Possible fallbacks for this effect to improve performance when needed.
  16631. */
  16632. fallbacks: Nullable<EffectFallbacks>;
  16633. /**
  16634. * Callback that will be called when the shader is compiled.
  16635. */
  16636. onCompiled: Nullable<(effect: Effect) => void>;
  16637. /**
  16638. * Callback that will be called if an error occurs during shader compilation.
  16639. */
  16640. onError: Nullable<(effect: Effect, errors: string) => void>;
  16641. /**
  16642. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16643. */
  16644. indexParameters: any;
  16645. /**
  16646. * Max number of lights that can be used in the shader.
  16647. */
  16648. maxSimultaneousLights: number;
  16649. /**
  16650. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16651. */
  16652. transformFeedbackVaryings: Nullable<string[]>;
  16653. }
  16654. /**
  16655. * Effect containing vertex and fragment shader that can be executed on an object.
  16656. */
  16657. class Effect {
  16658. /**
  16659. * Name of the effect.
  16660. */
  16661. name: any;
  16662. /**
  16663. * String container all the define statements that should be set on the shader.
  16664. */
  16665. defines: string;
  16666. /**
  16667. * Callback that will be called when the shader is compiled.
  16668. */
  16669. onCompiled: Nullable<(effect: Effect) => void>;
  16670. /**
  16671. * Callback that will be called if an error occurs during shader compilation.
  16672. */
  16673. onError: Nullable<(effect: Effect, errors: string) => void>;
  16674. /**
  16675. * Callback that will be called when effect is bound.
  16676. */
  16677. onBind: Nullable<(effect: Effect) => void>;
  16678. /**
  16679. * Unique ID of the effect.
  16680. */
  16681. uniqueId: number;
  16682. /**
  16683. * Observable that will be called when the shader is compiled.
  16684. */
  16685. onCompileObservable: Observable<Effect>;
  16686. /**
  16687. * Observable that will be called if an error occurs during shader compilation.
  16688. */
  16689. onErrorObservable: Observable<Effect>;
  16690. /** @hidden */
  16691. _onBindObservable: Nullable<Observable<Effect>>;
  16692. /**
  16693. * Observable that will be called when effect is bound.
  16694. */
  16695. readonly onBindObservable: Observable<Effect>;
  16696. /** @hidden */
  16697. _bonesComputationForcedToCPU: boolean;
  16698. private static _uniqueIdSeed;
  16699. private _engine;
  16700. private _uniformBuffersNames;
  16701. private _uniformsNames;
  16702. private _samplers;
  16703. private _isReady;
  16704. private _compilationError;
  16705. private _attributesNames;
  16706. private _attributes;
  16707. private _uniforms;
  16708. /**
  16709. * Key for the effect.
  16710. * @hidden
  16711. */
  16712. _key: string;
  16713. private _indexParameters;
  16714. private _fallbacks;
  16715. private _vertexSourceCode;
  16716. private _fragmentSourceCode;
  16717. private _vertexSourceCodeOverride;
  16718. private _fragmentSourceCodeOverride;
  16719. private _transformFeedbackVaryings;
  16720. /**
  16721. * Compiled shader to webGL program.
  16722. * @hidden
  16723. */
  16724. _program: WebGLProgram;
  16725. private _valueCache;
  16726. private static _baseCache;
  16727. /**
  16728. * Instantiates an effect.
  16729. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16730. * @param baseName Name of the effect.
  16731. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16732. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16733. * @param samplers List of sampler variables that will be passed to the shader.
  16734. * @param engine Engine to be used to render the effect
  16735. * @param defines Define statements to be added to the shader.
  16736. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16737. * @param onCompiled Callback that will be called when the shader is compiled.
  16738. * @param onError Callback that will be called if an error occurs during shader compilation.
  16739. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16740. */
  16741. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  16742. /**
  16743. * Unique key for this effect
  16744. */
  16745. readonly key: string;
  16746. /**
  16747. * If the effect has been compiled and prepared.
  16748. * @returns if the effect is compiled and prepared.
  16749. */
  16750. isReady(): boolean;
  16751. /**
  16752. * The engine the effect was initialized with.
  16753. * @returns the engine.
  16754. */
  16755. getEngine(): Engine;
  16756. /**
  16757. * The compiled webGL program for the effect
  16758. * @returns the webGL program.
  16759. */
  16760. getProgram(): WebGLProgram;
  16761. /**
  16762. * The set of names of attribute variables for the shader.
  16763. * @returns An array of attribute names.
  16764. */
  16765. getAttributesNames(): string[];
  16766. /**
  16767. * Returns the attribute at the given index.
  16768. * @param index The index of the attribute.
  16769. * @returns The location of the attribute.
  16770. */
  16771. getAttributeLocation(index: number): number;
  16772. /**
  16773. * Returns the attribute based on the name of the variable.
  16774. * @param name of the attribute to look up.
  16775. * @returns the attribute location.
  16776. */
  16777. getAttributeLocationByName(name: string): number;
  16778. /**
  16779. * The number of attributes.
  16780. * @returns the numnber of attributes.
  16781. */
  16782. getAttributesCount(): number;
  16783. /**
  16784. * Gets the index of a uniform variable.
  16785. * @param uniformName of the uniform to look up.
  16786. * @returns the index.
  16787. */
  16788. getUniformIndex(uniformName: string): number;
  16789. /**
  16790. * Returns the attribute based on the name of the variable.
  16791. * @param uniformName of the uniform to look up.
  16792. * @returns the location of the uniform.
  16793. */
  16794. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  16795. /**
  16796. * Returns an array of sampler variable names
  16797. * @returns The array of sampler variable neames.
  16798. */
  16799. getSamplers(): string[];
  16800. /**
  16801. * The error from the last compilation.
  16802. * @returns the error string.
  16803. */
  16804. getCompilationError(): string;
  16805. /**
  16806. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  16807. * @param func The callback to be used.
  16808. */
  16809. executeWhenCompiled(func: (effect: Effect) => void): void;
  16810. /** @hidden */
  16811. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  16812. /** @hidden */
  16813. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  16814. /** @hidden */
  16815. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  16816. private _processShaderConversion;
  16817. private _processIncludes;
  16818. private _processPrecision;
  16819. /**
  16820. * Recompiles the webGL program
  16821. * @param vertexSourceCode The source code for the vertex shader.
  16822. * @param fragmentSourceCode The source code for the fragment shader.
  16823. * @param onCompiled Callback called when completed.
  16824. * @param onError Callback called on error.
  16825. * @hidden
  16826. */
  16827. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  16828. /**
  16829. * Gets the uniform locations of the the specified variable names
  16830. * @param names THe names of the variables to lookup.
  16831. * @returns Array of locations in the same order as variable names.
  16832. */
  16833. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  16834. /**
  16835. * Prepares the effect
  16836. * @hidden
  16837. */
  16838. _prepareEffect(): void;
  16839. /**
  16840. * Checks if the effect is supported. (Must be called after compilation)
  16841. */
  16842. readonly isSupported: boolean;
  16843. /**
  16844. * Binds a texture to the engine to be used as output of the shader.
  16845. * @param channel Name of the output variable.
  16846. * @param texture Texture to bind.
  16847. * @hidden
  16848. */
  16849. _bindTexture(channel: string, texture: InternalTexture): void;
  16850. /**
  16851. * Sets a texture on the engine to be used in the shader.
  16852. * @param channel Name of the sampler variable.
  16853. * @param texture Texture to set.
  16854. */
  16855. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16856. /**
  16857. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16858. * @param channel Name of the sampler variable.
  16859. * @param texture Texture to set.
  16860. */
  16861. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16862. /**
  16863. * Sets an array of textures on the engine to be used in the shader.
  16864. * @param channel Name of the variable.
  16865. * @param textures Textures to set.
  16866. */
  16867. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16868. /**
  16869. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  16870. * @param channel Name of the sampler variable.
  16871. * @param postProcess Post process to get the input texture from.
  16872. */
  16873. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16874. /**
  16875. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16876. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  16877. * @param channel Name of the sampler variable.
  16878. * @param postProcess Post process to get the output texture from.
  16879. */
  16880. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16881. /** @hidden */
  16882. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  16883. /** @hidden */
  16884. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  16885. /** @hidden */
  16886. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  16887. /** @hidden */
  16888. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  16889. /**
  16890. * Binds a buffer to a uniform.
  16891. * @param buffer Buffer to bind.
  16892. * @param name Name of the uniform variable to bind to.
  16893. */
  16894. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16895. /**
  16896. * Binds block to a uniform.
  16897. * @param blockName Name of the block to bind.
  16898. * @param index Index to bind.
  16899. */
  16900. bindUniformBlock(blockName: string, index: number): void;
  16901. /**
  16902. * Sets an interger value on a uniform variable.
  16903. * @param uniformName Name of the variable.
  16904. * @param value Value to be set.
  16905. * @returns this effect.
  16906. */
  16907. setInt(uniformName: string, value: number): Effect;
  16908. /**
  16909. * Sets an int array on a uniform variable.
  16910. * @param uniformName Name of the variable.
  16911. * @param array array to be set.
  16912. * @returns this effect.
  16913. */
  16914. setIntArray(uniformName: string, array: Int32Array): Effect;
  16915. /**
  16916. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  16917. * @param uniformName Name of the variable.
  16918. * @param array array to be set.
  16919. * @returns this effect.
  16920. */
  16921. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16922. /**
  16923. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  16924. * @param uniformName Name of the variable.
  16925. * @param array array to be set.
  16926. * @returns this effect.
  16927. */
  16928. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16929. /**
  16930. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  16931. * @param uniformName Name of the variable.
  16932. * @param array array to be set.
  16933. * @returns this effect.
  16934. */
  16935. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16936. /**
  16937. * Sets an float array on a uniform variable.
  16938. * @param uniformName Name of the variable.
  16939. * @param array array to be set.
  16940. * @returns this effect.
  16941. */
  16942. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16943. /**
  16944. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  16945. * @param uniformName Name of the variable.
  16946. * @param array array to be set.
  16947. * @returns this effect.
  16948. */
  16949. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16950. /**
  16951. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  16952. * @param uniformName Name of the variable.
  16953. * @param array array to be set.
  16954. * @returns this effect.
  16955. */
  16956. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16957. /**
  16958. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  16959. * @param uniformName Name of the variable.
  16960. * @param array array to be set.
  16961. * @returns this effect.
  16962. */
  16963. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16964. /**
  16965. * Sets an array on a uniform variable.
  16966. * @param uniformName Name of the variable.
  16967. * @param array array to be set.
  16968. * @returns this effect.
  16969. */
  16970. setArray(uniformName: string, array: number[]): Effect;
  16971. /**
  16972. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  16973. * @param uniformName Name of the variable.
  16974. * @param array array to be set.
  16975. * @returns this effect.
  16976. */
  16977. setArray2(uniformName: string, array: number[]): Effect;
  16978. /**
  16979. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  16980. * @param uniformName Name of the variable.
  16981. * @param array array to be set.
  16982. * @returns this effect.
  16983. */
  16984. setArray3(uniformName: string, array: number[]): Effect;
  16985. /**
  16986. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  16987. * @param uniformName Name of the variable.
  16988. * @param array array to be set.
  16989. * @returns this effect.
  16990. */
  16991. setArray4(uniformName: string, array: number[]): Effect;
  16992. /**
  16993. * Sets matrices on a uniform variable.
  16994. * @param uniformName Name of the variable.
  16995. * @param matrices matrices to be set.
  16996. * @returns this effect.
  16997. */
  16998. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16999. /**
  17000. * Sets matrix on a uniform variable.
  17001. * @param uniformName Name of the variable.
  17002. * @param matrix matrix to be set.
  17003. * @returns this effect.
  17004. */
  17005. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17006. /**
  17007. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  17008. * @param uniformName Name of the variable.
  17009. * @param matrix matrix to be set.
  17010. * @returns this effect.
  17011. */
  17012. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17013. /**
  17014. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17015. * @param uniformName Name of the variable.
  17016. * @param matrix matrix to be set.
  17017. * @returns this effect.
  17018. */
  17019. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17020. /**
  17021. * Sets a float on a uniform variable.
  17022. * @param uniformName Name of the variable.
  17023. * @param value value to be set.
  17024. * @returns this effect.
  17025. */
  17026. setFloat(uniformName: string, value: number): Effect;
  17027. /**
  17028. * Sets a boolean on a uniform variable.
  17029. * @param uniformName Name of the variable.
  17030. * @param bool value to be set.
  17031. * @returns this effect.
  17032. */
  17033. setBool(uniformName: string, bool: boolean): Effect;
  17034. /**
  17035. * Sets a Vector2 on a uniform variable.
  17036. * @param uniformName Name of the variable.
  17037. * @param vector2 vector2 to be set.
  17038. * @returns this effect.
  17039. */
  17040. setVector2(uniformName: string, vector2: Vector2): Effect;
  17041. /**
  17042. * Sets a float2 on a uniform variable.
  17043. * @param uniformName Name of the variable.
  17044. * @param x First float in float2.
  17045. * @param y Second float in float2.
  17046. * @returns this effect.
  17047. */
  17048. setFloat2(uniformName: string, x: number, y: number): Effect;
  17049. /**
  17050. * Sets a Vector3 on a uniform variable.
  17051. * @param uniformName Name of the variable.
  17052. * @param vector3 Value to be set.
  17053. * @returns this effect.
  17054. */
  17055. setVector3(uniformName: string, vector3: Vector3): Effect;
  17056. /**
  17057. * Sets a float3 on a uniform variable.
  17058. * @param uniformName Name of the variable.
  17059. * @param x First float in float3.
  17060. * @param y Second float in float3.
  17061. * @param z Third float in float3.
  17062. * @returns this effect.
  17063. */
  17064. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17065. /**
  17066. * Sets a Vector4 on a uniform variable.
  17067. * @param uniformName Name of the variable.
  17068. * @param vector4 Value to be set.
  17069. * @returns this effect.
  17070. */
  17071. setVector4(uniformName: string, vector4: Vector4): Effect;
  17072. /**
  17073. * Sets a float4 on a uniform variable.
  17074. * @param uniformName Name of the variable.
  17075. * @param x First float in float4.
  17076. * @param y Second float in float4.
  17077. * @param z Third float in float4.
  17078. * @param w Fourth float in float4.
  17079. * @returns this effect.
  17080. */
  17081. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17082. /**
  17083. * Sets a Color3 on a uniform variable.
  17084. * @param uniformName Name of the variable.
  17085. * @param color3 Value to be set.
  17086. * @returns this effect.
  17087. */
  17088. setColor3(uniformName: string, color3: Color3): Effect;
  17089. /**
  17090. * Sets a Color4 on a uniform variable.
  17091. * @param uniformName Name of the variable.
  17092. * @param color3 Value to be set.
  17093. * @param alpha Alpha value to be set.
  17094. * @returns this effect.
  17095. */
  17096. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17097. /**
  17098. * Sets a Color4 on a uniform variable
  17099. * @param uniformName defines the name of the variable
  17100. * @param color4 defines the value to be set
  17101. * @returns this effect.
  17102. */
  17103. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17104. /**
  17105. * This function will add a new shader to the shader store
  17106. * @param name the name of the shader
  17107. * @param pixelShader optional pixel shader content
  17108. * @param vertexShader optional vertex shader content
  17109. */
  17110. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17111. /**
  17112. * Store of each shader (The can be looked up using effect.key)
  17113. */
  17114. static ShadersStore: {
  17115. [key: string]: string;
  17116. };
  17117. /**
  17118. * Store of each included file for a shader (The can be looked up using effect.key)
  17119. */
  17120. static IncludesShadersStore: {
  17121. [key: string]: string;
  17122. };
  17123. /**
  17124. * Resets the cache of effects.
  17125. */
  17126. static ResetCache(): void;
  17127. }
  17128. }
  17129. declare module BABYLON {
  17130. /**
  17131. * This represents all the required information to add a fresnel effect on a material:
  17132. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17133. */
  17134. class FresnelParameters {
  17135. private _isEnabled;
  17136. /**
  17137. * Define if the fresnel effect is enable or not.
  17138. */
  17139. isEnabled: boolean;
  17140. /**
  17141. * Define the color used on edges (grazing angle)
  17142. */
  17143. leftColor: Color3;
  17144. /**
  17145. * Define the color used on center
  17146. */
  17147. rightColor: Color3;
  17148. /**
  17149. * Define bias applied to computed fresnel term
  17150. */
  17151. bias: number;
  17152. /**
  17153. * Defined the power exponent applied to fresnel term
  17154. */
  17155. power: number;
  17156. /**
  17157. * Clones the current fresnel and its valuues
  17158. * @returns a clone fresnel configuration
  17159. */
  17160. clone(): FresnelParameters;
  17161. /**
  17162. * Serializes the current fresnel parameters to a JSON representation.
  17163. * @return the JSON serialization
  17164. */
  17165. serialize(): any;
  17166. /**
  17167. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17168. * @param parsedFresnelParameters Define the JSON representation
  17169. * @returns the parsed parameters
  17170. */
  17171. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17172. }
  17173. }
  17174. declare module BABYLON {
  17175. /**
  17176. * Interface to follow in your material defines to integrate easily the
  17177. * Image proccessing functions.
  17178. * @hidden
  17179. */
  17180. interface IImageProcessingConfigurationDefines {
  17181. IMAGEPROCESSING: boolean;
  17182. VIGNETTE: boolean;
  17183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17184. VIGNETTEBLENDMODEOPAQUE: boolean;
  17185. TONEMAPPING: boolean;
  17186. TONEMAPPING_ACES: boolean;
  17187. CONTRAST: boolean;
  17188. EXPOSURE: boolean;
  17189. COLORCURVES: boolean;
  17190. COLORGRADING: boolean;
  17191. COLORGRADING3D: boolean;
  17192. SAMPLER3DGREENDEPTH: boolean;
  17193. SAMPLER3DBGRMAP: boolean;
  17194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17195. }
  17196. /**
  17197. * @hidden
  17198. */
  17199. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17200. IMAGEPROCESSING: boolean;
  17201. VIGNETTE: boolean;
  17202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17203. VIGNETTEBLENDMODEOPAQUE: boolean;
  17204. TONEMAPPING: boolean;
  17205. TONEMAPPING_ACES: boolean;
  17206. CONTRAST: boolean;
  17207. COLORCURVES: boolean;
  17208. COLORGRADING: boolean;
  17209. COLORGRADING3D: boolean;
  17210. SAMPLER3DGREENDEPTH: boolean;
  17211. SAMPLER3DBGRMAP: boolean;
  17212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17213. EXPOSURE: boolean;
  17214. constructor();
  17215. }
  17216. /**
  17217. * This groups together the common properties used for image processing either in direct forward pass
  17218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17219. * or not.
  17220. */
  17221. class ImageProcessingConfiguration {
  17222. /**
  17223. * Default tone mapping applied in BabylonJS.
  17224. */
  17225. static readonly TONEMAPPING_STANDARD: number;
  17226. /**
  17227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17228. * to other engines rendering to increase portability.
  17229. */
  17230. static readonly TONEMAPPING_ACES: number;
  17231. /**
  17232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17233. */
  17234. colorCurves: Nullable<ColorCurves>;
  17235. private _colorCurvesEnabled;
  17236. /**
  17237. * Gets wether the color curves effect is enabled.
  17238. */
  17239. /**
  17240. * Sets wether the color curves effect is enabled.
  17241. */
  17242. colorCurvesEnabled: boolean;
  17243. private _colorGradingTexture;
  17244. /**
  17245. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17246. */
  17247. /**
  17248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17249. */
  17250. colorGradingTexture: Nullable<BaseTexture>;
  17251. private _colorGradingEnabled;
  17252. /**
  17253. * Gets wether the color grading effect is enabled.
  17254. */
  17255. /**
  17256. * Sets wether the color grading effect is enabled.
  17257. */
  17258. colorGradingEnabled: boolean;
  17259. private _colorGradingWithGreenDepth;
  17260. /**
  17261. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17262. */
  17263. /**
  17264. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17265. */
  17266. colorGradingWithGreenDepth: boolean;
  17267. private _colorGradingBGR;
  17268. /**
  17269. * Gets wether the color grading texture contains BGR values.
  17270. */
  17271. /**
  17272. * Sets wether the color grading texture contains BGR values.
  17273. */
  17274. colorGradingBGR: boolean;
  17275. /** @hidden */
  17276. _exposure: number;
  17277. /**
  17278. * Gets the Exposure used in the effect.
  17279. */
  17280. /**
  17281. * Sets the Exposure used in the effect.
  17282. */
  17283. exposure: number;
  17284. private _toneMappingEnabled;
  17285. /**
  17286. * Gets wether the tone mapping effect is enabled.
  17287. */
  17288. /**
  17289. * Sets wether the tone mapping effect is enabled.
  17290. */
  17291. toneMappingEnabled: boolean;
  17292. private _toneMappingType;
  17293. /**
  17294. * Gets the type of tone mapping effect.
  17295. */
  17296. /**
  17297. * Sets the type of tone mapping effect used in BabylonJS.
  17298. */
  17299. toneMappingType: number;
  17300. protected _contrast: number;
  17301. /**
  17302. * Gets the contrast used in the effect.
  17303. */
  17304. /**
  17305. * Sets the contrast used in the effect.
  17306. */
  17307. contrast: number;
  17308. /**
  17309. * Vignette stretch size.
  17310. */
  17311. vignetteStretch: number;
  17312. /**
  17313. * Vignette centre X Offset.
  17314. */
  17315. vignetteCentreX: number;
  17316. /**
  17317. * Vignette centre Y Offset.
  17318. */
  17319. vignetteCentreY: number;
  17320. /**
  17321. * Vignette weight or intensity of the vignette effect.
  17322. */
  17323. vignetteWeight: number;
  17324. /**
  17325. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17326. * if vignetteEnabled is set to true.
  17327. */
  17328. vignetteColor: Color4;
  17329. /**
  17330. * Camera field of view used by the Vignette effect.
  17331. */
  17332. vignetteCameraFov: number;
  17333. private _vignetteBlendMode;
  17334. /**
  17335. * Gets the vignette blend mode allowing different kind of effect.
  17336. */
  17337. /**
  17338. * Sets the vignette blend mode allowing different kind of effect.
  17339. */
  17340. vignetteBlendMode: number;
  17341. private _vignetteEnabled;
  17342. /**
  17343. * Gets wether the vignette effect is enabled.
  17344. */
  17345. /**
  17346. * Sets wether the vignette effect is enabled.
  17347. */
  17348. vignetteEnabled: boolean;
  17349. private _applyByPostProcess;
  17350. /**
  17351. * Gets wether the image processing is applied through a post process or not.
  17352. */
  17353. /**
  17354. * Sets wether the image processing is applied through a post process or not.
  17355. */
  17356. applyByPostProcess: boolean;
  17357. private _isEnabled;
  17358. /**
  17359. * Gets wether the image processing is enabled or not.
  17360. */
  17361. /**
  17362. * Sets wether the image processing is enabled or not.
  17363. */
  17364. isEnabled: boolean;
  17365. /**
  17366. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17367. */
  17368. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17369. /**
  17370. * Method called each time the image processing information changes requires to recompile the effect.
  17371. */
  17372. protected _updateParameters(): void;
  17373. /**
  17374. * Gets the current class name.
  17375. * @return "ImageProcessingConfiguration"
  17376. */
  17377. getClassName(): string;
  17378. /**
  17379. * Prepare the list of uniforms associated with the Image Processing effects.
  17380. * @param uniforms The list of uniforms used in the effect
  17381. * @param defines the list of defines currently in use
  17382. */
  17383. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17384. /**
  17385. * Prepare the list of samplers associated with the Image Processing effects.
  17386. * @param samplersList The list of uniforms used in the effect
  17387. * @param defines the list of defines currently in use
  17388. */
  17389. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17390. /**
  17391. * Prepare the list of defines associated to the shader.
  17392. * @param defines the list of defines to complete
  17393. * @param forPostProcess Define if we are currently in post process mode or not
  17394. */
  17395. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17396. /**
  17397. * Returns true if all the image processing information are ready.
  17398. * @returns True if ready, otherwise, false
  17399. */
  17400. isReady(): boolean;
  17401. /**
  17402. * Binds the image processing to the shader.
  17403. * @param effect The effect to bind to
  17404. * @param aspectRatio Define the current aspect ratio of the effect
  17405. */
  17406. bind(effect: Effect, aspectRatio?: number): void;
  17407. /**
  17408. * Clones the current image processing instance.
  17409. * @return The cloned image processing
  17410. */
  17411. clone(): ImageProcessingConfiguration;
  17412. /**
  17413. * Serializes the current image processing instance to a json representation.
  17414. * @return a JSON representation
  17415. */
  17416. serialize(): any;
  17417. /**
  17418. * Parses the image processing from a json representation.
  17419. * @param source the JSON source to parse
  17420. * @return The parsed image processing
  17421. */
  17422. static Parse(source: any): ImageProcessingConfiguration;
  17423. private static _VIGNETTEMODE_MULTIPLY;
  17424. private static _VIGNETTEMODE_OPAQUE;
  17425. /**
  17426. * Used to apply the vignette as a mix with the pixel color.
  17427. */
  17428. static readonly VIGNETTEMODE_MULTIPLY: number;
  17429. /**
  17430. * Used to apply the vignette as a replacement of the pixel color.
  17431. */
  17432. static readonly VIGNETTEMODE_OPAQUE: number;
  17433. }
  17434. }
  17435. declare module BABYLON {
  17436. /**
  17437. * Manages the defines for the Material
  17438. */
  17439. class MaterialDefines {
  17440. private _keys;
  17441. private _isDirty;
  17442. /** @hidden */
  17443. _renderId: number;
  17444. /** @hidden */
  17445. _areLightsDirty: boolean;
  17446. /** @hidden */
  17447. _areAttributesDirty: boolean;
  17448. /** @hidden */
  17449. _areTexturesDirty: boolean;
  17450. /** @hidden */
  17451. _areFresnelDirty: boolean;
  17452. /** @hidden */
  17453. _areMiscDirty: boolean;
  17454. /** @hidden */
  17455. _areImageProcessingDirty: boolean;
  17456. /** @hidden */
  17457. _normals: boolean;
  17458. /** @hidden */
  17459. _uvs: boolean;
  17460. /** @hidden */
  17461. _needNormals: boolean;
  17462. /** @hidden */
  17463. _needUVs: boolean;
  17464. /**
  17465. * Specifies if the material needs to be re-calculated
  17466. */
  17467. readonly isDirty: boolean;
  17468. /**
  17469. * Marks the material to indicate that it has been re-calculated
  17470. */
  17471. markAsProcessed(): void;
  17472. /**
  17473. * Marks the material to indicate that it needs to be re-calculated
  17474. */
  17475. markAsUnprocessed(): void;
  17476. /**
  17477. * Marks the material to indicate all of its defines need to be re-calculated
  17478. */
  17479. markAllAsDirty(): void;
  17480. /**
  17481. * Marks the material to indicate that image processing needs to be re-calculated
  17482. */
  17483. markAsImageProcessingDirty(): void;
  17484. /**
  17485. * Marks the material to indicate the lights need to be re-calculated
  17486. */
  17487. markAsLightDirty(): void;
  17488. /**
  17489. * Marks the attribute state as changed
  17490. */
  17491. markAsAttributesDirty(): void;
  17492. /**
  17493. * Marks the texture state as changed
  17494. */
  17495. markAsTexturesDirty(): void;
  17496. /**
  17497. * Marks the fresnel state as changed
  17498. */
  17499. markAsFresnelDirty(): void;
  17500. /**
  17501. * Marks the misc state as changed
  17502. */
  17503. markAsMiscDirty(): void;
  17504. /**
  17505. * Rebuilds the material defines
  17506. */
  17507. rebuild(): void;
  17508. /**
  17509. * Specifies if two material defines are equal
  17510. * @param other - A material define instance to compare to
  17511. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17512. */
  17513. isEqual(other: MaterialDefines): boolean;
  17514. /**
  17515. * Clones this instance's defines to another instance
  17516. * @param other - material defines to clone values to
  17517. */
  17518. cloneTo(other: MaterialDefines): void;
  17519. /**
  17520. * Resets the material define values
  17521. */
  17522. reset(): void;
  17523. /**
  17524. * Converts the material define values to a string
  17525. * @returns - String of material define information
  17526. */
  17527. toString(): string;
  17528. }
  17529. /**
  17530. * Base class for the main features of a material in Babylon.js
  17531. */
  17532. class Material implements IAnimatable {
  17533. private static _TriangleFillMode;
  17534. private static _WireFrameFillMode;
  17535. private static _PointFillMode;
  17536. private static _PointListDrawMode;
  17537. private static _LineListDrawMode;
  17538. private static _LineLoopDrawMode;
  17539. private static _LineStripDrawMode;
  17540. private static _TriangleStripDrawMode;
  17541. private static _TriangleFanDrawMode;
  17542. /**
  17543. * Returns the triangle fill mode
  17544. */
  17545. static readonly TriangleFillMode: number;
  17546. /**
  17547. * Returns the wireframe mode
  17548. */
  17549. static readonly WireFrameFillMode: number;
  17550. /**
  17551. * Returns the point fill mode
  17552. */
  17553. static readonly PointFillMode: number;
  17554. /**
  17555. * Returns the point list draw mode
  17556. */
  17557. static readonly PointListDrawMode: number;
  17558. /**
  17559. * Returns the line list draw mode
  17560. */
  17561. static readonly LineListDrawMode: number;
  17562. /**
  17563. * Returns the line loop draw mode
  17564. */
  17565. static readonly LineLoopDrawMode: number;
  17566. /**
  17567. * Returns the line strip draw mode
  17568. */
  17569. static readonly LineStripDrawMode: number;
  17570. /**
  17571. * Returns the triangle strip draw mode
  17572. */
  17573. static readonly TriangleStripDrawMode: number;
  17574. /**
  17575. * Returns the triangle fan draw mode
  17576. */
  17577. static readonly TriangleFanDrawMode: number;
  17578. /**
  17579. * Stores the clock-wise side orientation
  17580. */
  17581. private static _ClockWiseSideOrientation;
  17582. /**
  17583. * Stores the counter clock-wise side orientation
  17584. */
  17585. private static _CounterClockWiseSideOrientation;
  17586. /**
  17587. * Returns the clock-wise side orientation
  17588. */
  17589. static readonly ClockWiseSideOrientation: number;
  17590. /**
  17591. * Returns the counter clock-wise side orientation
  17592. */
  17593. static readonly CounterClockWiseSideOrientation: number;
  17594. /**
  17595. * The dirty texture flag value
  17596. */
  17597. static readonly TextureDirtyFlag: number;
  17598. /**
  17599. * The dirty light flag value
  17600. */
  17601. static readonly LightDirtyFlag: number;
  17602. /**
  17603. * The dirty fresnel flag value
  17604. */
  17605. static readonly FresnelDirtyFlag: number;
  17606. /**
  17607. * The dirty attribute flag value
  17608. */
  17609. static readonly AttributesDirtyFlag: number;
  17610. /**
  17611. * The dirty misc flag value
  17612. */
  17613. static readonly MiscDirtyFlag: number;
  17614. /**
  17615. * The all dirty flag value
  17616. */
  17617. static readonly AllDirtyFlag: number;
  17618. /**
  17619. * The ID of the material
  17620. */
  17621. id: string;
  17622. /**
  17623. * Gets or sets the unique id of the material
  17624. */
  17625. uniqueId: number;
  17626. /**
  17627. * The name of the material
  17628. */
  17629. name: string;
  17630. /**
  17631. * Specifies if the ready state should be checked on each call
  17632. */
  17633. checkReadyOnEveryCall: boolean;
  17634. /**
  17635. * Specifies if the ready state should be checked once
  17636. */
  17637. checkReadyOnlyOnce: boolean;
  17638. /**
  17639. * The state of the material
  17640. */
  17641. state: string;
  17642. /**
  17643. * The alpha value of the material
  17644. */
  17645. protected _alpha: number;
  17646. /**
  17647. * Sets the alpha value of the material
  17648. */
  17649. /**
  17650. * Gets the alpha value of the material
  17651. */
  17652. alpha: number;
  17653. /**
  17654. * Specifies if back face culling is enabled
  17655. */
  17656. protected _backFaceCulling: boolean;
  17657. /**
  17658. * Sets the back-face culling state
  17659. */
  17660. /**
  17661. * Gets the back-face culling state
  17662. */
  17663. backFaceCulling: boolean;
  17664. /**
  17665. * Stores the value for side orientation
  17666. */
  17667. sideOrientation: number;
  17668. /**
  17669. * Callback triggered when the material is compiled
  17670. */
  17671. onCompiled: (effect: Effect) => void;
  17672. /**
  17673. * Callback triggered when an error occurs
  17674. */
  17675. onError: (effect: Effect, errors: string) => void;
  17676. /**
  17677. * Callback triggered to get the render target textures
  17678. */
  17679. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17680. /**
  17681. * Gets a boolean indicating that current material needs to register RTT
  17682. */
  17683. readonly hasRenderTargetTextures: boolean;
  17684. /**
  17685. * Specifies if the material should be serialized
  17686. */
  17687. doNotSerialize: boolean;
  17688. /**
  17689. * Specifies if the effect should be stored on sub meshes
  17690. */
  17691. storeEffectOnSubMeshes: boolean;
  17692. /**
  17693. * Stores the animations for the material
  17694. */
  17695. animations: Array<Animation>;
  17696. /**
  17697. * An event triggered when the material is disposed
  17698. */
  17699. onDisposeObservable: Observable<Material>;
  17700. /**
  17701. * An observer which watches for dispose events
  17702. */
  17703. private _onDisposeObserver;
  17704. private _onUnBindObservable;
  17705. /**
  17706. * Called during a dispose event
  17707. */
  17708. onDispose: () => void;
  17709. private _onBindObservable;
  17710. /**
  17711. * An event triggered when the material is bound
  17712. */
  17713. readonly onBindObservable: Observable<AbstractMesh>;
  17714. /**
  17715. * An observer which watches for bind events
  17716. */
  17717. private _onBindObserver;
  17718. /**
  17719. * Called during a bind event
  17720. */
  17721. onBind: (Mesh: AbstractMesh) => void;
  17722. /**
  17723. * An event triggered when the material is unbound
  17724. */
  17725. readonly onUnBindObservable: Observable<Material>;
  17726. /**
  17727. * Stores the value of the alpha mode
  17728. */
  17729. private _alphaMode;
  17730. /**
  17731. * Sets the value of the alpha mode.
  17732. *
  17733. * | Value | Type | Description |
  17734. * | --- | --- | --- |
  17735. * | 0 | ALPHA_DISABLE | |
  17736. * | 1 | ALPHA_ADD | |
  17737. * | 2 | ALPHA_COMBINE | |
  17738. * | 3 | ALPHA_SUBTRACT | |
  17739. * | 4 | ALPHA_MULTIPLY | |
  17740. * | 5 | ALPHA_MAXIMIZED | |
  17741. * | 6 | ALPHA_ONEONE | |
  17742. * | 7 | ALPHA_PREMULTIPLIED | |
  17743. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17744. * | 9 | ALPHA_INTERPOLATE | |
  17745. * | 10 | ALPHA_SCREENMODE | |
  17746. *
  17747. */
  17748. /**
  17749. * Gets the value of the alpha mode
  17750. */
  17751. alphaMode: number;
  17752. /**
  17753. * Stores the state of the need depth pre-pass value
  17754. */
  17755. private _needDepthPrePass;
  17756. /**
  17757. * Sets the need depth pre-pass value
  17758. */
  17759. /**
  17760. * Gets the depth pre-pass value
  17761. */
  17762. needDepthPrePass: boolean;
  17763. /**
  17764. * Specifies if depth writing should be disabled
  17765. */
  17766. disableDepthWrite: boolean;
  17767. /**
  17768. * Specifies if depth writing should be forced
  17769. */
  17770. forceDepthWrite: boolean;
  17771. /**
  17772. * Specifies if there should be a separate pass for culling
  17773. */
  17774. separateCullingPass: boolean;
  17775. /**
  17776. * Stores the state specifing if fog should be enabled
  17777. */
  17778. private _fogEnabled;
  17779. /**
  17780. * Sets the state for enabling fog
  17781. */
  17782. /**
  17783. * Gets the value of the fog enabled state
  17784. */
  17785. fogEnabled: boolean;
  17786. /**
  17787. * Stores the size of points
  17788. */
  17789. pointSize: number;
  17790. /**
  17791. * Stores the z offset value
  17792. */
  17793. zOffset: number;
  17794. /**
  17795. * Gets a value specifying if wireframe mode is enabled
  17796. */
  17797. /**
  17798. * Sets the state of wireframe mode
  17799. */
  17800. wireframe: boolean;
  17801. /**
  17802. * Gets the value specifying if point clouds are enabled
  17803. */
  17804. /**
  17805. * Sets the state of point cloud mode
  17806. */
  17807. pointsCloud: boolean;
  17808. /**
  17809. * Gets the material fill mode
  17810. */
  17811. /**
  17812. * Sets the material fill mode
  17813. */
  17814. fillMode: number;
  17815. /**
  17816. * @hidden
  17817. * Stores the effects for the material
  17818. */
  17819. _effect: Nullable<Effect>;
  17820. /**
  17821. * @hidden
  17822. * Specifies if the material was previously ready
  17823. */
  17824. _wasPreviouslyReady: boolean;
  17825. /**
  17826. * Specifies if uniform buffers should be used
  17827. */
  17828. private _useUBO;
  17829. /**
  17830. * Stores a reference to the scene
  17831. */
  17832. private _scene;
  17833. /**
  17834. * Stores the fill mode state
  17835. */
  17836. private _fillMode;
  17837. /**
  17838. * Specifies if the depth write state should be cached
  17839. */
  17840. private _cachedDepthWriteState;
  17841. /**
  17842. * Stores the uniform buffer
  17843. */
  17844. protected _uniformBuffer: UniformBuffer;
  17845. /**
  17846. * Creates a material instance
  17847. * @param name defines the name of the material
  17848. * @param scene defines the scene to reference
  17849. * @param doNotAdd specifies if the material should be added to the scene
  17850. */
  17851. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17852. /**
  17853. * Returns a string representation of the current material
  17854. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17855. * @returns a string with material information
  17856. */
  17857. toString(fullDetails?: boolean): string;
  17858. /**
  17859. * Gets the class name of the material
  17860. * @returns a string with the class name of the material
  17861. */
  17862. getClassName(): string;
  17863. /**
  17864. * Specifies if updates for the material been locked
  17865. */
  17866. readonly isFrozen: boolean;
  17867. /**
  17868. * Locks updates for the material
  17869. */
  17870. freeze(): void;
  17871. /**
  17872. * Unlocks updates for the material
  17873. */
  17874. unfreeze(): void;
  17875. /**
  17876. * Specifies if the material is ready to be used
  17877. * @param mesh defines the mesh to check
  17878. * @param useInstances specifies if instances should be used
  17879. * @returns a boolean indicating if the material is ready to be used
  17880. */
  17881. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17882. /**
  17883. * Specifies that the submesh is ready to be used
  17884. * @param mesh defines the mesh to check
  17885. * @param subMesh defines which submesh to check
  17886. * @param useInstances specifies that instances should be used
  17887. * @returns a boolean indicating that the submesh is ready or not
  17888. */
  17889. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17890. /**
  17891. * Returns the material effect
  17892. * @returns the effect associated with the material
  17893. */
  17894. getEffect(): Nullable<Effect>;
  17895. /**
  17896. * Returns the current scene
  17897. * @returns a Scene
  17898. */
  17899. getScene(): Scene;
  17900. /**
  17901. * Specifies if the material will require alpha blending
  17902. * @returns a boolean specifying if alpha blending is needed
  17903. */
  17904. needAlphaBlending(): boolean;
  17905. /**
  17906. * Specifies if the mesh will require alpha blending
  17907. * @param mesh defines the mesh to check
  17908. * @returns a boolean specifying if alpha blending is needed for the mesh
  17909. */
  17910. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17911. /**
  17912. * Specifies if this material should be rendered in alpha test mode
  17913. * @returns a boolean specifying if an alpha test is needed.
  17914. */
  17915. needAlphaTesting(): boolean;
  17916. /**
  17917. * Gets the texture used for the alpha test
  17918. * @returns the texture to use for alpha testing
  17919. */
  17920. getAlphaTestTexture(): Nullable<BaseTexture>;
  17921. /**
  17922. * Marks the material to indicate that it needs to be re-calculated
  17923. */
  17924. markDirty(): void;
  17925. /** @hidden */
  17926. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17927. /**
  17928. * Binds the material to the mesh
  17929. * @param world defines the world transformation matrix
  17930. * @param mesh defines the mesh to bind the material to
  17931. */
  17932. bind(world: Matrix, mesh?: Mesh): void;
  17933. /**
  17934. * Binds the submesh to the material
  17935. * @param world defines the world transformation matrix
  17936. * @param mesh defines the mesh containing the submesh
  17937. * @param subMesh defines the submesh to bind the material to
  17938. */
  17939. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17940. /**
  17941. * Binds the world matrix to the material
  17942. * @param world defines the world transformation matrix
  17943. */
  17944. bindOnlyWorldMatrix(world: Matrix): void;
  17945. /**
  17946. * Binds the scene's uniform buffer to the effect.
  17947. * @param effect defines the effect to bind to the scene uniform buffer
  17948. * @param sceneUbo defines the uniform buffer storing scene data
  17949. */
  17950. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17951. /**
  17952. * Binds the view matrix to the effect
  17953. * @param effect defines the effect to bind the view matrix to
  17954. */
  17955. bindView(effect: Effect): void;
  17956. /**
  17957. * Binds the view projection matrix to the effect
  17958. * @param effect defines the effect to bind the view projection matrix to
  17959. */
  17960. bindViewProjection(effect: Effect): void;
  17961. /**
  17962. * Specifies if material alpha testing should be turned on for the mesh
  17963. * @param mesh defines the mesh to check
  17964. */
  17965. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17966. /**
  17967. * Processes to execute after binding the material to a mesh
  17968. * @param mesh defines the rendered mesh
  17969. */
  17970. protected _afterBind(mesh?: Mesh): void;
  17971. /**
  17972. * Unbinds the material from the mesh
  17973. */
  17974. unbind(): void;
  17975. /**
  17976. * Gets the active textures from the material
  17977. * @returns an array of textures
  17978. */
  17979. getActiveTextures(): BaseTexture[];
  17980. /**
  17981. * Specifies if the material uses a texture
  17982. * @param texture defines the texture to check against the material
  17983. * @returns a boolean specifying if the material uses the texture
  17984. */
  17985. hasTexture(texture: BaseTexture): boolean;
  17986. /**
  17987. * Makes a duplicate of the material, and gives it a new name
  17988. * @param name defines the new name for the duplicated material
  17989. * @returns the cloned material
  17990. */
  17991. clone(name: string): Nullable<Material>;
  17992. /**
  17993. * Gets the meshes bound to the material
  17994. * @returns an array of meshes bound to the material
  17995. */
  17996. getBindedMeshes(): AbstractMesh[];
  17997. /**
  17998. * Force shader compilation
  17999. * @param mesh defines the mesh associated with this material
  18000. * @param onCompiled defines a function to execute once the material is compiled
  18001. * @param options defines the options to configure the compilation
  18002. */
  18003. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18004. clipPlane: boolean;
  18005. }>): void;
  18006. /**
  18007. * Force shader compilation
  18008. * @param mesh defines the mesh that will use this material
  18009. * @param options defines additional options for compiling the shaders
  18010. * @returns a promise that resolves when the compilation completes
  18011. */
  18012. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18013. clipPlane: boolean;
  18014. }>): Promise<void>;
  18015. /**
  18016. * Marks a define in the material to indicate that it needs to be re-computed
  18017. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18018. */
  18019. markAsDirty(flag: number): void;
  18020. /**
  18021. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18022. * @param func defines a function which checks material defines against the submeshes
  18023. */
  18024. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18025. /**
  18026. * Indicates that image processing needs to be re-calculated for all submeshes
  18027. */
  18028. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18029. /**
  18030. * Indicates that textures need to be re-calculated for all submeshes
  18031. */
  18032. protected _markAllSubMeshesAsTexturesDirty(): void;
  18033. /**
  18034. * Indicates that fresnel needs to be re-calculated for all submeshes
  18035. */
  18036. protected _markAllSubMeshesAsFresnelDirty(): void;
  18037. /**
  18038. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18039. */
  18040. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18041. /**
  18042. * Indicates that lights need to be re-calculated for all submeshes
  18043. */
  18044. protected _markAllSubMeshesAsLightsDirty(): void;
  18045. /**
  18046. * Indicates that attributes need to be re-calculated for all submeshes
  18047. */
  18048. protected _markAllSubMeshesAsAttributesDirty(): void;
  18049. /**
  18050. * Indicates that misc needs to be re-calculated for all submeshes
  18051. */
  18052. protected _markAllSubMeshesAsMiscDirty(): void;
  18053. /**
  18054. * Indicates that textures and misc need to be re-calculated for all submeshes
  18055. */
  18056. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18057. /**
  18058. * Disposes the material
  18059. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18060. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18061. */
  18062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18063. /**
  18064. * Serializes this material
  18065. * @returns the serialized material object
  18066. */
  18067. serialize(): any;
  18068. /**
  18069. * Creates a MultiMaterial from parsed MultiMaterial data.
  18070. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18071. * @param scene defines the hosting scene
  18072. * @returns a new MultiMaterial
  18073. */
  18074. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18075. /**
  18076. * Creates a material from parsed material data
  18077. * @param parsedMaterial defines parsed material data
  18078. * @param scene defines the hosting scene
  18079. * @param rootUrl defines the root URL to use to load textures
  18080. * @returns a new material
  18081. */
  18082. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18083. }
  18084. }
  18085. declare module BABYLON {
  18086. /**
  18087. * "Static Class" containing the most commonly used helper while dealing with material for
  18088. * rendering purpose.
  18089. *
  18090. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18091. *
  18092. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18093. */
  18094. class MaterialHelper {
  18095. /**
  18096. * Bind the current view position to an effect.
  18097. * @param effect The effect to be bound
  18098. * @param scene The scene the eyes position is used from
  18099. */
  18100. static BindEyePosition(effect: Effect, scene: Scene): void;
  18101. /**
  18102. * Helps preparing the defines values about the UVs in used in the effect.
  18103. * UVs are shared as much as we can accross channels in the shaders.
  18104. * @param texture The texture we are preparing the UVs for
  18105. * @param defines The defines to update
  18106. * @param key The channel key "diffuse", "specular"... used in the shader
  18107. */
  18108. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18109. /**
  18110. * Binds a texture matrix value to its corrsponding uniform
  18111. * @param texture The texture to bind the matrix for
  18112. * @param uniformBuffer The uniform buffer receivin the data
  18113. * @param key The channel key "diffuse", "specular"... used in the shader
  18114. */
  18115. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18116. /**
  18117. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18118. * @param mesh defines the current mesh
  18119. * @param scene defines the current scene
  18120. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18121. * @param pointsCloud defines if point cloud rendering has to be turned on
  18122. * @param fogEnabled defines if fog has to be turned on
  18123. * @param alphaTest defines if alpha testing has to be turned on
  18124. * @param defines defines the current list of defines
  18125. */
  18126. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18127. /**
  18128. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18129. * @param scene defines the current scene
  18130. * @param engine defines the current engine
  18131. * @param defines specifies the list of active defines
  18132. * @param useInstances defines if instances have to be turned on
  18133. * @param useClipPlane defines if clip plane have to be turned on
  18134. */
  18135. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18136. /**
  18137. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18138. * @param mesh The mesh containing the geometry data we will draw
  18139. * @param defines The defines to update
  18140. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18141. * @param useBones Precise whether bones should be used or not (override mesh info)
  18142. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18143. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18144. * @returns false if defines are considered not dirty and have not been checked
  18145. */
  18146. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18147. /**
  18148. * Prepares the defines related to the light information passed in parameter
  18149. * @param scene The scene we are intending to draw
  18150. * @param mesh The mesh the effect is compiling for
  18151. * @param defines The defines to update
  18152. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18153. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18154. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18155. * @returns true if normals will be required for the rest of the effect
  18156. */
  18157. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18158. /**
  18159. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18160. * that won t be acctive due to defines being turned off.
  18161. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18162. * @param samplersList The samplers list
  18163. * @param defines The defines helping in the list generation
  18164. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18165. */
  18166. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18167. /**
  18168. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18169. * @param defines The defines to update while falling back
  18170. * @param fallbacks The authorized effect fallbacks
  18171. * @param maxSimultaneousLights The maximum number of lights allowed
  18172. * @param rank the current rank of the Effect
  18173. * @returns The newly affected rank
  18174. */
  18175. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18176. /**
  18177. * Prepares the list of attributes required for morph targets according to the effect defines.
  18178. * @param attribs The current list of supported attribs
  18179. * @param mesh The mesh to prepare the morph targets attributes for
  18180. * @param defines The current Defines of the effect
  18181. */
  18182. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18183. /**
  18184. * Prepares the list of attributes required for bones according to the effect defines.
  18185. * @param attribs The current list of supported attribs
  18186. * @param mesh The mesh to prepare the bones attributes for
  18187. * @param defines The current Defines of the effect
  18188. * @param fallbacks The current efffect fallback strategy
  18189. */
  18190. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18191. /**
  18192. * Prepares the list of attributes required for instances according to the effect defines.
  18193. * @param attribs The current list of supported attribs
  18194. * @param defines The current Defines of the effect
  18195. */
  18196. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18197. /**
  18198. * Binds the light shadow information to the effect for the given mesh.
  18199. * @param light The light containing the generator
  18200. * @param scene The scene the lights belongs to
  18201. * @param mesh The mesh we are binding the information to render
  18202. * @param lightIndex The light index in the effect used to render the mesh
  18203. * @param effect The effect we are binding the data to
  18204. */
  18205. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18206. /**
  18207. * Binds the light information to the effect.
  18208. * @param light The light containing the generator
  18209. * @param effect The effect we are binding the data to
  18210. * @param lightIndex The light index in the effect used to render
  18211. */
  18212. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18213. /**
  18214. * Binds the lights information from the scene to the effect for the given mesh.
  18215. * @param scene The scene the lights belongs to
  18216. * @param mesh The mesh we are binding the information to render
  18217. * @param effect The effect we are binding the data to
  18218. * @param defines The generated defines for the effect
  18219. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18220. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18221. */
  18222. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18223. private static _tempFogColor;
  18224. /**
  18225. * Binds the fog information from the scene to the effect for the given mesh.
  18226. * @param scene The scene the lights belongs to
  18227. * @param mesh The mesh we are binding the information to render
  18228. * @param effect The effect we are binding the data to
  18229. * @param linearSpace Defines if the fog effect is applied in linear space
  18230. */
  18231. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18232. /**
  18233. * Binds the bones information from the mesh to the effect.
  18234. * @param mesh The mesh we are binding the information to render
  18235. * @param effect The effect we are binding the data to
  18236. */
  18237. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18238. /**
  18239. * Binds the morph targets information from the mesh to the effect.
  18240. * @param abstractMesh The mesh we are binding the information to render
  18241. * @param effect The effect we are binding the data to
  18242. */
  18243. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18244. /**
  18245. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18246. * @param defines The generated defines used in the effect
  18247. * @param effect The effect we are binding the data to
  18248. * @param scene The scene we are willing to render with logarithmic scale for
  18249. */
  18250. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18251. /**
  18252. * Binds the clip plane information from the scene to the effect.
  18253. * @param scene The scene the clip plane information are extracted from
  18254. * @param effect The effect we are binding the data to
  18255. */
  18256. static BindClipPlane(effect: Effect, scene: Scene): void;
  18257. }
  18258. }
  18259. declare module BABYLON {
  18260. /**
  18261. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18262. * separate meshes. This can be use to improve performances.
  18263. * @see http://doc.babylonjs.com/how_to/multi_materials
  18264. */
  18265. class MultiMaterial extends Material {
  18266. private _subMaterials;
  18267. /**
  18268. * Gets or Sets the list of Materials used within the multi material.
  18269. * They need to be ordered according to the submeshes order in the associated mesh
  18270. */
  18271. subMaterials: Nullable<Material>[];
  18272. /**
  18273. * Instantiates a new Multi Material
  18274. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18275. * separate meshes. This can be use to improve performances.
  18276. * @see http://doc.babylonjs.com/how_to/multi_materials
  18277. * @param name Define the name in the scene
  18278. * @param scene Define the scene the material belongs to
  18279. */
  18280. constructor(name: string, scene: Scene);
  18281. private _hookArray;
  18282. /**
  18283. * Get one of the submaterial by its index in the submaterials array
  18284. * @param index The index to look the sub material at
  18285. * @returns The Material if the index has been defined
  18286. */
  18287. getSubMaterial(index: number): Nullable<Material>;
  18288. /**
  18289. * Get the list of active textures for the whole sub materials list.
  18290. * @returns All the textures that will be used during the rendering
  18291. */
  18292. getActiveTextures(): BaseTexture[];
  18293. /**
  18294. * Gets the current class name of the material e.g. "MultiMaterial"
  18295. * Mainly use in serialization.
  18296. * @returns the class name
  18297. */
  18298. getClassName(): string;
  18299. /**
  18300. * Checks if the material is ready to render the requested sub mesh
  18301. * @param mesh Define the mesh the submesh belongs to
  18302. * @param subMesh Define the sub mesh to look readyness for
  18303. * @param useInstances Define whether or not the material is used with instances
  18304. * @returns true if ready, otherwise false
  18305. */
  18306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18307. /**
  18308. * Clones the current material and its related sub materials
  18309. * @param name Define the name of the newly cloned material
  18310. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18311. * @returns the cloned material
  18312. */
  18313. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18314. /**
  18315. * Serializes the materials into a JSON representation.
  18316. * @returns the JSON representation
  18317. */
  18318. serialize(): any;
  18319. /**
  18320. * Dispose the material and release its associated resources
  18321. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  18322. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  18323. */
  18324. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18325. }
  18326. }
  18327. declare module BABYLON {
  18328. /**
  18329. * Base class of materials working in push mode in babylon JS
  18330. * @hidden
  18331. */
  18332. class PushMaterial extends Material {
  18333. protected _activeEffect: Effect;
  18334. protected _normalMatrix: Matrix;
  18335. constructor(name: string, scene: Scene);
  18336. getEffect(): Effect;
  18337. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18338. /**
  18339. * Binds the given world matrix to the active effect
  18340. *
  18341. * @param world the matrix to bind
  18342. */
  18343. bindOnlyWorldMatrix(world: Matrix): void;
  18344. /**
  18345. * Binds the given normal matrix to the active effect
  18346. *
  18347. * @param normalMatrix the matrix to bind
  18348. */
  18349. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18350. bind(world: Matrix, mesh?: Mesh): void;
  18351. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18352. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18353. }
  18354. }
  18355. declare module BABYLON {
  18356. /**
  18357. * Defines the options associated with the creation of a shader material.
  18358. */
  18359. interface IShaderMaterialOptions {
  18360. /**
  18361. * Does the material work in alpha blend mode
  18362. */
  18363. needAlphaBlending: boolean;
  18364. /**
  18365. * Does the material work in alpha test mode
  18366. */
  18367. needAlphaTesting: boolean;
  18368. /**
  18369. * The list of attribute names used in the shader
  18370. */
  18371. attributes: string[];
  18372. /**
  18373. * The list of unifrom names used in the shader
  18374. */
  18375. uniforms: string[];
  18376. /**
  18377. * The list of UBO names used in the shader
  18378. */
  18379. uniformBuffers: string[];
  18380. /**
  18381. * The list of sampler names used in the shader
  18382. */
  18383. samplers: string[];
  18384. /**
  18385. * The list of defines used in the shader
  18386. */
  18387. defines: string[];
  18388. }
  18389. /**
  18390. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  18391. *
  18392. * This returned material effects how the mesh will look based on the code in the shaders.
  18393. *
  18394. * @see http://doc.babylonjs.com/how_to/shader_material
  18395. */
  18396. class ShaderMaterial extends Material {
  18397. private _shaderPath;
  18398. private _options;
  18399. private _textures;
  18400. private _textureArrays;
  18401. private _floats;
  18402. private _ints;
  18403. private _floatsArrays;
  18404. private _colors3;
  18405. private _colors3Arrays;
  18406. private _colors4;
  18407. private _vectors2;
  18408. private _vectors3;
  18409. private _vectors4;
  18410. private _matrices;
  18411. private _matrices3x3;
  18412. private _matrices2x2;
  18413. private _vectors2Arrays;
  18414. private _vectors3Arrays;
  18415. private _cachedWorldViewMatrix;
  18416. private _renderId;
  18417. /**
  18418. * Instantiate a new shader material.
  18419. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  18420. * This returned material effects how the mesh will look based on the code in the shaders.
  18421. * @see http://doc.babylonjs.com/how_to/shader_material
  18422. * @param name Define the name of the material in the scene
  18423. * @param scene Define the scene the material belongs to
  18424. * @param shaderPath Defines the route to the shader code in one of three ways:
  18425. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18426. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18427. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18428. * @param options Define the options used to create the shader
  18429. */
  18430. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18431. /**
  18432. * Gets the current class name of the material e.g. "ShaderMaterial"
  18433. * Mainly use in serialization.
  18434. * @returns the class name
  18435. */
  18436. getClassName(): string;
  18437. /**
  18438. * Specifies if the material will require alpha blending
  18439. * @returns a boolean specifying if alpha blending is needed
  18440. */
  18441. needAlphaBlending(): boolean;
  18442. /**
  18443. * Specifies if this material should be rendered in alpha test mode
  18444. * @returns a boolean specifying if an alpha test is needed.
  18445. */
  18446. needAlphaTesting(): boolean;
  18447. private _checkUniform;
  18448. /**
  18449. * Set a texture in the shader.
  18450. * @param name Define the name of the uniform samplers as defined in the shader
  18451. * @param texture Define the texture to bind to this sampler
  18452. * @return the material itself allowing "fluent" like uniform updates
  18453. */
  18454. setTexture(name: string, texture: Texture): ShaderMaterial;
  18455. /**
  18456. * Set a texture array in the shader.
  18457. * @param name Define the name of the uniform sampler array as defined in the shader
  18458. * @param textures Define the list of textures to bind to this sampler
  18459. * @return the material itself allowing "fluent" like uniform updates
  18460. */
  18461. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18462. /**
  18463. * Set a float in the shader.
  18464. * @param name Define the name of the uniform as defined in the shader
  18465. * @param value Define the value to give to the uniform
  18466. * @return the material itself allowing "fluent" like uniform updates
  18467. */
  18468. setFloat(name: string, value: number): ShaderMaterial;
  18469. /**
  18470. * Set a int in the shader.
  18471. * @param name Define the name of the uniform as defined in the shader
  18472. * @param value Define the value to give to the uniform
  18473. * @return the material itself allowing "fluent" like uniform updates
  18474. */
  18475. setInt(name: string, value: number): ShaderMaterial;
  18476. /**
  18477. * Set an array of floats in the shader.
  18478. * @param name Define the name of the uniform as defined in the shader
  18479. * @param value Define the value to give to the uniform
  18480. * @return the material itself allowing "fluent" like uniform updates
  18481. */
  18482. setFloats(name: string, value: number[]): ShaderMaterial;
  18483. /**
  18484. * Set a vec3 in the shader from a Color3.
  18485. * @param name Define the name of the uniform as defined in the shader
  18486. * @param value Define the value to give to the uniform
  18487. * @return the material itself allowing "fluent" like uniform updates
  18488. */
  18489. setColor3(name: string, value: Color3): ShaderMaterial;
  18490. /**
  18491. * Set a vec3 array in the shader from a Color3 array.
  18492. * @param name Define the name of the uniform as defined in the shader
  18493. * @param value Define the value to give to the uniform
  18494. * @return the material itself allowing "fluent" like uniform updates
  18495. */
  18496. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18497. /**
  18498. * Set a vec4 in the shader from a Color4.
  18499. * @param name Define the name of the uniform as defined in the shader
  18500. * @param value Define the value to give to the uniform
  18501. * @return the material itself allowing "fluent" like uniform updates
  18502. */
  18503. setColor4(name: string, value: Color4): ShaderMaterial;
  18504. /**
  18505. * Set a vec2 in the shader from a Vector2.
  18506. * @param name Define the name of the uniform as defined in the shader
  18507. * @param value Define the value to give to the uniform
  18508. * @return the material itself allowing "fluent" like uniform updates
  18509. */
  18510. setVector2(name: string, value: Vector2): ShaderMaterial;
  18511. /**
  18512. * Set a vec3 in the shader from a Vector3.
  18513. * @param name Define the name of the uniform as defined in the shader
  18514. * @param value Define the value to give to the uniform
  18515. * @return the material itself allowing "fluent" like uniform updates
  18516. */
  18517. setVector3(name: string, value: Vector3): ShaderMaterial;
  18518. /**
  18519. * Set a vec4 in the shader from a Vector4.
  18520. * @param name Define the name of the uniform as defined in the shader
  18521. * @param value Define the value to give to the uniform
  18522. * @return the material itself allowing "fluent" like uniform updates
  18523. */
  18524. setVector4(name: string, value: Vector4): ShaderMaterial;
  18525. /**
  18526. * Set a mat4 in the shader from a Matrix.
  18527. * @param name Define the name of the uniform as defined in the shader
  18528. * @param value Define the value to give to the uniform
  18529. * @return the material itself allowing "fluent" like uniform updates
  18530. */
  18531. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18532. /**
  18533. * Set a mat3 in the shader from a Float32Array.
  18534. * @param name Define the name of the uniform as defined in the shader
  18535. * @param value Define the value to give to the uniform
  18536. * @return the material itself allowing "fluent" like uniform updates
  18537. */
  18538. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18539. /**
  18540. * Set a mat2 in the shader from a Float32Array.
  18541. * @param name Define the name of the uniform as defined in the shader
  18542. * @param value Define the value to give to the uniform
  18543. * @return the material itself allowing "fluent" like uniform updates
  18544. */
  18545. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18546. /**
  18547. * Set a vec2 array in the shader from a number array.
  18548. * @param name Define the name of the uniform as defined in the shader
  18549. * @param value Define the value to give to the uniform
  18550. * @return the material itself allowing "fluent" like uniform updates
  18551. */
  18552. setArray2(name: string, value: number[]): ShaderMaterial;
  18553. /**
  18554. * Set a vec3 array in the shader from a number array.
  18555. * @param name Define the name of the uniform as defined in the shader
  18556. * @param value Define the value to give to the uniform
  18557. * @return the material itself allowing "fluent" like uniform updates
  18558. */
  18559. setArray3(name: string, value: number[]): ShaderMaterial;
  18560. private _checkCache;
  18561. /**
  18562. * Checks if the material is ready to render the requested mesh
  18563. * @param mesh Define the mesh to render
  18564. * @param useInstances Define whether or not the material is used with instances
  18565. * @returns true if ready, otherwise false
  18566. */
  18567. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18568. /**
  18569. * Binds the world matrix to the material
  18570. * @param world defines the world transformation matrix
  18571. */
  18572. bindOnlyWorldMatrix(world: Matrix): void;
  18573. /**
  18574. * Binds the material to the mesh
  18575. * @param world defines the world transformation matrix
  18576. * @param mesh defines the mesh to bind the material to
  18577. */
  18578. bind(world: Matrix, mesh?: Mesh): void;
  18579. /**
  18580. * Gets the active textures from the material
  18581. * @returns an array of textures
  18582. */
  18583. getActiveTextures(): BaseTexture[];
  18584. /**
  18585. * Specifies if the material uses a texture
  18586. * @param texture defines the texture to check against the material
  18587. * @returns a boolean specifying if the material uses the texture
  18588. */
  18589. hasTexture(texture: BaseTexture): boolean;
  18590. /**
  18591. * Makes a duplicate of the material, and gives it a new name
  18592. * @param name defines the new name for the duplicated material
  18593. * @returns the cloned material
  18594. */
  18595. clone(name: string): ShaderMaterial;
  18596. /**
  18597. * Disposes the material
  18598. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18599. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18600. */
  18601. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18602. /**
  18603. * Serializes this material in a JSON representation
  18604. * @returns the serialized material object
  18605. */
  18606. serialize(): any;
  18607. /**
  18608. * Creates a shader material from parsed shader material data
  18609. * @param source defines the JSON represnetation of the material
  18610. * @param scene defines the hosting scene
  18611. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18612. * @returns a new material
  18613. */
  18614. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18615. }
  18616. }
  18617. declare module BABYLON {
  18618. /** @hidden */
  18619. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18620. MAINUV1: boolean;
  18621. MAINUV2: boolean;
  18622. DIFFUSE: boolean;
  18623. DIFFUSEDIRECTUV: number;
  18624. AMBIENT: boolean;
  18625. AMBIENTDIRECTUV: number;
  18626. OPACITY: boolean;
  18627. OPACITYDIRECTUV: number;
  18628. OPACITYRGB: boolean;
  18629. REFLECTION: boolean;
  18630. EMISSIVE: boolean;
  18631. EMISSIVEDIRECTUV: number;
  18632. SPECULAR: boolean;
  18633. SPECULARDIRECTUV: number;
  18634. BUMP: boolean;
  18635. BUMPDIRECTUV: number;
  18636. PARALLAX: boolean;
  18637. PARALLAXOCCLUSION: boolean;
  18638. SPECULAROVERALPHA: boolean;
  18639. CLIPPLANE: boolean;
  18640. CLIPPLANE2: boolean;
  18641. CLIPPLANE3: boolean;
  18642. CLIPPLANE4: boolean;
  18643. ALPHATEST: boolean;
  18644. DEPTHPREPASS: boolean;
  18645. ALPHAFROMDIFFUSE: boolean;
  18646. POINTSIZE: boolean;
  18647. FOG: boolean;
  18648. SPECULARTERM: boolean;
  18649. DIFFUSEFRESNEL: boolean;
  18650. OPACITYFRESNEL: boolean;
  18651. REFLECTIONFRESNEL: boolean;
  18652. REFRACTIONFRESNEL: boolean;
  18653. EMISSIVEFRESNEL: boolean;
  18654. FRESNEL: boolean;
  18655. NORMAL: boolean;
  18656. UV1: boolean;
  18657. UV2: boolean;
  18658. VERTEXCOLOR: boolean;
  18659. VERTEXALPHA: boolean;
  18660. NUM_BONE_INFLUENCERS: number;
  18661. BonesPerMesh: number;
  18662. INSTANCES: boolean;
  18663. GLOSSINESS: boolean;
  18664. ROUGHNESS: boolean;
  18665. EMISSIVEASILLUMINATION: boolean;
  18666. LINKEMISSIVEWITHDIFFUSE: boolean;
  18667. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18668. LIGHTMAP: boolean;
  18669. LIGHTMAPDIRECTUV: number;
  18670. OBJECTSPACE_NORMALMAP: boolean;
  18671. USELIGHTMAPASSHADOWMAP: boolean;
  18672. REFLECTIONMAP_3D: boolean;
  18673. REFLECTIONMAP_SPHERICAL: boolean;
  18674. REFLECTIONMAP_PLANAR: boolean;
  18675. REFLECTIONMAP_CUBIC: boolean;
  18676. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18677. REFLECTIONMAP_PROJECTION: boolean;
  18678. REFLECTIONMAP_SKYBOX: boolean;
  18679. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  18680. REFLECTIONMAP_EXPLICIT: boolean;
  18681. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18682. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18683. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18684. INVERTCUBICMAP: boolean;
  18685. LOGARITHMICDEPTH: boolean;
  18686. REFRACTION: boolean;
  18687. REFRACTIONMAP_3D: boolean;
  18688. REFLECTIONOVERALPHA: boolean;
  18689. TWOSIDEDLIGHTING: boolean;
  18690. SHADOWFLOAT: boolean;
  18691. MORPHTARGETS: boolean;
  18692. MORPHTARGETS_NORMAL: boolean;
  18693. MORPHTARGETS_TANGENT: boolean;
  18694. NUM_MORPH_INFLUENCERS: number;
  18695. NONUNIFORMSCALING: boolean;
  18696. PREMULTIPLYALPHA: boolean;
  18697. IMAGEPROCESSING: boolean;
  18698. VIGNETTE: boolean;
  18699. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18700. VIGNETTEBLENDMODEOPAQUE: boolean;
  18701. TONEMAPPING: boolean;
  18702. TONEMAPPING_ACES: boolean;
  18703. CONTRAST: boolean;
  18704. COLORCURVES: boolean;
  18705. COLORGRADING: boolean;
  18706. COLORGRADING3D: boolean;
  18707. SAMPLER3DGREENDEPTH: boolean;
  18708. SAMPLER3DBGRMAP: boolean;
  18709. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18710. /**
  18711. * If the reflection texture on this material is in linear color space
  18712. * @hidden
  18713. */
  18714. IS_REFLECTION_LINEAR: boolean;
  18715. /**
  18716. * If the refraction texture on this material is in linear color space
  18717. * @hidden
  18718. */
  18719. IS_REFRACTION_LINEAR: boolean;
  18720. EXPOSURE: boolean;
  18721. constructor();
  18722. setReflectionMode(modeToEnable: string): void;
  18723. }
  18724. /**
  18725. * This is the default material used in Babylon. It is the best trade off between quality
  18726. * and performances.
  18727. * @see http://doc.babylonjs.com/babylon101/materials
  18728. */
  18729. class StandardMaterial extends PushMaterial {
  18730. private _diffuseTexture;
  18731. /**
  18732. * The basic texture of the material as viewed under a light.
  18733. */
  18734. diffuseTexture: Nullable<BaseTexture>;
  18735. private _ambientTexture;
  18736. /**
  18737. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18738. */
  18739. ambientTexture: Nullable<BaseTexture>;
  18740. private _opacityTexture;
  18741. /**
  18742. * Define the transparency of the material from a texture.
  18743. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18744. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18745. */
  18746. opacityTexture: Nullable<BaseTexture>;
  18747. private _reflectionTexture;
  18748. /**
  18749. * Define the texture used to display the reflection.
  18750. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18751. */
  18752. reflectionTexture: Nullable<BaseTexture>;
  18753. private _emissiveTexture;
  18754. /**
  18755. * Define texture of the material as if self lit.
  18756. * This will be mixed in the final result even in the absence of light.
  18757. */
  18758. emissiveTexture: Nullable<BaseTexture>;
  18759. private _specularTexture;
  18760. /**
  18761. * Define how the color and intensity of the highlight given by the light in the material.
  18762. */
  18763. specularTexture: Nullable<BaseTexture>;
  18764. private _bumpTexture;
  18765. /**
  18766. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18767. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  18768. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  18769. */
  18770. bumpTexture: Nullable<BaseTexture>;
  18771. private _lightmapTexture;
  18772. /**
  18773. * Complex lighting can be computationally expensive to compute at runtime.
  18774. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18775. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  18776. */
  18777. lightmapTexture: Nullable<BaseTexture>;
  18778. private _refractionTexture;
  18779. /**
  18780. * Define the texture used to display the refraction.
  18781. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18782. */
  18783. refractionTexture: Nullable<BaseTexture>;
  18784. /**
  18785. * The color of the material lit by the environmental background lighting.
  18786. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18787. */
  18788. ambientColor: Color3;
  18789. /**
  18790. * The basic color of the material as viewed under a light.
  18791. */
  18792. diffuseColor: Color3;
  18793. /**
  18794. * Define how the color and intensity of the highlight given by the light in the material.
  18795. */
  18796. specularColor: Color3;
  18797. /**
  18798. * Define the color of the material as if self lit.
  18799. * This will be mixed in the final result even in the absence of light.
  18800. */
  18801. emissiveColor: Color3;
  18802. /**
  18803. * Defines how sharp are the highlights in the material.
  18804. * The bigger the value the sharper giving a more glossy feeling to the result.
  18805. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18806. */
  18807. specularPower: number;
  18808. private _useAlphaFromDiffuseTexture;
  18809. /**
  18810. * Does the transparency come from the diffuse texture alpha channel.
  18811. */
  18812. useAlphaFromDiffuseTexture: boolean;
  18813. private _useEmissiveAsIllumination;
  18814. /**
  18815. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18816. */
  18817. useEmissiveAsIllumination: boolean;
  18818. private _linkEmissiveWithDiffuse;
  18819. /**
  18820. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18821. * the emissive level when the final color is close to one.
  18822. */
  18823. linkEmissiveWithDiffuse: boolean;
  18824. private _useSpecularOverAlpha;
  18825. /**
  18826. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18827. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18828. */
  18829. useSpecularOverAlpha: boolean;
  18830. private _useReflectionOverAlpha;
  18831. /**
  18832. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18833. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18834. */
  18835. useReflectionOverAlpha: boolean;
  18836. private _disableLighting;
  18837. /**
  18838. * Does lights from the scene impacts this material.
  18839. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18840. */
  18841. disableLighting: boolean;
  18842. private _useObjectSpaceNormalMap;
  18843. /**
  18844. * Allows using an object space normal map (instead of tangent space).
  18845. */
  18846. useObjectSpaceNormalMap: boolean;
  18847. private _useParallax;
  18848. /**
  18849. * Is parallax enabled or not.
  18850. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  18851. */
  18852. useParallax: boolean;
  18853. private _useParallaxOcclusion;
  18854. /**
  18855. * Is parallax occlusion enabled or not.
  18856. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18857. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  18858. */
  18859. useParallaxOcclusion: boolean;
  18860. /**
  18861. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  18862. */
  18863. parallaxScaleBias: number;
  18864. private _roughness;
  18865. /**
  18866. * Helps to define how blurry the reflections should appears in the material.
  18867. */
  18868. roughness: number;
  18869. /**
  18870. * In case of refraction, define the value of the indice of refraction.
  18871. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18872. */
  18873. indexOfRefraction: number;
  18874. /**
  18875. * Invert the refraction texture alongside the y axis.
  18876. * It can be usefull with procedural textures or probe for instance.
  18877. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18878. */
  18879. invertRefractionY: boolean;
  18880. /**
  18881. * Defines the alpha limits in alpha test mode.
  18882. */
  18883. alphaCutOff: number;
  18884. private _useLightmapAsShadowmap;
  18885. /**
  18886. * In case of light mapping, define whether the map contains light or shadow informations.
  18887. */
  18888. useLightmapAsShadowmap: boolean;
  18889. private _diffuseFresnelParameters;
  18890. /**
  18891. * Define the diffuse fresnel parameters of the material.
  18892. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18893. */
  18894. diffuseFresnelParameters: FresnelParameters;
  18895. private _opacityFresnelParameters;
  18896. /**
  18897. * Define the opacity fresnel parameters of the material.
  18898. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18899. */
  18900. opacityFresnelParameters: FresnelParameters;
  18901. private _reflectionFresnelParameters;
  18902. /**
  18903. * Define the reflection fresnel parameters of the material.
  18904. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18905. */
  18906. reflectionFresnelParameters: FresnelParameters;
  18907. private _refractionFresnelParameters;
  18908. /**
  18909. * Define the refraction fresnel parameters of the material.
  18910. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18911. */
  18912. refractionFresnelParameters: FresnelParameters;
  18913. private _emissiveFresnelParameters;
  18914. /**
  18915. * Define the emissive fresnel parameters of the material.
  18916. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18917. */
  18918. emissiveFresnelParameters: FresnelParameters;
  18919. private _useReflectionFresnelFromSpecular;
  18920. /**
  18921. * If true automatically deducts the fresnels values from the material specularity.
  18922. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18923. */
  18924. useReflectionFresnelFromSpecular: boolean;
  18925. private _useGlossinessFromSpecularMapAlpha;
  18926. /**
  18927. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18928. */
  18929. useGlossinessFromSpecularMapAlpha: boolean;
  18930. private _maxSimultaneousLights;
  18931. /**
  18932. * Defines the maximum number of lights that can be used in the material
  18933. */
  18934. maxSimultaneousLights: number;
  18935. private _invertNormalMapX;
  18936. /**
  18937. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18938. */
  18939. invertNormalMapX: boolean;
  18940. private _invertNormalMapY;
  18941. /**
  18942. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18943. */
  18944. invertNormalMapY: boolean;
  18945. private _twoSidedLighting;
  18946. /**
  18947. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18948. */
  18949. twoSidedLighting: boolean;
  18950. /**
  18951. * Default configuration related to image processing available in the standard Material.
  18952. */
  18953. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18954. /**
  18955. * Gets the image processing configuration used either in this material.
  18956. */
  18957. /**
  18958. * Sets the Default image processing configuration used either in the this material.
  18959. *
  18960. * If sets to null, the scene one is in use.
  18961. */
  18962. imageProcessingConfiguration: ImageProcessingConfiguration;
  18963. /**
  18964. * Keep track of the image processing observer to allow dispose and replace.
  18965. */
  18966. private _imageProcessingObserver;
  18967. /**
  18968. * Attaches a new image processing configuration to the Standard Material.
  18969. * @param configuration
  18970. */
  18971. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18972. /**
  18973. * Gets wether the color curves effect is enabled.
  18974. */
  18975. /**
  18976. * Sets wether the color curves effect is enabled.
  18977. */
  18978. cameraColorCurvesEnabled: boolean;
  18979. /**
  18980. * Gets wether the color grading effect is enabled.
  18981. */
  18982. /**
  18983. * Gets wether the color grading effect is enabled.
  18984. */
  18985. cameraColorGradingEnabled: boolean;
  18986. /**
  18987. * Gets wether tonemapping is enabled or not.
  18988. */
  18989. /**
  18990. * Sets wether tonemapping is enabled or not
  18991. */
  18992. cameraToneMappingEnabled: boolean;
  18993. /**
  18994. * The camera exposure used on this material.
  18995. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18996. * This corresponds to a photographic exposure.
  18997. */
  18998. /**
  18999. * The camera exposure used on this material.
  19000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19001. * This corresponds to a photographic exposure.
  19002. */
  19003. cameraExposure: number;
  19004. /**
  19005. * Gets The camera contrast used on this material.
  19006. */
  19007. /**
  19008. * Sets The camera contrast used on this material.
  19009. */
  19010. cameraContrast: number;
  19011. /**
  19012. * Gets the Color Grading 2D Lookup Texture.
  19013. */
  19014. /**
  19015. * Sets the Color Grading 2D Lookup Texture.
  19016. */
  19017. cameraColorGradingTexture: Nullable<BaseTexture>;
  19018. /**
  19019. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19020. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19021. * 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;
  19022. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19023. */
  19024. /**
  19025. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19026. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19027. * 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;
  19028. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19029. */
  19030. cameraColorCurves: Nullable<ColorCurves>;
  19031. /**
  19032. * Custom callback helping to override the default shader used in the material.
  19033. */
  19034. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19035. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19036. protected _worldViewProjectionMatrix: Matrix;
  19037. protected _globalAmbientColor: Color3;
  19038. protected _useLogarithmicDepth: boolean;
  19039. /**
  19040. * Instantiates a new standard material.
  19041. * This is the default material used in Babylon. It is the best trade off between quality
  19042. * and performances.
  19043. * @see http://doc.babylonjs.com/babylon101/materials
  19044. * @param name Define the name of the material in the scene
  19045. * @param scene Define the scene the material belong to
  19046. */
  19047. constructor(name: string, scene: Scene);
  19048. /**
  19049. * Gets a boolean indicating that current material needs to register RTT
  19050. */
  19051. readonly hasRenderTargetTextures: boolean;
  19052. /**
  19053. * Gets the current class name of the material e.g. "StandardMaterial"
  19054. * Mainly use in serialization.
  19055. * @returns the class name
  19056. */
  19057. getClassName(): string;
  19058. /**
  19059. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19060. * You can try switching to logarithmic depth.
  19061. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19062. */
  19063. useLogarithmicDepth: boolean;
  19064. /**
  19065. * Specifies if the material will require alpha blending
  19066. * @returns a boolean specifying if alpha blending is needed
  19067. */
  19068. needAlphaBlending(): boolean;
  19069. /**
  19070. * Specifies if this material should be rendered in alpha test mode
  19071. * @returns a boolean specifying if an alpha test is needed.
  19072. */
  19073. needAlphaTesting(): boolean;
  19074. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19075. /**
  19076. * Get the texture used for alpha test purpose.
  19077. * @returns the diffuse texture in case of the standard material.
  19078. */
  19079. getAlphaTestTexture(): Nullable<BaseTexture>;
  19080. /**
  19081. * Get if the submesh is ready to be used and all its information available.
  19082. * Child classes can use it to update shaders
  19083. * @param mesh defines the mesh to check
  19084. * @param subMesh defines which submesh to check
  19085. * @param useInstances specifies that instances should be used
  19086. * @returns a boolean indicating that the submesh is ready or not
  19087. */
  19088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19089. /**
  19090. * Builds the material UBO layouts.
  19091. * Used internally during the effect preparation.
  19092. */
  19093. buildUniformLayout(): void;
  19094. /**
  19095. * Unbinds the material from the mesh
  19096. */
  19097. unbind(): void;
  19098. /**
  19099. * Binds the submesh to this material by preparing the effect and shader to draw
  19100. * @param world defines the world transformation matrix
  19101. * @param mesh defines the mesh containing the submesh
  19102. * @param subMesh defines the submesh to bind the material to
  19103. */
  19104. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19105. /**
  19106. * Get the list of animatables in the material.
  19107. * @returns the list of animatables object used in the material
  19108. */
  19109. getAnimatables(): IAnimatable[];
  19110. /**
  19111. * Gets the active textures from the material
  19112. * @returns an array of textures
  19113. */
  19114. getActiveTextures(): BaseTexture[];
  19115. /**
  19116. * Specifies if the material uses a texture
  19117. * @param texture defines the texture to check against the material
  19118. * @returns a boolean specifying if the material uses the texture
  19119. */
  19120. hasTexture(texture: BaseTexture): boolean;
  19121. /**
  19122. * Disposes the material
  19123. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19124. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19125. */
  19126. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19127. /**
  19128. * Makes a duplicate of the material, and gives it a new name
  19129. * @param name defines the new name for the duplicated material
  19130. * @returns the cloned material
  19131. */
  19132. clone(name: string): StandardMaterial;
  19133. /**
  19134. * Serializes this material in a JSON representation
  19135. * @returns the serialized material object
  19136. */
  19137. serialize(): any;
  19138. /**
  19139. * Creates a standard material from parsed material data
  19140. * @param source defines the JSON represnetation of the material
  19141. * @param scene defines the hosting scene
  19142. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19143. * @returns a new material
  19144. */
  19145. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19146. private static _DiffuseTextureEnabled;
  19147. /**
  19148. * Are diffuse textures enabled in the application.
  19149. */
  19150. static DiffuseTextureEnabled: boolean;
  19151. private static _AmbientTextureEnabled;
  19152. /**
  19153. * Are ambient textures enabled in the application.
  19154. */
  19155. static AmbientTextureEnabled: boolean;
  19156. private static _OpacityTextureEnabled;
  19157. /**
  19158. * Are opacity textures enabled in the application.
  19159. */
  19160. static OpacityTextureEnabled: boolean;
  19161. private static _ReflectionTextureEnabled;
  19162. /**
  19163. * Are reflection textures enabled in the application.
  19164. */
  19165. static ReflectionTextureEnabled: boolean;
  19166. private static _EmissiveTextureEnabled;
  19167. /**
  19168. * Are emissive textures enabled in the application.
  19169. */
  19170. static EmissiveTextureEnabled: boolean;
  19171. private static _SpecularTextureEnabled;
  19172. /**
  19173. * Are specular textures enabled in the application.
  19174. */
  19175. static SpecularTextureEnabled: boolean;
  19176. private static _BumpTextureEnabled;
  19177. /**
  19178. * Are bump textures enabled in the application.
  19179. */
  19180. static BumpTextureEnabled: boolean;
  19181. private static _LightmapTextureEnabled;
  19182. /**
  19183. * Are lightmap textures enabled in the application.
  19184. */
  19185. static LightmapTextureEnabled: boolean;
  19186. private static _RefractionTextureEnabled;
  19187. /**
  19188. * Are refraction textures enabled in the application.
  19189. */
  19190. static RefractionTextureEnabled: boolean;
  19191. private static _ColorGradingTextureEnabled;
  19192. /**
  19193. * Are color grading textures enabled in the application.
  19194. */
  19195. static ColorGradingTextureEnabled: boolean;
  19196. private static _FresnelEnabled;
  19197. /**
  19198. * Are fresnels enabled in the application.
  19199. */
  19200. static FresnelEnabled: boolean;
  19201. }
  19202. }
  19203. declare module BABYLON {
  19204. /**
  19205. * Uniform buffer objects.
  19206. *
  19207. * Handles blocks of uniform on the GPU.
  19208. *
  19209. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19210. *
  19211. * For more information, please refer to :
  19212. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19213. */
  19214. class UniformBuffer {
  19215. private _engine;
  19216. private _buffer;
  19217. private _data;
  19218. private _bufferData;
  19219. private _dynamic?;
  19220. private _uniformLocations;
  19221. private _uniformSizes;
  19222. private _uniformLocationPointer;
  19223. private _needSync;
  19224. private _noUBO;
  19225. private _currentEffect;
  19226. private static _MAX_UNIFORM_SIZE;
  19227. private static _tempBuffer;
  19228. /**
  19229. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19230. * This is dynamic to allow compat with webgl 1 and 2.
  19231. * You will need to pass the name of the uniform as well as the value.
  19232. */
  19233. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19234. /**
  19235. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19236. * This is dynamic to allow compat with webgl 1 and 2.
  19237. * You will need to pass the name of the uniform as well as the value.
  19238. */
  19239. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19240. /**
  19241. * Lambda to Update a single float in a uniform buffer.
  19242. * This is dynamic to allow compat with webgl 1 and 2.
  19243. * You will need to pass the name of the uniform as well as the value.
  19244. */
  19245. updateFloat: (name: string, x: number) => void;
  19246. /**
  19247. * Lambda to Update a vec2 of float in a uniform buffer.
  19248. * This is dynamic to allow compat with webgl 1 and 2.
  19249. * You will need to pass the name of the uniform as well as the value.
  19250. */
  19251. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19252. /**
  19253. * Lambda to Update a vec3 of float in a uniform buffer.
  19254. * This is dynamic to allow compat with webgl 1 and 2.
  19255. * You will need to pass the name of the uniform as well as the value.
  19256. */
  19257. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19258. /**
  19259. * Lambda to Update a vec4 of float in a uniform buffer.
  19260. * This is dynamic to allow compat with webgl 1 and 2.
  19261. * You will need to pass the name of the uniform as well as the value.
  19262. */
  19263. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19264. /**
  19265. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19266. * This is dynamic to allow compat with webgl 1 and 2.
  19267. * You will need to pass the name of the uniform as well as the value.
  19268. */
  19269. updateMatrix: (name: string, mat: Matrix) => void;
  19270. /**
  19271. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19272. * This is dynamic to allow compat with webgl 1 and 2.
  19273. * You will need to pass the name of the uniform as well as the value.
  19274. */
  19275. updateVector3: (name: string, vector: Vector3) => void;
  19276. /**
  19277. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19278. * This is dynamic to allow compat with webgl 1 and 2.
  19279. * You will need to pass the name of the uniform as well as the value.
  19280. */
  19281. updateVector4: (name: string, vector: Vector4) => void;
  19282. /**
  19283. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19284. * This is dynamic to allow compat with webgl 1 and 2.
  19285. * You will need to pass the name of the uniform as well as the value.
  19286. */
  19287. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19288. /**
  19289. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19290. * This is dynamic to allow compat with webgl 1 and 2.
  19291. * You will need to pass the name of the uniform as well as the value.
  19292. */
  19293. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19294. /**
  19295. * Instantiates a new Uniform buffer objects.
  19296. *
  19297. * Handles blocks of uniform on the GPU.
  19298. *
  19299. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19300. *
  19301. * For more information, please refer to :
  19302. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19303. * @param engine Define the engine the buffer is associated with
  19304. * @param data Define the data contained in the buffer
  19305. * @param dynamic Define if the buffer is updatable
  19306. */
  19307. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19308. /**
  19309. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19310. * or just falling back on setUniformXXX calls.
  19311. */
  19312. readonly useUbo: boolean;
  19313. /**
  19314. * Indicates if the WebGL underlying uniform buffer is in sync
  19315. * with the javascript cache data.
  19316. */
  19317. readonly isSync: boolean;
  19318. /**
  19319. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19320. * Also, a dynamic UniformBuffer will disable cache verification and always
  19321. * update the underlying WebGL uniform buffer to the GPU.
  19322. * @returns if Dynamic, otherwise false
  19323. */
  19324. isDynamic(): boolean;
  19325. /**
  19326. * The data cache on JS side.
  19327. * @returns the underlying data as a float array
  19328. */
  19329. getData(): Float32Array;
  19330. /**
  19331. * The underlying WebGL Uniform buffer.
  19332. * @returns the webgl buffer
  19333. */
  19334. getBuffer(): Nullable<WebGLBuffer>;
  19335. /**
  19336. * std140 layout specifies how to align data within an UBO structure.
  19337. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19338. * for specs.
  19339. */
  19340. private _fillAlignment;
  19341. /**
  19342. * Adds an uniform in the buffer.
  19343. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19344. * for the layout to be correct !
  19345. * @param name Name of the uniform, as used in the uniform block in the shader.
  19346. * @param size Data size, or data directly.
  19347. */
  19348. addUniform(name: string, size: number | number[]): void;
  19349. /**
  19350. * Adds a Matrix 4x4 to the uniform buffer.
  19351. * @param name Name of the uniform, as used in the uniform block in the shader.
  19352. * @param mat A 4x4 matrix.
  19353. */
  19354. addMatrix(name: string, mat: Matrix): void;
  19355. /**
  19356. * Adds a vec2 to the uniform buffer.
  19357. * @param name Name of the uniform, as used in the uniform block in the shader.
  19358. * @param x Define the x component value of the vec2
  19359. * @param y Define the y component value of the vec2
  19360. */
  19361. addFloat2(name: string, x: number, y: number): void;
  19362. /**
  19363. * Adds a vec3 to the uniform buffer.
  19364. * @param name Name of the uniform, as used in the uniform block in the shader.
  19365. * @param x Define the x component value of the vec3
  19366. * @param y Define the y component value of the vec3
  19367. * @param z Define the z component value of the vec3
  19368. */
  19369. addFloat3(name: string, x: number, y: number, z: number): void;
  19370. /**
  19371. * Adds a vec3 to the uniform buffer.
  19372. * @param name Name of the uniform, as used in the uniform block in the shader.
  19373. * @param color Define the vec3 from a Color
  19374. */
  19375. addColor3(name: string, color: Color3): void;
  19376. /**
  19377. * Adds a vec4 to the uniform buffer.
  19378. * @param name Name of the uniform, as used in the uniform block in the shader.
  19379. * @param color Define the rgb components from a Color
  19380. * @param alpha Define the a component of the vec4
  19381. */
  19382. addColor4(name: string, color: Color3, alpha: number): void;
  19383. /**
  19384. * Adds a vec3 to the uniform buffer.
  19385. * @param name Name of the uniform, as used in the uniform block in the shader.
  19386. * @param vector Define the vec3 components from a Vector
  19387. */
  19388. addVector3(name: string, vector: Vector3): void;
  19389. /**
  19390. * Adds a Matrix 3x3 to the uniform buffer.
  19391. * @param name Name of the uniform, as used in the uniform block in the shader.
  19392. */
  19393. addMatrix3x3(name: string): void;
  19394. /**
  19395. * Adds a Matrix 2x2 to the uniform buffer.
  19396. * @param name Name of the uniform, as used in the uniform block in the shader.
  19397. */
  19398. addMatrix2x2(name: string): void;
  19399. /**
  19400. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19401. */
  19402. create(): void;
  19403. /** @hidden */
  19404. _rebuild(): void;
  19405. /**
  19406. * Updates the WebGL Uniform Buffer on the GPU.
  19407. * If the `dynamic` flag is set to true, no cache comparison is done.
  19408. * Otherwise, the buffer will be updated only if the cache differs.
  19409. */
  19410. update(): void;
  19411. /**
  19412. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19413. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19414. * @param data Define the flattened data
  19415. * @param size Define the size of the data.
  19416. */
  19417. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19418. private _updateMatrix3x3ForUniform;
  19419. private _updateMatrix3x3ForEffect;
  19420. private _updateMatrix2x2ForEffect;
  19421. private _updateMatrix2x2ForUniform;
  19422. private _updateFloatForEffect;
  19423. private _updateFloatForUniform;
  19424. private _updateFloat2ForEffect;
  19425. private _updateFloat2ForUniform;
  19426. private _updateFloat3ForEffect;
  19427. private _updateFloat3ForUniform;
  19428. private _updateFloat4ForEffect;
  19429. private _updateFloat4ForUniform;
  19430. private _updateMatrixForEffect;
  19431. private _updateMatrixForUniform;
  19432. private _updateVector3ForEffect;
  19433. private _updateVector3ForUniform;
  19434. private _updateVector4ForEffect;
  19435. private _updateVector4ForUniform;
  19436. private _updateColor3ForEffect;
  19437. private _updateColor3ForUniform;
  19438. private _updateColor4ForEffect;
  19439. private _updateColor4ForUniform;
  19440. /**
  19441. * Sets a sampler uniform on the effect.
  19442. * @param name Define the name of the sampler.
  19443. * @param texture Define the texture to set in the sampler
  19444. */
  19445. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19446. /**
  19447. * Directly updates the value of the uniform in the cache AND on the GPU.
  19448. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19449. * @param data Define the flattened data
  19450. */
  19451. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19452. /**
  19453. * Binds this uniform buffer to an effect.
  19454. * @param effect Define the effect to bind the buffer to
  19455. * @param name Name of the uniform block in the shader.
  19456. */
  19457. bindToEffect(effect: Effect, name: string): void;
  19458. /**
  19459. * Disposes the uniform buffer.
  19460. */
  19461. dispose(): void;
  19462. }
  19463. }
  19464. declare module BABYLON {
  19465. /**
  19466. * Scalar computation library
  19467. */
  19468. class Scalar {
  19469. /**
  19470. * Two pi constants convenient for computation.
  19471. */
  19472. static TwoPi: number;
  19473. /**
  19474. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19475. * @param a number
  19476. * @param b number
  19477. * @param epsilon (default = 1.401298E-45)
  19478. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19479. */
  19480. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19481. /**
  19482. * Returns a string : the upper case translation of the number i to hexadecimal.
  19483. * @param i number
  19484. * @returns the upper case translation of the number i to hexadecimal.
  19485. */
  19486. static ToHex(i: number): string;
  19487. /**
  19488. * Returns -1 if value is negative and +1 is value is positive.
  19489. * @param value the value
  19490. * @returns the value itself if it's equal to zero.
  19491. */
  19492. static Sign(value: number): number;
  19493. /**
  19494. * Returns the value itself if it's between min and max.
  19495. * Returns min if the value is lower than min.
  19496. * Returns max if the value is greater than max.
  19497. * @param value the value to clmap
  19498. * @param min the min value to clamp to (default: 0)
  19499. * @param max the max value to clamp to (default: 1)
  19500. * @returns the clamped value
  19501. */
  19502. static Clamp(value: number, min?: number, max?: number): number;
  19503. /**
  19504. * the log2 of value.
  19505. * @param value the value to compute log2 of
  19506. * @returns the log2 of value.
  19507. */
  19508. static Log2(value: number): number;
  19509. /**
  19510. * Loops the value, so that it is never larger than length and never smaller than 0.
  19511. *
  19512. * This is similar to the modulo operator but it works with floating point numbers.
  19513. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19514. * With t = 5 and length = 2.5, the result would be 0.0.
  19515. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19516. * @param value the value
  19517. * @param length the length
  19518. * @returns the looped value
  19519. */
  19520. static Repeat(value: number, length: number): number;
  19521. /**
  19522. * Normalize the value between 0.0 and 1.0 using min and max values
  19523. * @param value value to normalize
  19524. * @param min max to normalize between
  19525. * @param max min to normalize between
  19526. * @returns the normalized value
  19527. */
  19528. static Normalize(value: number, min: number, max: number): number;
  19529. /**
  19530. * Denormalize the value from 0.0 and 1.0 using min and max values
  19531. * @param normalized value to denormalize
  19532. * @param min max to denormalize between
  19533. * @param max min to denormalize between
  19534. * @returns the denormalized value
  19535. */
  19536. static Denormalize(normalized: number, min: number, max: number): number;
  19537. /**
  19538. * Calculates the shortest difference between two given angles given in degrees.
  19539. * @param current current angle in degrees
  19540. * @param target target angle in degrees
  19541. * @returns the delta
  19542. */
  19543. static DeltaAngle(current: number, target: number): number;
  19544. /**
  19545. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19546. * @param tx value
  19547. * @param length length
  19548. * @returns The returned value will move back and forth between 0 and length
  19549. */
  19550. static PingPong(tx: number, length: number): number;
  19551. /**
  19552. * Interpolates between min and max with smoothing at the limits.
  19553. *
  19554. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19555. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19556. * @param from from
  19557. * @param to to
  19558. * @param tx value
  19559. * @returns the smooth stepped value
  19560. */
  19561. static SmoothStep(from: number, to: number, tx: number): number;
  19562. /**
  19563. * Moves a value current towards target.
  19564. *
  19565. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19566. * Negative values of maxDelta pushes the value away from target.
  19567. * @param current current value
  19568. * @param target target value
  19569. * @param maxDelta max distance to move
  19570. * @returns resulting value
  19571. */
  19572. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19573. /**
  19574. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19575. *
  19576. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19577. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19578. * @param current current value
  19579. * @param target target value
  19580. * @param maxDelta max distance to move
  19581. * @returns resulting angle
  19582. */
  19583. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19584. /**
  19585. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19586. * @param start start value
  19587. * @param end target value
  19588. * @param amount amount to lerp between
  19589. * @returns the lerped value
  19590. */
  19591. static Lerp(start: number, end: number, amount: number): number;
  19592. /**
  19593. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19594. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19595. * @param start start value
  19596. * @param end target value
  19597. * @param amount amount to lerp between
  19598. * @returns the lerped value
  19599. */
  19600. static LerpAngle(start: number, end: number, amount: number): number;
  19601. /**
  19602. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19603. * @param a start value
  19604. * @param b target value
  19605. * @param value value between a and b
  19606. * @returns the inverseLerp value
  19607. */
  19608. static InverseLerp(a: number, b: number, value: number): number;
  19609. /**
  19610. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19611. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19612. * @param value1 spline value
  19613. * @param tangent1 spline value
  19614. * @param value2 spline value
  19615. * @param tangent2 spline value
  19616. * @param amount input value
  19617. * @returns hermite result
  19618. */
  19619. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19620. /**
  19621. * Returns a random float number between and min and max values
  19622. * @param min min value of random
  19623. * @param max max value of random
  19624. * @returns random value
  19625. */
  19626. static RandomRange(min: number, max: number): number;
  19627. /**
  19628. * This function returns percentage of a number in a given range.
  19629. *
  19630. * RangeToPercent(40,20,60) will return 0.5 (50%)
  19631. * RangeToPercent(34,0,100) will return 0.34 (34%)
  19632. * @param number to convert to percentage
  19633. * @param min min range
  19634. * @param max max range
  19635. * @returns the percentage
  19636. */
  19637. static RangeToPercent(number: number, min: number, max: number): number;
  19638. /**
  19639. * This function returns number that corresponds to the percentage in a given range.
  19640. *
  19641. * PercentToRange(0.34,0,100) will return 34.
  19642. * @param percent to convert to number
  19643. * @param min min range
  19644. * @param max max range
  19645. * @returns the number
  19646. */
  19647. static PercentToRange(percent: number, min: number, max: number): number;
  19648. /**
  19649. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  19650. * @param angle The angle to normalize in radian.
  19651. * @return The converted angle.
  19652. */
  19653. static NormalizeRadians(angle: number): number;
  19654. }
  19655. }
  19656. declare module BABYLON {
  19657. /**
  19658. * Constant used to convert a value to gamma space
  19659. * @ignorenaming
  19660. */
  19661. const ToGammaSpace: number;
  19662. /**
  19663. * Constant used to convert a value to linear space
  19664. * @ignorenaming
  19665. */
  19666. const ToLinearSpace = 2.2;
  19667. /**
  19668. * Constant used to define the minimal number value in Babylon.js
  19669. * @ignorenaming
  19670. */
  19671. const Epsilon = 0.001;
  19672. /**
  19673. * Class used to hold a RBG color
  19674. */
  19675. class Color3 {
  19676. /**
  19677. * Defines the red component (between 0 and 1, default is 0)
  19678. */
  19679. r: number;
  19680. /**
  19681. * Defines the green component (between 0 and 1, default is 0)
  19682. */
  19683. g: number;
  19684. /**
  19685. * Defines the blue component (between 0 and 1, default is 0)
  19686. */
  19687. b: number;
  19688. /**
  19689. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  19690. * @param r defines the red component (between 0 and 1, default is 0)
  19691. * @param g defines the green component (between 0 and 1, default is 0)
  19692. * @param b defines the blue component (between 0 and 1, default is 0)
  19693. */
  19694. constructor(
  19695. /**
  19696. * Defines the red component (between 0 and 1, default is 0)
  19697. */
  19698. r?: number,
  19699. /**
  19700. * Defines the green component (between 0 and 1, default is 0)
  19701. */
  19702. g?: number,
  19703. /**
  19704. * Defines the blue component (between 0 and 1, default is 0)
  19705. */
  19706. b?: number);
  19707. /**
  19708. * Creates a string with the Color3 current values
  19709. * @returns the string representation of the Color3 object
  19710. */
  19711. toString(): string;
  19712. /**
  19713. * Returns the string "Color3"
  19714. * @returns "Color3"
  19715. */
  19716. getClassName(): string;
  19717. /**
  19718. * Compute the Color3 hash code
  19719. * @returns an unique number that can be used to hash Color3 objects
  19720. */
  19721. getHashCode(): number;
  19722. /**
  19723. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  19724. * @param array defines the array where to store the r,g,b components
  19725. * @param index defines an optional index in the target array to define where to start storing values
  19726. * @returns the current Color3 object
  19727. */
  19728. toArray(array: FloatArray, index?: number): Color3;
  19729. /**
  19730. * Returns a new Color4 object from the current Color3 and the given alpha
  19731. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  19732. * @returns a new Color4 object
  19733. */
  19734. toColor4(alpha?: number): Color4;
  19735. /**
  19736. * Returns a new array populated with 3 numeric elements : red, green and blue values
  19737. * @returns the new array
  19738. */
  19739. asArray(): number[];
  19740. /**
  19741. * Returns the luminance value
  19742. * @returns a float value
  19743. */
  19744. toLuminance(): number;
  19745. /**
  19746. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  19747. * @param otherColor defines the second operand
  19748. * @returns the new Color3 object
  19749. */
  19750. multiply(otherColor: Color3): Color3;
  19751. /**
  19752. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  19753. * @param otherColor defines the second operand
  19754. * @param result defines the Color3 object where to store the result
  19755. * @returns the current Color3
  19756. */
  19757. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  19758. /**
  19759. * Determines equality between Color3 objects
  19760. * @param otherColor defines the second operand
  19761. * @returns true if the rgb values are equal to the given ones
  19762. */
  19763. equals(otherColor: Color3): boolean;
  19764. /**
  19765. * Determines equality between the current Color3 object and a set of r,b,g values
  19766. * @param r defines the red component to check
  19767. * @param g defines the green component to check
  19768. * @param b defines the blue component to check
  19769. * @returns true if the rgb values are equal to the given ones
  19770. */
  19771. equalsFloats(r: number, g: number, b: number): boolean;
  19772. /**
  19773. * Multiplies in place each rgb value by scale
  19774. * @param scale defines the scaling factor
  19775. * @returns the updated Color3
  19776. */
  19777. scale(scale: number): Color3;
  19778. /**
  19779. * Multiplies the rgb values by scale and stores the result into "result"
  19780. * @param scale defines the scaling factor
  19781. * @param result defines the Color3 object where to store the result
  19782. * @returns the unmodified current Color3
  19783. */
  19784. scaleToRef(scale: number, result: Color3): Color3;
  19785. /**
  19786. * Scale the current Color3 values by a factor and add the result to a given Color3
  19787. * @param scale defines the scale factor
  19788. * @param result defines color to store the result into
  19789. * @returns the unmodified current Color3
  19790. */
  19791. scaleAndAddToRef(scale: number, result: Color3): Color3;
  19792. /**
  19793. * Clamps the rgb values by the min and max values and stores the result into "result"
  19794. * @param min defines minimum clamping value (default is 0)
  19795. * @param max defines maximum clamping value (default is 1)
  19796. * @param result defines color to store the result into
  19797. * @returns the original Color3
  19798. */
  19799. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  19800. /**
  19801. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  19802. * @param otherColor defines the second operand
  19803. * @returns the new Color3
  19804. */
  19805. add(otherColor: Color3): Color3;
  19806. /**
  19807. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  19808. * @param otherColor defines the second operand
  19809. * @param result defines Color3 object to store the result into
  19810. * @returns the unmodified current Color3
  19811. */
  19812. addToRef(otherColor: Color3, result: Color3): Color3;
  19813. /**
  19814. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  19815. * @param otherColor defines the second operand
  19816. * @returns the new Color3
  19817. */
  19818. subtract(otherColor: Color3): Color3;
  19819. /**
  19820. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  19821. * @param otherColor defines the second operand
  19822. * @param result defines Color3 object to store the result into
  19823. * @returns the unmodified current Color3
  19824. */
  19825. subtractToRef(otherColor: Color3, result: Color3): Color3;
  19826. /**
  19827. * Copy the current object
  19828. * @returns a new Color3 copied the current one
  19829. */
  19830. clone(): Color3;
  19831. /**
  19832. * Copies the rgb values from the source in the current Color3
  19833. * @param source defines the source Color3 object
  19834. * @returns the updated Color3 object
  19835. */
  19836. copyFrom(source: Color3): Color3;
  19837. /**
  19838. * Updates the Color3 rgb values from the given floats
  19839. * @param r defines the red component to read from
  19840. * @param g defines the green component to read from
  19841. * @param b defines the blue component to read from
  19842. * @returns the current Color3 object
  19843. */
  19844. copyFromFloats(r: number, g: number, b: number): Color3;
  19845. /**
  19846. * Updates the Color3 rgb values from the given floats
  19847. * @param r defines the red component to read from
  19848. * @param g defines the green component to read from
  19849. * @param b defines the blue component to read from
  19850. * @returns the current Color3 object
  19851. */
  19852. set(r: number, g: number, b: number): Color3;
  19853. /**
  19854. * Compute the Color3 hexadecimal code as a string
  19855. * @returns a string containing the hexadecimal representation of the Color3 object
  19856. */
  19857. toHexString(): string;
  19858. /**
  19859. * Computes a new Color3 converted from the current one to linear space
  19860. * @returns a new Color3 object
  19861. */
  19862. toLinearSpace(): Color3;
  19863. /**
  19864. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  19865. * @param convertedColor defines the Color3 object where to store the linear space version
  19866. * @returns the unmodified Color3
  19867. */
  19868. toLinearSpaceToRef(convertedColor: Color3): Color3;
  19869. /**
  19870. * Computes a new Color3 converted from the current one to gamma space
  19871. * @returns a new Color3 object
  19872. */
  19873. toGammaSpace(): Color3;
  19874. /**
  19875. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  19876. * @param convertedColor defines the Color3 object where to store the gamma space version
  19877. * @returns the unmodified Color3
  19878. */
  19879. toGammaSpaceToRef(convertedColor: Color3): Color3;
  19880. /**
  19881. * Creates a new Color3 from the string containing valid hexadecimal values
  19882. * @param hex defines a string containing valid hexadecimal values
  19883. * @returns a new Color3 object
  19884. */
  19885. static FromHexString(hex: string): Color3;
  19886. /**
  19887. * Creates a new Vector3 from the starting index of the given array
  19888. * @param array defines the source array
  19889. * @param offset defines an offset in the source array
  19890. * @returns a new Color3 object
  19891. */
  19892. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  19893. /**
  19894. * Creates a new Color3 from integer values (< 256)
  19895. * @param r defines the red component to read from (value between 0 and 255)
  19896. * @param g defines the green component to read from (value between 0 and 255)
  19897. * @param b defines the blue component to read from (value between 0 and 255)
  19898. * @returns a new Color3 object
  19899. */
  19900. static FromInts(r: number, g: number, b: number): Color3;
  19901. /**
  19902. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  19903. * @param start defines the start Color3 value
  19904. * @param end defines the end Color3 value
  19905. * @param amount defines the gradient value between start and end
  19906. * @returns a new Color3 object
  19907. */
  19908. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  19909. /**
  19910. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  19911. * @param left defines the start value
  19912. * @param right defines the end value
  19913. * @param amount defines the gradient factor
  19914. * @param result defines the Color3 object where to store the result
  19915. */
  19916. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  19917. /**
  19918. * Returns a Color3 value containing a red color
  19919. * @returns a new Color3 object
  19920. */
  19921. static Red(): Color3;
  19922. /**
  19923. * Returns a Color3 value containing a green color
  19924. * @returns a new Color3 object
  19925. */
  19926. static Green(): Color3;
  19927. /**
  19928. * Returns a Color3 value containing a blue color
  19929. * @returns a new Color3 object
  19930. */
  19931. static Blue(): Color3;
  19932. /**
  19933. * Returns a Color3 value containing a black color
  19934. * @returns a new Color3 object
  19935. */
  19936. static Black(): Color3;
  19937. /**
  19938. * Returns a Color3 value containing a white color
  19939. * @returns a new Color3 object
  19940. */
  19941. static White(): Color3;
  19942. /**
  19943. * Returns a Color3 value containing a purple color
  19944. * @returns a new Color3 object
  19945. */
  19946. static Purple(): Color3;
  19947. /**
  19948. * Returns a Color3 value containing a magenta color
  19949. * @returns a new Color3 object
  19950. */
  19951. static Magenta(): Color3;
  19952. /**
  19953. * Returns a Color3 value containing a yellow color
  19954. * @returns a new Color3 object
  19955. */
  19956. static Yellow(): Color3;
  19957. /**
  19958. * Returns a Color3 value containing a gray color
  19959. * @returns a new Color3 object
  19960. */
  19961. static Gray(): Color3;
  19962. /**
  19963. * Returns a Color3 value containing a teal color
  19964. * @returns a new Color3 object
  19965. */
  19966. static Teal(): Color3;
  19967. /**
  19968. * Returns a Color3 value containing a random color
  19969. * @returns a new Color3 object
  19970. */
  19971. static Random(): Color3;
  19972. }
  19973. /**
  19974. * Class used to hold a RBGA color
  19975. */
  19976. class Color4 {
  19977. /**
  19978. * Defines the red component (between 0 and 1, default is 0)
  19979. */
  19980. r: number;
  19981. /**
  19982. * Defines the green component (between 0 and 1, default is 0)
  19983. */
  19984. g: number;
  19985. /**
  19986. * Defines the blue component (between 0 and 1, default is 0)
  19987. */
  19988. b: number;
  19989. /**
  19990. * Defines the alpha component (between 0 and 1, default is 1)
  19991. */
  19992. a: number;
  19993. /**
  19994. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  19995. * @param r defines the red component (between 0 and 1, default is 0)
  19996. * @param g defines the green component (between 0 and 1, default is 0)
  19997. * @param b defines the blue component (between 0 and 1, default is 0)
  19998. * @param a defines the alpha component (between 0 and 1, default is 1)
  19999. */
  20000. constructor(
  20001. /**
  20002. * Defines the red component (between 0 and 1, default is 0)
  20003. */
  20004. r?: number,
  20005. /**
  20006. * Defines the green component (between 0 and 1, default is 0)
  20007. */
  20008. g?: number,
  20009. /**
  20010. * Defines the blue component (between 0 and 1, default is 0)
  20011. */
  20012. b?: number,
  20013. /**
  20014. * Defines the alpha component (between 0 and 1, default is 1)
  20015. */
  20016. a?: number);
  20017. /**
  20018. * Adds in place the given Color4 values to the current Color4 object
  20019. * @param right defines the second operand
  20020. * @returns the current updated Color4 object
  20021. */
  20022. addInPlace(right: Color4): Color4;
  20023. /**
  20024. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20025. * @returns the new array
  20026. */
  20027. asArray(): number[];
  20028. /**
  20029. * Stores from the starting index in the given array the Color4 successive values
  20030. * @param array defines the array where to store the r,g,b components
  20031. * @param index defines an optional index in the target array to define where to start storing values
  20032. * @returns the current Color4 object
  20033. */
  20034. toArray(array: number[], index?: number): Color4;
  20035. /**
  20036. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20037. * @param right defines the second operand
  20038. * @returns a new Color4 object
  20039. */
  20040. add(right: Color4): Color4;
  20041. /**
  20042. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20043. * @param right defines the second operand
  20044. * @returns a new Color4 object
  20045. */
  20046. subtract(right: Color4): Color4;
  20047. /**
  20048. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20049. * @param right defines the second operand
  20050. * @param result defines the Color4 object where to store the result
  20051. * @returns the current Color4 object
  20052. */
  20053. subtractToRef(right: Color4, result: Color4): Color4;
  20054. /**
  20055. * Creates a new Color4 with the current Color4 values multiplied by scale
  20056. * @param scale defines the scaling factor to apply
  20057. * @returns a new Color4 object
  20058. */
  20059. scale(scale: number): Color4;
  20060. /**
  20061. * Multiplies the current Color4 values by scale and stores the result in "result"
  20062. * @param scale defines the scaling factor to apply
  20063. * @param result defines the Color4 object where to store the result
  20064. * @returns the current unmodified Color4
  20065. */
  20066. scaleToRef(scale: number, result: Color4): Color4;
  20067. /**
  20068. * Scale the current Color4 values by a factor and add the result to a given Color4
  20069. * @param scale defines the scale factor
  20070. * @param result defines the Color4 object where to store the result
  20071. * @returns the unmodified current Color4
  20072. */
  20073. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20074. /**
  20075. * Clamps the rgb values by the min and max values and stores the result into "result"
  20076. * @param min defines minimum clamping value (default is 0)
  20077. * @param max defines maximum clamping value (default is 1)
  20078. * @param result defines color to store the result into.
  20079. * @returns the cuurent Color4
  20080. */
  20081. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20082. /**
  20083. * Multipy an Color4 value by another and return a new Color4 object
  20084. * @param color defines the Color4 value to multiply by
  20085. * @returns a new Color4 object
  20086. */
  20087. multiply(color: Color4): Color4;
  20088. /**
  20089. * Multipy a Color4 value by another and push the result in a reference value
  20090. * @param color defines the Color4 value to multiply by
  20091. * @param result defines the Color4 to fill the result in
  20092. * @returns the result Color4
  20093. */
  20094. multiplyToRef(color: Color4, result: Color4): Color4;
  20095. /**
  20096. * Creates a string with the Color4 current values
  20097. * @returns the string representation of the Color4 object
  20098. */
  20099. toString(): string;
  20100. /**
  20101. * Returns the string "Color4"
  20102. * @returns "Color4"
  20103. */
  20104. getClassName(): string;
  20105. /**
  20106. * Compute the Color4 hash code
  20107. * @returns an unique number that can be used to hash Color4 objects
  20108. */
  20109. getHashCode(): number;
  20110. /**
  20111. * Creates a new Color4 copied from the current one
  20112. * @returns a new Color4 object
  20113. */
  20114. clone(): Color4;
  20115. /**
  20116. * Copies the given Color4 values into the current one
  20117. * @param source defines the source Color4 object
  20118. * @returns the current updated Color4 object
  20119. */
  20120. copyFrom(source: Color4): Color4;
  20121. /**
  20122. * Copies the given float values into the current one
  20123. * @param r defines the red component to read from
  20124. * @param g defines the green component to read from
  20125. * @param b defines the blue component to read from
  20126. * @param a defines the alpha component to read from
  20127. * @returns the current updated Color4 object
  20128. */
  20129. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20130. /**
  20131. * Copies the given float values into the current one
  20132. * @param r defines the red component to read from
  20133. * @param g defines the green component to read from
  20134. * @param b defines the blue component to read from
  20135. * @param a defines the alpha component to read from
  20136. * @returns the current updated Color4 object
  20137. */
  20138. set(r: number, g: number, b: number, a: number): Color4;
  20139. /**
  20140. * Compute the Color4 hexadecimal code as a string
  20141. * @returns a string containing the hexadecimal representation of the Color4 object
  20142. */
  20143. toHexString(): string;
  20144. /**
  20145. * Computes a new Color4 converted from the current one to linear space
  20146. * @returns a new Color4 object
  20147. */
  20148. toLinearSpace(): Color4;
  20149. /**
  20150. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20151. * @param convertedColor defines the Color4 object where to store the linear space version
  20152. * @returns the unmodified Color4
  20153. */
  20154. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20155. /**
  20156. * Computes a new Color4 converted from the current one to gamma space
  20157. * @returns a new Color4 object
  20158. */
  20159. toGammaSpace(): Color4;
  20160. /**
  20161. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20162. * @param convertedColor defines the Color4 object where to store the gamma space version
  20163. * @returns the unmodified Color4
  20164. */
  20165. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20166. /**
  20167. * Creates a new Color4 from the string containing valid hexadecimal values
  20168. * @param hex defines a string containing valid hexadecimal values
  20169. * @returns a new Color4 object
  20170. */
  20171. static FromHexString(hex: string): Color4;
  20172. /**
  20173. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20174. * @param left defines the start value
  20175. * @param right defines the end value
  20176. * @param amount defines the gradient factor
  20177. * @returns a new Color4 object
  20178. */
  20179. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  20180. /**
  20181. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20182. * @param left defines the start value
  20183. * @param right defines the end value
  20184. * @param amount defines the gradient factor
  20185. * @param result defines the Color4 object where to store data
  20186. */
  20187. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  20188. /**
  20189. * Creates a new Color4 from a Color3 and an alpha value
  20190. * @param color3 defines the source Color3 to read from
  20191. * @param alpha defines the alpha component (1.0 by default)
  20192. * @returns a new Color4 object
  20193. */
  20194. static FromColor3(color3: Color3, alpha?: number): Color4;
  20195. /**
  20196. * Creates a new Color4 from the starting index element of the given array
  20197. * @param array defines the source array to read from
  20198. * @param offset defines the offset in the source array
  20199. * @returns a new Color4 object
  20200. */
  20201. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  20202. /**
  20203. * Creates a new Color3 from integer values (< 256)
  20204. * @param r defines the red component to read from (value between 0 and 255)
  20205. * @param g defines the green component to read from (value between 0 and 255)
  20206. * @param b defines the blue component to read from (value between 0 and 255)
  20207. * @param a defines the alpha component to read from (value between 0 and 255)
  20208. * @returns a new Color3 object
  20209. */
  20210. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20211. /**
  20212. * Check the content of a given array and convert it to an array containing RGBA data
  20213. * If the original array was already containing count * 4 values then it is returned directly
  20214. * @param colors defines the array to check
  20215. * @param count defines the number of RGBA data to expect
  20216. * @returns an array containing count * 4 values (RGBA)
  20217. */
  20218. static CheckColors4(colors: number[], count: number): number[];
  20219. }
  20220. /**
  20221. * Class representing a vector containing 2 coordinates
  20222. */
  20223. class Vector2 {
  20224. /** defines the first coordinate */
  20225. x: number;
  20226. /** defines the second coordinate */
  20227. y: number;
  20228. /**
  20229. * Creates a new Vector2 from the given x and y coordinates
  20230. * @param x defines the first coordinate
  20231. * @param y defines the second coordinate
  20232. */
  20233. constructor(
  20234. /** defines the first coordinate */
  20235. x?: number,
  20236. /** defines the second coordinate */
  20237. y?: number);
  20238. /**
  20239. * Gets a string with the Vector2 coordinates
  20240. * @returns a string with the Vector2 coordinates
  20241. */
  20242. toString(): string;
  20243. /**
  20244. * Gets class name
  20245. * @returns the string "Vector2"
  20246. */
  20247. getClassName(): string;
  20248. /**
  20249. * Gets current vector hash code
  20250. * @returns the Vector2 hash code as a number
  20251. */
  20252. getHashCode(): number;
  20253. /**
  20254. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20255. * @param array defines the source array
  20256. * @param index defines the offset in source array
  20257. * @returns the current Vector2
  20258. */
  20259. toArray(array: FloatArray, index?: number): Vector2;
  20260. /**
  20261. * Copy the current vector to an array
  20262. * @returns a new array with 2 elements: the Vector2 coordinates.
  20263. */
  20264. asArray(): number[];
  20265. /**
  20266. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20267. * @param source defines the source Vector2
  20268. * @returns the current updated Vector2
  20269. */
  20270. copyFrom(source: Vector2): Vector2;
  20271. /**
  20272. * Sets the Vector2 coordinates with the given floats
  20273. * @param x defines the first coordinate
  20274. * @param y defines the second coordinate
  20275. * @returns the current updated Vector2
  20276. */
  20277. copyFromFloats(x: number, y: number): Vector2;
  20278. /**
  20279. * Sets the Vector2 coordinates with the given floats
  20280. * @param x defines the first coordinate
  20281. * @param y defines the second coordinate
  20282. * @returns the current updated Vector2
  20283. */
  20284. set(x: number, y: number): Vector2;
  20285. /**
  20286. * Add another vector with the current one
  20287. * @param otherVector defines the other vector
  20288. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20289. */
  20290. add(otherVector: Vector2): Vector2;
  20291. /**
  20292. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20293. * @param otherVector defines the other vector
  20294. * @param result defines the target vector
  20295. * @returns the unmodified current Vector2
  20296. */
  20297. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  20298. /**
  20299. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20300. * @param otherVector defines the other vector
  20301. * @returns the current updated Vector2
  20302. */
  20303. addInPlace(otherVector: Vector2): Vector2;
  20304. /**
  20305. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20306. * @param otherVector defines the other vector
  20307. * @returns a new Vector2
  20308. */
  20309. addVector3(otherVector: Vector3): Vector2;
  20310. /**
  20311. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20312. * @param otherVector defines the other vector
  20313. * @returns a new Vector2
  20314. */
  20315. subtract(otherVector: Vector2): Vector2;
  20316. /**
  20317. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20318. * @param otherVector defines the other vector
  20319. * @param result defines the target vector
  20320. * @returns the unmodified current Vector2
  20321. */
  20322. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  20323. /**
  20324. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20325. * @param otherVector defines the other vector
  20326. * @returns the current updated Vector2
  20327. */
  20328. subtractInPlace(otherVector: Vector2): Vector2;
  20329. /**
  20330. * Multiplies in place the current Vector2 coordinates by the given ones
  20331. * @param otherVector defines the other vector
  20332. * @returns the current updated Vector2
  20333. */
  20334. multiplyInPlace(otherVector: Vector2): Vector2;
  20335. /**
  20336. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20337. * @param otherVector defines the other vector
  20338. * @returns a new Vector2
  20339. */
  20340. multiply(otherVector: Vector2): Vector2;
  20341. /**
  20342. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20343. * @param otherVector defines the other vector
  20344. * @param result defines the target vector
  20345. * @returns the unmodified current Vector2
  20346. */
  20347. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  20348. /**
  20349. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20350. * @param x defines the first coordinate
  20351. * @param y defines the second coordinate
  20352. * @returns a new Vector2
  20353. */
  20354. multiplyByFloats(x: number, y: number): Vector2;
  20355. /**
  20356. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20357. * @param otherVector defines the other vector
  20358. * @returns a new Vector2
  20359. */
  20360. divide(otherVector: Vector2): Vector2;
  20361. /**
  20362. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20363. * @param otherVector defines the other vector
  20364. * @param result defines the target vector
  20365. * @returns the unmodified current Vector2
  20366. */
  20367. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  20368. /**
  20369. * Divides the current Vector2 coordinates by the given ones
  20370. * @param otherVector defines the other vector
  20371. * @returns the current updated Vector2
  20372. */
  20373. divideInPlace(otherVector: Vector2): Vector2;
  20374. /**
  20375. * Gets a new Vector2 with current Vector2 negated coordinates
  20376. * @returns a new Vector2
  20377. */
  20378. negate(): Vector2;
  20379. /**
  20380. * Multiply the Vector2 coordinates by scale
  20381. * @param scale defines the scaling factor
  20382. * @returns the current updated Vector2
  20383. */
  20384. scaleInPlace(scale: number): Vector2;
  20385. /**
  20386. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20387. * @param scale defines the scaling factor
  20388. * @returns a new Vector2
  20389. */
  20390. scale(scale: number): Vector2;
  20391. /**
  20392. * Scale the current Vector2 values by a factor to a given Vector2
  20393. * @param scale defines the scale factor
  20394. * @param result defines the Vector2 object where to store the result
  20395. * @returns the unmodified current Vector2
  20396. */
  20397. scaleToRef(scale: number, result: Vector2): Vector2;
  20398. /**
  20399. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20400. * @param scale defines the scale factor
  20401. * @param result defines the Vector2 object where to store the result
  20402. * @returns the unmodified current Vector2
  20403. */
  20404. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20405. /**
  20406. * Gets a boolean if two vectors are equals
  20407. * @param otherVector defines the other vector
  20408. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20409. */
  20410. equals(otherVector: Vector2): boolean;
  20411. /**
  20412. * Gets a boolean if two vectors are equals (using an epsilon value)
  20413. * @param otherVector defines the other vector
  20414. * @param epsilon defines the minimal distance to consider equality
  20415. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20416. */
  20417. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20418. /**
  20419. * Gets a new Vector2 from current Vector2 floored values
  20420. * @returns a new Vector2
  20421. */
  20422. floor(): Vector2;
  20423. /**
  20424. * Gets a new Vector2 from current Vector2 floored values
  20425. * @returns a new Vector2
  20426. */
  20427. fract(): Vector2;
  20428. /**
  20429. * Gets the length of the vector
  20430. * @returns the vector length (float)
  20431. */
  20432. length(): number;
  20433. /**
  20434. * Gets the vector squared length
  20435. * @returns the vector squared length (float)
  20436. */
  20437. lengthSquared(): number;
  20438. /**
  20439. * Normalize the vector
  20440. * @returns the current updated Vector2
  20441. */
  20442. normalize(): Vector2;
  20443. /**
  20444. * Gets a new Vector2 copied from the Vector2
  20445. * @returns a new Vector2
  20446. */
  20447. clone(): Vector2;
  20448. /**
  20449. * Gets a new Vector2(0, 0)
  20450. * @returns a new Vector2
  20451. */
  20452. static Zero(): Vector2;
  20453. /**
  20454. * Gets a new Vector2(1, 1)
  20455. * @returns a new Vector2
  20456. */
  20457. static One(): Vector2;
  20458. /**
  20459. * Gets a new Vector2 set from the given index element of the given array
  20460. * @param array defines the data source
  20461. * @param offset defines the offset in the data source
  20462. * @returns a new Vector2
  20463. */
  20464. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20465. /**
  20466. * Sets "result" from the given index element of the given array
  20467. * @param array defines the data source
  20468. * @param offset defines the offset in the data source
  20469. * @param result defines the target vector
  20470. */
  20471. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20472. /**
  20473. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20474. * @param value1 defines 1st point of control
  20475. * @param value2 defines 2nd point of control
  20476. * @param value3 defines 3rd point of control
  20477. * @param value4 defines 4th point of control
  20478. * @param amount defines the interpolation factor
  20479. * @returns a new Vector2
  20480. */
  20481. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20482. /**
  20483. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  20484. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20485. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20486. * @param value defines the value to clamp
  20487. * @param min defines the lower limit
  20488. * @param max defines the upper limit
  20489. * @returns a new Vector2
  20490. */
  20491. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20492. /**
  20493. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20494. * @param value1 defines the 1st control point
  20495. * @param tangent1 defines the outgoing tangent
  20496. * @param value2 defines the 2nd control point
  20497. * @param tangent2 defines the incoming tangent
  20498. * @param amount defines the interpolation factor
  20499. * @returns a new Vector2
  20500. */
  20501. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20502. /**
  20503. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20504. * @param start defines the start vector
  20505. * @param end defines the end vector
  20506. * @param amount defines the interpolation factor
  20507. * @returns a new Vector2
  20508. */
  20509. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20510. /**
  20511. * Gets the dot product of the vector "left" and the vector "right"
  20512. * @param left defines first vector
  20513. * @param right defines second vector
  20514. * @returns the dot product (float)
  20515. */
  20516. static Dot(left: Vector2, right: Vector2): number;
  20517. /**
  20518. * Returns a new Vector2 equal to the normalized given vector
  20519. * @param vector defines the vector to normalize
  20520. * @returns a new Vector2
  20521. */
  20522. static Normalize(vector: Vector2): Vector2;
  20523. /**
  20524. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20525. * @param left defines 1st vector
  20526. * @param right defines 2nd vector
  20527. * @returns a new Vector2
  20528. */
  20529. static Minimize(left: Vector2, right: Vector2): Vector2;
  20530. /**
  20531. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20532. * @param left defines 1st vector
  20533. * @param right defines 2nd vector
  20534. * @returns a new Vector2
  20535. */
  20536. static Maximize(left: Vector2, right: Vector2): Vector2;
  20537. /**
  20538. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20539. * @param vector defines the vector to transform
  20540. * @param transformation defines the matrix to apply
  20541. * @returns a new Vector2
  20542. */
  20543. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20544. /**
  20545. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20546. * @param vector defines the vector to transform
  20547. * @param transformation defines the matrix to apply
  20548. * @param result defines the target vector
  20549. */
  20550. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20551. /**
  20552. * Determines if a given vector is included in a triangle
  20553. * @param p defines the vector to test
  20554. * @param p0 defines 1st triangle point
  20555. * @param p1 defines 2nd triangle point
  20556. * @param p2 defines 3rd triangle point
  20557. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20558. */
  20559. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20560. /**
  20561. * Gets the distance between the vectors "value1" and "value2"
  20562. * @param value1 defines first vector
  20563. * @param value2 defines second vector
  20564. * @returns the distance between vectors
  20565. */
  20566. static Distance(value1: Vector2, value2: Vector2): number;
  20567. /**
  20568. * Returns the squared distance between the vectors "value1" and "value2"
  20569. * @param value1 defines first vector
  20570. * @param value2 defines second vector
  20571. * @returns the squared distance between vectors
  20572. */
  20573. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20574. /**
  20575. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20576. * @param value1 defines first vector
  20577. * @param value2 defines second vector
  20578. * @returns a new Vector2
  20579. */
  20580. static Center(value1: Vector2, value2: Vector2): Vector2;
  20581. /**
  20582. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20583. * @param p defines the middle point
  20584. * @param segA defines one point of the segment
  20585. * @param segB defines the other point of the segment
  20586. * @returns the shortest distance
  20587. */
  20588. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20589. }
  20590. /**
  20591. * Classed used to store (x,y,z) vector representation
  20592. * A Vector3 is the main object used in 3D geometry
  20593. * It can represent etiher the coordinates of a point the space, either a direction
  20594. * Reminder: Babylon.js uses a left handed forward facing system
  20595. */
  20596. class Vector3 {
  20597. /**
  20598. * Defines the first coordinates (on X axis)
  20599. */
  20600. x: number;
  20601. /**
  20602. * Defines the second coordinates (on Y axis)
  20603. */
  20604. y: number;
  20605. /**
  20606. * Defines the third coordinates (on Z axis)
  20607. */
  20608. z: number;
  20609. /**
  20610. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20611. * @param x defines the first coordinates (on X axis)
  20612. * @param y defines the second coordinates (on Y axis)
  20613. * @param z defines the third coordinates (on Z axis)
  20614. */
  20615. constructor(
  20616. /**
  20617. * Defines the first coordinates (on X axis)
  20618. */
  20619. x?: number,
  20620. /**
  20621. * Defines the second coordinates (on Y axis)
  20622. */
  20623. y?: number,
  20624. /**
  20625. * Defines the third coordinates (on Z axis)
  20626. */
  20627. z?: number);
  20628. /**
  20629. * Creates a string representation of the Vector3
  20630. * @returns a string with the Vector3 coordinates.
  20631. */
  20632. toString(): string;
  20633. /**
  20634. * Gets the class name
  20635. * @returns the string "Vector3"
  20636. */
  20637. getClassName(): string;
  20638. /**
  20639. * Creates the Vector3 hash code
  20640. * @returns a number which tends to be unique between Vector3 instances
  20641. */
  20642. getHashCode(): number;
  20643. /**
  20644. * Creates an array containing three elements : the coordinates of the Vector3
  20645. * @returns a new array of numbers
  20646. */
  20647. asArray(): number[];
  20648. /**
  20649. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20650. * @param array defines the destination array
  20651. * @param index defines the offset in the destination array
  20652. * @returns the current Vector3
  20653. */
  20654. toArray(array: FloatArray, index?: number): Vector3;
  20655. /**
  20656. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20657. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20658. */
  20659. toQuaternion(): Quaternion;
  20660. /**
  20661. * Adds the given vector to the current Vector3
  20662. * @param otherVector defines the second operand
  20663. * @returns the current updated Vector3
  20664. */
  20665. addInPlace(otherVector: Vector3): Vector3;
  20666. /**
  20667. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20668. * @param otherVector defines the second operand
  20669. * @returns the resulting Vector3
  20670. */
  20671. add(otherVector: Vector3): Vector3;
  20672. /**
  20673. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  20674. * @param otherVector defines the second operand
  20675. * @param result defines the Vector3 object where to store the result
  20676. * @returns the current Vector3
  20677. */
  20678. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  20679. /**
  20680. * Subtract the given vector from the current Vector3
  20681. * @param otherVector defines the second operand
  20682. * @returns the current updated Vector3
  20683. */
  20684. subtractInPlace(otherVector: Vector3): Vector3;
  20685. /**
  20686. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  20687. * @param otherVector defines the second operand
  20688. * @returns the resulting Vector3
  20689. */
  20690. subtract(otherVector: Vector3): Vector3;
  20691. /**
  20692. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  20693. * @param otherVector defines the second operand
  20694. * @param result defines the Vector3 object where to store the result
  20695. * @returns the current Vector3
  20696. */
  20697. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  20698. /**
  20699. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  20700. * @param x defines the x coordinate of the operand
  20701. * @param y defines the y coordinate of the operand
  20702. * @param z defines the z coordinate of the operand
  20703. * @returns the resulting Vector3
  20704. */
  20705. subtractFromFloats(x: number, y: number, z: number): Vector3;
  20706. /**
  20707. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  20708. * @param x defines the x coordinate of the operand
  20709. * @param y defines the y coordinate of the operand
  20710. * @param z defines the z coordinate of the operand
  20711. * @param result defines the Vector3 object where to store the result
  20712. * @returns the current Vector3
  20713. */
  20714. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  20715. /**
  20716. * Gets a new Vector3 set with the current Vector3 negated coordinates
  20717. * @returns a new Vector3
  20718. */
  20719. negate(): Vector3;
  20720. /**
  20721. * Multiplies the Vector3 coordinates by the float "scale"
  20722. * @param scale defines the multiplier factor
  20723. * @returns the current updated Vector3
  20724. */
  20725. scaleInPlace(scale: number): Vector3;
  20726. /**
  20727. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  20728. * @param scale defines the multiplier factor
  20729. * @returns a new Vector3
  20730. */
  20731. scale(scale: number): Vector3;
  20732. /**
  20733. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  20734. * @param scale defines the multiplier factor
  20735. * @param result defines the Vector3 object where to store the result
  20736. * @returns the current Vector3
  20737. */
  20738. scaleToRef(scale: number, result: Vector3): Vector3;
  20739. /**
  20740. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  20741. * @param scale defines the scale factor
  20742. * @param result defines the Vector3 object where to store the result
  20743. * @returns the unmodified current Vector3
  20744. */
  20745. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  20746. /**
  20747. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  20748. * @param otherVector defines the second operand
  20749. * @returns true if both vectors are equals
  20750. */
  20751. equals(otherVector: Vector3): boolean;
  20752. /**
  20753. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  20754. * @param otherVector defines the second operand
  20755. * @param epsilon defines the minimal distance to define values as equals
  20756. * @returns true if both vectors are distant less than epsilon
  20757. */
  20758. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  20759. /**
  20760. * Returns true if the current Vector3 coordinates equals the given floats
  20761. * @param x defines the x coordinate of the operand
  20762. * @param y defines the y coordinate of the operand
  20763. * @param z defines the z coordinate of the operand
  20764. * @returns true if both vectors are equals
  20765. */
  20766. equalsToFloats(x: number, y: number, z: number): boolean;
  20767. /**
  20768. * Multiplies the current Vector3 coordinates by the given ones
  20769. * @param otherVector defines the second operand
  20770. * @returns the current updated Vector3
  20771. */
  20772. multiplyInPlace(otherVector: Vector3): Vector3;
  20773. /**
  20774. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  20775. * @param otherVector defines the second operand
  20776. * @returns the new Vector3
  20777. */
  20778. multiply(otherVector: Vector3): Vector3;
  20779. /**
  20780. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  20781. * @param otherVector defines the second operand
  20782. * @param result defines the Vector3 object where to store the result
  20783. * @returns the current Vector3
  20784. */
  20785. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  20786. /**
  20787. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  20788. * @param x defines the x coordinate of the operand
  20789. * @param y defines the y coordinate of the operand
  20790. * @param z defines the z coordinate of the operand
  20791. * @returns the new Vector3
  20792. */
  20793. multiplyByFloats(x: number, y: number, z: number): Vector3;
  20794. /**
  20795. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  20796. * @param otherVector defines the second operand
  20797. * @returns the new Vector3
  20798. */
  20799. divide(otherVector: Vector3): Vector3;
  20800. /**
  20801. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  20802. * @param otherVector defines the second operand
  20803. * @param result defines the Vector3 object where to store the result
  20804. * @returns the current Vector3
  20805. */
  20806. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  20807. /**
  20808. * Divides the current Vector3 coordinates by the given ones.
  20809. * @param otherVector defines the second operand
  20810. * @returns the current updated Vector3
  20811. */
  20812. divideInPlace(otherVector: Vector3): Vector3;
  20813. /**
  20814. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  20815. * @param other defines the second operand
  20816. * @returns the current updated Vector3
  20817. */
  20818. minimizeInPlace(other: Vector3): Vector3;
  20819. /**
  20820. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  20821. * @param other defines the second operand
  20822. * @returns the current updated Vector3
  20823. */
  20824. maximizeInPlace(other: Vector3): Vector3;
  20825. /**
  20826. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  20827. * @param x defines the x coordinate of the operand
  20828. * @param y defines the y coordinate of the operand
  20829. * @param z defines the z coordinate of the operand
  20830. * @returns the current updated Vector3
  20831. */
  20832. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20833. /**
  20834. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  20835. * @param x defines the x coordinate of the operand
  20836. * @param y defines the y coordinate of the operand
  20837. * @param z defines the z coordinate of the operand
  20838. * @returns the current updated Vector3
  20839. */
  20840. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20841. /**
  20842. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  20843. */
  20844. readonly isNonUniform: boolean;
  20845. /**
  20846. * Gets a new Vector3 from current Vector3 floored values
  20847. * @returns a new Vector3
  20848. */
  20849. floor(): Vector3;
  20850. /**
  20851. * Gets a new Vector3 from current Vector3 floored values
  20852. * @returns a new Vector3
  20853. */
  20854. fract(): Vector3;
  20855. /**
  20856. * Gets the length of the Vector3
  20857. * @returns the length of the Vecto3
  20858. */
  20859. length(): number;
  20860. /**
  20861. * Gets the squared length of the Vector3
  20862. * @returns squared length of the Vector3
  20863. */
  20864. lengthSquared(): number;
  20865. /**
  20866. * Normalize the current Vector3.
  20867. * Please note that this is an in place operation.
  20868. * @returns the current updated Vector3
  20869. */
  20870. normalize(): Vector3;
  20871. /**
  20872. * Normalize the current Vector3 to a new vector
  20873. * @returns the new Vector3
  20874. */
  20875. normalizeToNew(): Vector3;
  20876. /**
  20877. * Normalize the current Vector3 to the reference
  20878. * @param reference define the Vector3 to update
  20879. * @returns the updated Vector3
  20880. */
  20881. normalizeToRef(reference: Vector3): Vector3;
  20882. /**
  20883. * Creates a new Vector3 copied from the current Vector3
  20884. * @returns the new Vector3
  20885. */
  20886. clone(): Vector3;
  20887. /**
  20888. * Copies the given vector coordinates to the current Vector3 ones
  20889. * @param source defines the source Vector3
  20890. * @returns the current updated Vector3
  20891. */
  20892. copyFrom(source: Vector3): Vector3;
  20893. /**
  20894. * Copies the given floats to the current Vector3 coordinates
  20895. * @param x defines the x coordinate of the operand
  20896. * @param y defines the y coordinate of the operand
  20897. * @param z defines the z coordinate of the operand
  20898. * @returns the current updated Vector3
  20899. */
  20900. copyFromFloats(x: number, y: number, z: number): Vector3;
  20901. /**
  20902. * Copies the given floats to the current Vector3 coordinates
  20903. * @param x defines the x coordinate of the operand
  20904. * @param y defines the y coordinate of the operand
  20905. * @param z defines the z coordinate of the operand
  20906. * @returns the current updated Vector3
  20907. */
  20908. set(x: number, y: number, z: number): Vector3;
  20909. /**
  20910. * Get the clip factor between two vectors
  20911. * @param vector0 defines the first operand
  20912. * @param vector1 defines the second operand
  20913. * @param axis defines the axis to use
  20914. * @param size defines the size along the axis
  20915. * @returns the clip factor
  20916. */
  20917. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  20918. /**
  20919. * Get angle between two vectors
  20920. * @param vector0 angle between vector0 and vector1
  20921. * @param vector1 angle between vector0 and vector1
  20922. * @param normal direction of the normal
  20923. * @return the angle between vector0 and vector1
  20924. */
  20925. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  20926. /**
  20927. * Returns a new Vector3 set from the index "offset" of the given array
  20928. * @param array defines the source array
  20929. * @param offset defines the offset in the source array
  20930. * @returns the new Vector3
  20931. */
  20932. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  20933. /**
  20934. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  20935. * This function is deprecated. Use FromArray instead
  20936. * @param array defines the source array
  20937. * @param offset defines the offset in the source array
  20938. * @returns the new Vector3
  20939. */
  20940. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  20941. /**
  20942. * Sets the given vector "result" with the element values from the index "offset" of the given array
  20943. * @param array defines the source array
  20944. * @param offset defines the offset in the source array
  20945. * @param result defines the Vector3 where to store the result
  20946. */
  20947. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  20948. /**
  20949. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  20950. * This function is deprecated. Use FromArrayToRef instead.
  20951. * @param array defines the source array
  20952. * @param offset defines the offset in the source array
  20953. * @param result defines the Vector3 where to store the result
  20954. */
  20955. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  20956. /**
  20957. * Sets the given vector "result" with the given floats.
  20958. * @param x defines the x coordinate of the source
  20959. * @param y defines the y coordinate of the source
  20960. * @param z defines the z coordinate of the source
  20961. * @param result defines the Vector3 where to store the result
  20962. */
  20963. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  20964. /**
  20965. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  20966. * @returns a new empty Vector3
  20967. */
  20968. static Zero(): Vector3;
  20969. /**
  20970. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  20971. * @returns a new unit Vector3
  20972. */
  20973. static One(): Vector3;
  20974. /**
  20975. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  20976. * @returns a new up Vector3
  20977. */
  20978. static Up(): Vector3;
  20979. /**
  20980. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  20981. * @returns a new down Vector3
  20982. */
  20983. static Down(): Vector3;
  20984. /**
  20985. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  20986. * @returns a new forward Vector3
  20987. */
  20988. static Forward(): Vector3;
  20989. /**
  20990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  20991. * @returns a new forward Vector3
  20992. */
  20993. static Backward(): Vector3;
  20994. /**
  20995. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  20996. * @returns a new right Vector3
  20997. */
  20998. static Right(): Vector3;
  20999. /**
  21000. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21001. * @returns a new left Vector3
  21002. */
  21003. static Left(): Vector3;
  21004. /**
  21005. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21006. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21007. * @param vector defines the Vector3 to transform
  21008. * @param transformation defines the transformation matrix
  21009. * @returns the transformed Vector3
  21010. */
  21011. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  21012. /**
  21013. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21014. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21015. * @param vector defines the Vector3 to transform
  21016. * @param transformation defines the transformation matrix
  21017. * @param result defines the Vector3 where to store the result
  21018. */
  21019. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21020. /**
  21021. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21022. * This method computes tranformed coordinates only, not transformed direction vectors
  21023. * @param x define the x coordinate of the source vector
  21024. * @param y define the y coordinate of the source vector
  21025. * @param z define the z coordinate of the source vector
  21026. * @param transformation defines the transformation matrix
  21027. * @param result defines the Vector3 where to store the result
  21028. */
  21029. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21030. /**
  21031. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21032. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21033. * @param vector defines the Vector3 to transform
  21034. * @param transformation defines the transformation matrix
  21035. * @returns the new Vector3
  21036. */
  21037. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  21038. /**
  21039. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21040. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21041. * @param vector defines the Vector3 to transform
  21042. * @param transformation defines the transformation matrix
  21043. * @param result defines the Vector3 where to store the result
  21044. */
  21045. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21046. /**
  21047. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21048. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21049. * @param x define the x coordinate of the source vector
  21050. * @param y define the y coordinate of the source vector
  21051. * @param z define the z coordinate of the source vector
  21052. * @param transformation defines the transformation matrix
  21053. * @param result defines the Vector3 where to store the result
  21054. */
  21055. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21056. /**
  21057. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21058. * @param value1 defines the first control point
  21059. * @param value2 defines the second control point
  21060. * @param value3 defines the third control point
  21061. * @param value4 defines the fourth control point
  21062. * @param amount defines the amount on the spline to use
  21063. * @returns the new Vector3
  21064. */
  21065. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  21066. /**
  21067. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  21068. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21069. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21070. * @param value defines the current value
  21071. * @param min defines the lower range value
  21072. * @param max defines the upper range value
  21073. * @returns the new Vector3
  21074. */
  21075. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  21076. /**
  21077. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21078. * @param value1 defines the first control point
  21079. * @param tangent1 defines the first tangent vector
  21080. * @param value2 defines the second control point
  21081. * @param tangent2 defines the second tangent vector
  21082. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21083. * @returns the new Vector3
  21084. */
  21085. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  21086. /**
  21087. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21088. * @param start defines the start value
  21089. * @param end defines the end value
  21090. * @param amount max defines amount between both (between 0 and 1)
  21091. * @returns the new Vector3
  21092. */
  21093. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  21094. /**
  21095. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21096. * @param start defines the start value
  21097. * @param end defines the end value
  21098. * @param amount max defines amount between both (between 0 and 1)
  21099. * @param result defines the Vector3 where to store the result
  21100. */
  21101. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  21102. /**
  21103. * Returns the dot product (float) between the vectors "left" and "right"
  21104. * @param left defines the left operand
  21105. * @param right defines the right operand
  21106. * @returns the dot product
  21107. */
  21108. static Dot(left: Vector3, right: Vector3): number;
  21109. /**
  21110. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21111. * The cross product is then orthogonal to both "left" and "right"
  21112. * @param left defines the left operand
  21113. * @param right defines the right operand
  21114. * @returns the cross product
  21115. */
  21116. static Cross(left: Vector3, right: Vector3): Vector3;
  21117. /**
  21118. * Sets the given vector "result" with the cross product of "left" and "right"
  21119. * The cross product is then orthogonal to both "left" and "right"
  21120. * @param left defines the left operand
  21121. * @param right defines the right operand
  21122. * @param result defines the Vector3 where to store the result
  21123. */
  21124. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21125. /**
  21126. * Returns a new Vector3 as the normalization of the given vector
  21127. * @param vector defines the Vector3 to normalize
  21128. * @returns the new Vector3
  21129. */
  21130. static Normalize(vector: Vector3): Vector3;
  21131. /**
  21132. * Sets the given vector "result" with the normalization of the given first vector
  21133. * @param vector defines the Vector3 to normalize
  21134. * @param result defines the Vector3 where to store the result
  21135. */
  21136. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  21137. private static _viewportMatrixCache;
  21138. /**
  21139. * Project a Vector3 onto screen space
  21140. * @param vector defines the Vector3 to project
  21141. * @param world defines the world matrix to use
  21142. * @param transform defines the transform (view x projection) matrix to use
  21143. * @param viewport defines the screen viewport to use
  21144. * @returns the new Vector3
  21145. */
  21146. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  21147. /**
  21148. * Unproject from screen space to object space
  21149. * @param source defines the screen space Vector3 to use
  21150. * @param viewportWidth defines the current width of the viewport
  21151. * @param viewportHeight defines the current height of the viewport
  21152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21153. * @param transform defines the transform (view x projection) matrix to use
  21154. * @returns the new Vector3
  21155. */
  21156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  21157. /**
  21158. * Unproject from screen space to object space
  21159. * @param source defines the screen space Vector3 to use
  21160. * @param viewportWidth defines the current width of the viewport
  21161. * @param viewportHeight defines the current height of the viewport
  21162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21163. * @param view defines the view matrix to use
  21164. * @param projection defines the projection matrix to use
  21165. * @returns the new Vector3
  21166. */
  21167. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  21168. /**
  21169. * Unproject from screen space to object space
  21170. * @param source defines the screen space Vector3 to use
  21171. * @param viewportWidth defines the current width of the viewport
  21172. * @param viewportHeight defines the current height of the viewport
  21173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21174. * @param view defines the view matrix to use
  21175. * @param projection defines the projection matrix to use
  21176. * @param result defines the Vector3 where to store the result
  21177. */
  21178. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21179. /**
  21180. * Unproject from screen space to object space
  21181. * @param sourceX defines the screen space x coordinate to use
  21182. * @param sourceY defines the screen space y coordinate to use
  21183. * @param sourceZ defines the screen space z coordinate to use
  21184. * @param viewportWidth defines the current width of the viewport
  21185. * @param viewportHeight defines the current height of the viewport
  21186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21187. * @param view defines the view matrix to use
  21188. * @param projection defines the projection matrix to use
  21189. * @param result defines the Vector3 where to store the result
  21190. */
  21191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21192. /**
  21193. * Gets the minimal coordinate values between two Vector3
  21194. * @param left defines the first operand
  21195. * @param right defines the second operand
  21196. * @returns the new Vector3
  21197. */
  21198. static Minimize(left: Vector3, right: Vector3): Vector3;
  21199. /**
  21200. * Gets the maximal coordinate values between two Vector3
  21201. * @param left defines the first operand
  21202. * @param right defines the second operand
  21203. * @returns the new Vector3
  21204. */
  21205. static Maximize(left: Vector3, right: Vector3): Vector3;
  21206. /**
  21207. * Returns the distance between the vectors "value1" and "value2"
  21208. * @param value1 defines the first operand
  21209. * @param value2 defines the second operand
  21210. * @returns the distance
  21211. */
  21212. static Distance(value1: Vector3, value2: Vector3): number;
  21213. /**
  21214. * Returns the squared distance between the vectors "value1" and "value2"
  21215. * @param value1 defines the first operand
  21216. * @param value2 defines the second operand
  21217. * @returns the squared distance
  21218. */
  21219. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  21220. /**
  21221. * Returns a new Vector3 located at the center between "value1" and "value2"
  21222. * @param value1 defines the first operand
  21223. * @param value2 defines the second operand
  21224. * @returns the new Vector3
  21225. */
  21226. static Center(value1: Vector3, value2: Vector3): Vector3;
  21227. /**
  21228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21230. * to something in order to rotate it from its local system to the given target system
  21231. * Note: axis1, axis2 and axis3 are normalized during this operation
  21232. * @param axis1 defines the first axis
  21233. * @param axis2 defines the second axis
  21234. * @param axis3 defines the third axis
  21235. * @returns a new Vector3
  21236. */
  21237. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  21238. /**
  21239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21240. * @param axis1 defines the first axis
  21241. * @param axis2 defines the second axis
  21242. * @param axis3 defines the third axis
  21243. * @param ref defines the Vector3 where to store the result
  21244. */
  21245. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  21246. }
  21247. /**
  21248. * Vector4 class created for EulerAngle class conversion to Quaternion
  21249. */
  21250. class Vector4 {
  21251. /** x value of the vector */
  21252. x: number;
  21253. /** y value of the vector */
  21254. y: number;
  21255. /** z value of the vector */
  21256. z: number;
  21257. /** w value of the vector */
  21258. w: number;
  21259. /**
  21260. * Creates a Vector4 object from the given floats.
  21261. * @param x x value of the vector
  21262. * @param y y value of the vector
  21263. * @param z z value of the vector
  21264. * @param w w value of the vector
  21265. */
  21266. constructor(
  21267. /** x value of the vector */
  21268. x: number,
  21269. /** y value of the vector */
  21270. y: number,
  21271. /** z value of the vector */
  21272. z: number,
  21273. /** w value of the vector */
  21274. w: number);
  21275. /**
  21276. * Returns the string with the Vector4 coordinates.
  21277. * @returns a string containing all the vector values
  21278. */
  21279. toString(): string;
  21280. /**
  21281. * Returns the string "Vector4".
  21282. * @returns "Vector4"
  21283. */
  21284. getClassName(): string;
  21285. /**
  21286. * Returns the Vector4 hash code.
  21287. * @returns a unique hash code
  21288. */
  21289. getHashCode(): number;
  21290. /**
  21291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21292. * @returns the resulting array
  21293. */
  21294. asArray(): number[];
  21295. /**
  21296. * Populates the given array from the given index with the Vector4 coordinates.
  21297. * @param array array to populate
  21298. * @param index index of the array to start at (default: 0)
  21299. * @returns the Vector4.
  21300. */
  21301. toArray(array: FloatArray, index?: number): Vector4;
  21302. /**
  21303. * Adds the given vector to the current Vector4.
  21304. * @param otherVector the vector to add
  21305. * @returns the updated Vector4.
  21306. */
  21307. addInPlace(otherVector: Vector4): Vector4;
  21308. /**
  21309. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21310. * @param otherVector the vector to add
  21311. * @returns the resulting vector
  21312. */
  21313. add(otherVector: Vector4): Vector4;
  21314. /**
  21315. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21316. * @param otherVector the vector to add
  21317. * @param result the vector to store the result
  21318. * @returns the current Vector4.
  21319. */
  21320. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  21321. /**
  21322. * Subtract in place the given vector from the current Vector4.
  21323. * @param otherVector the vector to subtract
  21324. * @returns the updated Vector4.
  21325. */
  21326. subtractInPlace(otherVector: Vector4): Vector4;
  21327. /**
  21328. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21329. * @param otherVector the vector to add
  21330. * @returns the new vector with the result
  21331. */
  21332. subtract(otherVector: Vector4): Vector4;
  21333. /**
  21334. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21335. * @param otherVector the vector to subtract
  21336. * @param result the vector to store the result
  21337. * @returns the current Vector4.
  21338. */
  21339. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  21340. /**
  21341. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21342. */
  21343. /**
  21344. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21345. * @param x value to subtract
  21346. * @param y value to subtract
  21347. * @param z value to subtract
  21348. * @param w value to subtract
  21349. * @returns new vector containing the result
  21350. */
  21351. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21352. /**
  21353. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21354. * @param x value to subtract
  21355. * @param y value to subtract
  21356. * @param z value to subtract
  21357. * @param w value to subtract
  21358. * @param result the vector to store the result in
  21359. * @returns the current Vector4.
  21360. */
  21361. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21362. /**
  21363. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21364. * @returns a new vector with the negated values
  21365. */
  21366. negate(): Vector4;
  21367. /**
  21368. * Multiplies the current Vector4 coordinates by scale (float).
  21369. * @param scale the number to scale with
  21370. * @returns the updated Vector4.
  21371. */
  21372. scaleInPlace(scale: number): Vector4;
  21373. /**
  21374. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21375. * @param scale the number to scale with
  21376. * @returns a new vector with the result
  21377. */
  21378. scale(scale: number): Vector4;
  21379. /**
  21380. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21381. * @param scale the number to scale with
  21382. * @param result a vector to store the result in
  21383. * @returns the current Vector4.
  21384. */
  21385. scaleToRef(scale: number, result: Vector4): Vector4;
  21386. /**
  21387. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21388. * @param scale defines the scale factor
  21389. * @param result defines the Vector4 object where to store the result
  21390. * @returns the unmodified current Vector4
  21391. */
  21392. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21393. /**
  21394. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21395. * @param otherVector the vector to compare against
  21396. * @returns true if they are equal
  21397. */
  21398. equals(otherVector: Vector4): boolean;
  21399. /**
  21400. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21401. * @param otherVector vector to compare against
  21402. * @param epsilon (Default: very small number)
  21403. * @returns true if they are equal
  21404. */
  21405. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21406. /**
  21407. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21408. * @param x x value to compare against
  21409. * @param y y value to compare against
  21410. * @param z z value to compare against
  21411. * @param w w value to compare against
  21412. * @returns true if equal
  21413. */
  21414. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21415. /**
  21416. * Multiplies in place the current Vector4 by the given one.
  21417. * @param otherVector vector to multiple with
  21418. * @returns the updated Vector4.
  21419. */
  21420. multiplyInPlace(otherVector: Vector4): Vector4;
  21421. /**
  21422. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21423. * @param otherVector vector to multiple with
  21424. * @returns resulting new vector
  21425. */
  21426. multiply(otherVector: Vector4): Vector4;
  21427. /**
  21428. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21429. * @param otherVector vector to multiple with
  21430. * @param result vector to store the result
  21431. * @returns the current Vector4.
  21432. */
  21433. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21434. /**
  21435. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21436. * @param x x value multiply with
  21437. * @param y y value multiply with
  21438. * @param z z value multiply with
  21439. * @param w w value multiply with
  21440. * @returns resulting new vector
  21441. */
  21442. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21443. /**
  21444. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21445. * @param otherVector vector to devide with
  21446. * @returns resulting new vector
  21447. */
  21448. divide(otherVector: Vector4): Vector4;
  21449. /**
  21450. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21451. * @param otherVector vector to devide with
  21452. * @param result vector to store the result
  21453. * @returns the current Vector4.
  21454. */
  21455. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21456. /**
  21457. * Divides the current Vector3 coordinates by the given ones.
  21458. * @param otherVector vector to devide with
  21459. * @returns the updated Vector3.
  21460. */
  21461. divideInPlace(otherVector: Vector4): Vector4;
  21462. /**
  21463. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21464. * @param other defines the second operand
  21465. * @returns the current updated Vector4
  21466. */
  21467. minimizeInPlace(other: Vector4): Vector4;
  21468. /**
  21469. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21470. * @param other defines the second operand
  21471. * @returns the current updated Vector4
  21472. */
  21473. maximizeInPlace(other: Vector4): Vector4;
  21474. /**
  21475. * Gets a new Vector4 from current Vector4 floored values
  21476. * @returns a new Vector4
  21477. */
  21478. floor(): Vector4;
  21479. /**
  21480. * Gets a new Vector4 from current Vector3 floored values
  21481. * @returns a new Vector4
  21482. */
  21483. fract(): Vector4;
  21484. /**
  21485. * Returns the Vector4 length (float).
  21486. * @returns the length
  21487. */
  21488. length(): number;
  21489. /**
  21490. * Returns the Vector4 squared length (float).
  21491. * @returns the length squared
  21492. */
  21493. lengthSquared(): number;
  21494. /**
  21495. * Normalizes in place the Vector4.
  21496. * @returns the updated Vector4.
  21497. */
  21498. normalize(): Vector4;
  21499. /**
  21500. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21501. * @returns this converted to a new vector3
  21502. */
  21503. toVector3(): Vector3;
  21504. /**
  21505. * Returns a new Vector4 copied from the current one.
  21506. * @returns the new cloned vector
  21507. */
  21508. clone(): Vector4;
  21509. /**
  21510. * Updates the current Vector4 with the given one coordinates.
  21511. * @param source the source vector to copy from
  21512. * @returns the updated Vector4.
  21513. */
  21514. copyFrom(source: Vector4): Vector4;
  21515. /**
  21516. * Updates the current Vector4 coordinates with the given floats.
  21517. * @param x float to copy from
  21518. * @param y float to copy from
  21519. * @param z float to copy from
  21520. * @param w float to copy from
  21521. * @returns the updated Vector4.
  21522. */
  21523. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21524. /**
  21525. * Updates the current Vector4 coordinates with the given floats.
  21526. * @param x float to set from
  21527. * @param y float to set from
  21528. * @param z float to set from
  21529. * @param w float to set from
  21530. * @returns the updated Vector4.
  21531. */
  21532. set(x: number, y: number, z: number, w: number): Vector4;
  21533. /**
  21534. * Returns a new Vector4 set from the starting index of the given array.
  21535. * @param array the array to pull values from
  21536. * @param offset the offset into the array to start at
  21537. * @returns the new vector
  21538. */
  21539. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21540. /**
  21541. * Updates the given vector "result" from the starting index of the given array.
  21542. * @param array the array to pull values from
  21543. * @param offset the offset into the array to start at
  21544. * @param result the vector to store the result in
  21545. */
  21546. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21547. /**
  21548. * Updates the given vector "result" from the starting index of the given Float32Array.
  21549. * @param array the array to pull values from
  21550. * @param offset the offset into the array to start at
  21551. * @param result the vector to store the result in
  21552. */
  21553. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21554. /**
  21555. * Updates the given vector "result" coordinates from the given floats.
  21556. * @param x float to set from
  21557. * @param y float to set from
  21558. * @param z float to set from
  21559. * @param w float to set from
  21560. * @param result the vector to the floats in
  21561. */
  21562. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21563. /**
  21564. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21565. * @returns the new vector
  21566. */
  21567. static Zero(): Vector4;
  21568. /**
  21569. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21570. * @returns the new vector
  21571. */
  21572. static One(): Vector4;
  21573. /**
  21574. * Returns a new normalized Vector4 from the given one.
  21575. * @param vector the vector to normalize
  21576. * @returns the vector
  21577. */
  21578. static Normalize(vector: Vector4): Vector4;
  21579. /**
  21580. * Updates the given vector "result" from the normalization of the given one.
  21581. * @param vector the vector to normalize
  21582. * @param result the vector to store the result in
  21583. */
  21584. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  21585. /**
  21586. * Returns a vector with the minimum values from the left and right vectors
  21587. * @param left left vector to minimize
  21588. * @param right right vector to minimize
  21589. * @returns a new vector with the minimum of the left and right vector values
  21590. */
  21591. static Minimize(left: Vector4, right: Vector4): Vector4;
  21592. /**
  21593. * Returns a vector with the maximum values from the left and right vectors
  21594. * @param left left vector to maximize
  21595. * @param right right vector to maximize
  21596. * @returns a new vector with the maximum of the left and right vector values
  21597. */
  21598. static Maximize(left: Vector4, right: Vector4): Vector4;
  21599. /**
  21600. * Returns the distance (float) between the vectors "value1" and "value2".
  21601. * @param value1 value to calulate the distance between
  21602. * @param value2 value to calulate the distance between
  21603. * @return the distance between the two vectors
  21604. */
  21605. static Distance(value1: Vector4, value2: Vector4): number;
  21606. /**
  21607. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21608. * @param value1 value to calulate the distance between
  21609. * @param value2 value to calulate the distance between
  21610. * @return the distance between the two vectors squared
  21611. */
  21612. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  21613. /**
  21614. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21615. * @param value1 value to calulate the center between
  21616. * @param value2 value to calulate the center between
  21617. * @return the center between the two vectors
  21618. */
  21619. static Center(value1: Vector4, value2: Vector4): Vector4;
  21620. /**
  21621. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21622. * This methods computes transformed normalized direction vectors only.
  21623. * @param vector the vector to transform
  21624. * @param transformation the transformation matrix to apply
  21625. * @returns the new vector
  21626. */
  21627. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  21628. /**
  21629. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21630. * This methods computes transformed normalized direction vectors only.
  21631. * @param vector the vector to transform
  21632. * @param transformation the transformation matrix to apply
  21633. * @param result the vector to store the result in
  21634. */
  21635. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  21636. /**
  21637. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  21638. * This methods computes transformed normalized direction vectors only.
  21639. * @param x value to transform
  21640. * @param y value to transform
  21641. * @param z value to transform
  21642. * @param w value to transform
  21643. * @param transformation the transformation matrix to apply
  21644. * @param result the vector to store the results in
  21645. */
  21646. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  21647. }
  21648. /**
  21649. * Interface for the size containing width and height
  21650. */
  21651. interface ISize {
  21652. /**
  21653. * Width
  21654. */
  21655. width: number;
  21656. /**
  21657. * Heighht
  21658. */
  21659. height: number;
  21660. }
  21661. /**
  21662. * Size containing widht and height
  21663. */
  21664. class Size implements ISize {
  21665. /**
  21666. * Width
  21667. */
  21668. width: number;
  21669. /**
  21670. * Height
  21671. */
  21672. height: number;
  21673. /**
  21674. * Creates a Size object from the given width and height (floats).
  21675. * @param width width of the new size
  21676. * @param height height of the new size
  21677. */
  21678. constructor(width: number, height: number);
  21679. /**
  21680. * Returns a string with the Size width and height
  21681. * @returns a string with the Size width and height
  21682. */
  21683. toString(): string;
  21684. /**
  21685. * "Size"
  21686. * @returns the string "Size"
  21687. */
  21688. getClassName(): string;
  21689. /**
  21690. * Returns the Size hash code.
  21691. * @returns a hash code for a unique width and height
  21692. */
  21693. getHashCode(): number;
  21694. /**
  21695. * Updates the current size from the given one.
  21696. * @param src the given size
  21697. */
  21698. copyFrom(src: Size): void;
  21699. /**
  21700. * Updates in place the current Size from the given floats.
  21701. * @param width width of the new size
  21702. * @param height height of the new size
  21703. * @returns the updated Size.
  21704. */
  21705. copyFromFloats(width: number, height: number): Size;
  21706. /**
  21707. * Updates in place the current Size from the given floats.
  21708. * @param width width to set
  21709. * @param height height to set
  21710. * @returns the updated Size.
  21711. */
  21712. set(width: number, height: number): Size;
  21713. /**
  21714. * Multiplies the width and height by numbers
  21715. * @param w factor to multiple the width by
  21716. * @param h factor to multiple the height by
  21717. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  21718. */
  21719. multiplyByFloats(w: number, h: number): Size;
  21720. /**
  21721. * Clones the size
  21722. * @returns a new Size copied from the given one.
  21723. */
  21724. clone(): Size;
  21725. /**
  21726. * True if the current Size and the given one width and height are strictly equal.
  21727. * @param other the other size to compare against
  21728. * @returns True if the current Size and the given one width and height are strictly equal.
  21729. */
  21730. equals(other: Size): boolean;
  21731. /**
  21732. * The surface of the Size : width * height (float).
  21733. */
  21734. readonly surface: number;
  21735. /**
  21736. * Create a new size of zero
  21737. * @returns a new Size set to (0.0, 0.0)
  21738. */
  21739. static Zero(): Size;
  21740. /**
  21741. * Sums the width and height of two sizes
  21742. * @param otherSize size to add to this size
  21743. * @returns a new Size set as the addition result of the current Size and the given one.
  21744. */
  21745. add(otherSize: Size): Size;
  21746. /**
  21747. * Subtracts the width and height of two
  21748. * @param otherSize size to subtract to this size
  21749. * @returns a new Size set as the subtraction result of the given one from the current Size.
  21750. */
  21751. subtract(otherSize: Size): Size;
  21752. /**
  21753. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  21754. * @param start starting size to lerp between
  21755. * @param end end size to lerp between
  21756. * @param amount amount to lerp between the start and end values
  21757. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  21758. */
  21759. static Lerp(start: Size, end: Size, amount: number): Size;
  21760. }
  21761. /**
  21762. * Class used to store quaternion data
  21763. * @see https://en.wikipedia.org/wiki/Quaternion
  21764. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  21765. */
  21766. class Quaternion {
  21767. /** defines the first component (0 by default) */
  21768. x: number;
  21769. /** defines the second component (0 by default) */
  21770. y: number;
  21771. /** defines the third component (0 by default) */
  21772. z: number;
  21773. /** defines the fourth component (1.0 by default) */
  21774. w: number;
  21775. /**
  21776. * Creates a new Quaternion from the given floats
  21777. * @param x defines the first component (0 by default)
  21778. * @param y defines the second component (0 by default)
  21779. * @param z defines the third component (0 by default)
  21780. * @param w defines the fourth component (1.0 by default)
  21781. */
  21782. constructor(
  21783. /** defines the first component (0 by default) */
  21784. x?: number,
  21785. /** defines the second component (0 by default) */
  21786. y?: number,
  21787. /** defines the third component (0 by default) */
  21788. z?: number,
  21789. /** defines the fourth component (1.0 by default) */
  21790. w?: number);
  21791. /**
  21792. * Gets a string representation for the current quaternion
  21793. * @returns a string with the Quaternion coordinates
  21794. */
  21795. toString(): string;
  21796. /**
  21797. * Gets the class name of the quaternion
  21798. * @returns the string "Quaternion"
  21799. */
  21800. getClassName(): string;
  21801. /**
  21802. * Gets a hash code for this quaternion
  21803. * @returns the quaternion hash code
  21804. */
  21805. getHashCode(): number;
  21806. /**
  21807. * Copy the quaternion to an array
  21808. * @returns a new array populated with 4 elements from the quaternion coordinates
  21809. */
  21810. asArray(): number[];
  21811. /**
  21812. * Check if two quaternions are equals
  21813. * @param otherQuaternion defines the second operand
  21814. * @return true if the current quaternion and the given one coordinates are strictly equals
  21815. */
  21816. equals(otherQuaternion: Quaternion): boolean;
  21817. /**
  21818. * Clone the current quaternion
  21819. * @returns a new quaternion copied from the current one
  21820. */
  21821. clone(): Quaternion;
  21822. /**
  21823. * Copy a quaternion to the current one
  21824. * @param other defines the other quaternion
  21825. * @returns the updated current quaternion
  21826. */
  21827. copyFrom(other: Quaternion): Quaternion;
  21828. /**
  21829. * Updates the current quaternion with the given float coordinates
  21830. * @param x defines the x coordinate
  21831. * @param y defines the y coordinate
  21832. * @param z defines the z coordinate
  21833. * @param w defines the w coordinate
  21834. * @returns the updated current quaternion
  21835. */
  21836. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  21837. /**
  21838. * Updates the current quaternion from the given float coordinates
  21839. * @param x defines the x coordinate
  21840. * @param y defines the y coordinate
  21841. * @param z defines the z coordinate
  21842. * @param w defines the w coordinate
  21843. * @returns the updated current quaternion
  21844. */
  21845. set(x: number, y: number, z: number, w: number): Quaternion;
  21846. /**
  21847. * Adds two quaternions
  21848. * @param other defines the second operand
  21849. * @returns a new quaternion as the addition result of the given one and the current quaternion
  21850. */
  21851. add(other: Quaternion): Quaternion;
  21852. /**
  21853. * Add a quaternion to the current one
  21854. * @param other defines the quaternion to add
  21855. * @returns the current quaternion
  21856. */
  21857. addInPlace(other: Quaternion): Quaternion;
  21858. /**
  21859. * Subtract two quaternions
  21860. * @param other defines the second operand
  21861. * @returns a new quaternion as the subtraction result of the given one from the current one
  21862. */
  21863. subtract(other: Quaternion): Quaternion;
  21864. /**
  21865. * Multiplies the current quaternion by a scale factor
  21866. * @param value defines the scale factor
  21867. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  21868. */
  21869. scale(value: number): Quaternion;
  21870. /**
  21871. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  21872. * @param scale defines the scale factor
  21873. * @param result defines the Quaternion object where to store the result
  21874. * @returns the unmodified current quaternion
  21875. */
  21876. scaleToRef(scale: number, result: Quaternion): Quaternion;
  21877. /**
  21878. * Multiplies in place the current quaternion by a scale factor
  21879. * @param value defines the scale factor
  21880. * @returns the current modified quaternion
  21881. */
  21882. scaleInPlace(value: number): Quaternion;
  21883. /**
  21884. * Scale the current quaternion values by a factor and add the result to a given quaternion
  21885. * @param scale defines the scale factor
  21886. * @param result defines the Quaternion object where to store the result
  21887. * @returns the unmodified current quaternion
  21888. */
  21889. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  21890. /**
  21891. * Multiplies two quaternions
  21892. * @param q1 defines the second operand
  21893. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  21894. */
  21895. multiply(q1: Quaternion): Quaternion;
  21896. /**
  21897. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  21898. * @param q1 defines the second operand
  21899. * @param result defines the target quaternion
  21900. * @returns the current quaternion
  21901. */
  21902. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  21903. /**
  21904. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  21905. * @param q1 defines the second operand
  21906. * @returns the currentupdated quaternion
  21907. */
  21908. multiplyInPlace(q1: Quaternion): Quaternion;
  21909. /**
  21910. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  21911. * @param ref defines the target quaternion
  21912. * @returns the current quaternion
  21913. */
  21914. conjugateToRef(ref: Quaternion): Quaternion;
  21915. /**
  21916. * Conjugates in place (1-q) the current quaternion
  21917. * @returns the current updated quaternion
  21918. */
  21919. conjugateInPlace(): Quaternion;
  21920. /**
  21921. * Conjugates in place (1-q) the current quaternion
  21922. * @returns a new quaternion
  21923. */
  21924. conjugate(): Quaternion;
  21925. /**
  21926. * Gets length of current quaternion
  21927. * @returns the quaternion length (float)
  21928. */
  21929. length(): number;
  21930. /**
  21931. * Normalize in place the current quaternion
  21932. * @returns the current updated quaternion
  21933. */
  21934. normalize(): Quaternion;
  21935. /**
  21936. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  21937. * @param order is a reserved parameter and is ignore for now
  21938. * @returns a new Vector3 containing the Euler angles
  21939. */
  21940. toEulerAngles(order?: string): Vector3;
  21941. /**
  21942. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  21943. * @param result defines the vector which will be filled with the Euler angles
  21944. * @param order is a reserved parameter and is ignore for now
  21945. * @returns the current unchanged quaternion
  21946. */
  21947. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  21948. /**
  21949. * Updates the given rotation matrix with the current quaternion values
  21950. * @param result defines the target matrix
  21951. * @returns the current unchanged quaternion
  21952. */
  21953. toRotationMatrix(result: Matrix): Quaternion;
  21954. /**
  21955. * Updates the current quaternion from the given rotation matrix values
  21956. * @param matrix defines the source matrix
  21957. * @returns the current updated quaternion
  21958. */
  21959. fromRotationMatrix(matrix: Matrix): Quaternion;
  21960. /**
  21961. * Creates a new quaternion from a rotation matrix
  21962. * @param matrix defines the source matrix
  21963. * @returns a new quaternion created from the given rotation matrix values
  21964. */
  21965. static FromRotationMatrix(matrix: Matrix): Quaternion;
  21966. /**
  21967. * Updates the given quaternion with the given rotation matrix values
  21968. * @param matrix defines the source matrix
  21969. * @param result defines the target quaternion
  21970. */
  21971. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  21972. /**
  21973. * Returns the dot product (float) between the quaternions "left" and "right"
  21974. * @param left defines the left operand
  21975. * @param right defines the right operand
  21976. * @returns the dot product
  21977. */
  21978. static Dot(left: Quaternion, right: Quaternion): number;
  21979. /**
  21980. * Checks if the two quaternions are close to each other
  21981. * @param quat0 defines the first quaternion to check
  21982. * @param quat1 defines the second quaternion to check
  21983. * @returns true if the two quaternions are close to each other
  21984. */
  21985. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  21986. /**
  21987. * Creates an empty quaternion
  21988. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  21989. */
  21990. static Zero(): Quaternion;
  21991. /**
  21992. * Inverse a given quaternion
  21993. * @param q defines the source quaternion
  21994. * @returns a new quaternion as the inverted current quaternion
  21995. */
  21996. static Inverse(q: Quaternion): Quaternion;
  21997. /**
  21998. * Creates an identity quaternion
  21999. * @returns the identity quaternion
  22000. */
  22001. static Identity(): Quaternion;
  22002. /**
  22003. * Gets a boolean indicating if the given quaternion is identity
  22004. * @param quaternion defines the quaternion to check
  22005. * @returns true if the quaternion is identity
  22006. */
  22007. static IsIdentity(quaternion: Quaternion): boolean;
  22008. /**
  22009. * Creates a quaternion from a rotation around an axis
  22010. * @param axis defines the axis to use
  22011. * @param angle defines the angle to use
  22012. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22013. */
  22014. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  22015. /**
  22016. * Creates a rotation around an axis and stores it into the given quaternion
  22017. * @param axis defines the axis to use
  22018. * @param angle defines the angle to use
  22019. * @param result defines the target quaternion
  22020. * @returns the target quaternion
  22021. */
  22022. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  22023. /**
  22024. * Creates a new quaternion from data stored into an array
  22025. * @param array defines the data source
  22026. * @param offset defines the offset in the source array where the data starts
  22027. * @returns a new quaternion
  22028. */
  22029. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  22030. /**
  22031. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22032. * @param yaw defines the rotation around Y axis
  22033. * @param pitch defines the rotation around X axis
  22034. * @param roll defines the rotation around Z axis
  22035. * @returns the new quaternion
  22036. */
  22037. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22038. /**
  22039. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22040. * @param yaw defines the rotation around Y axis
  22041. * @param pitch defines the rotation around X axis
  22042. * @param roll defines the rotation around Z axis
  22043. * @param result defines the target quaternion
  22044. */
  22045. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22046. /**
  22047. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22048. * @param alpha defines the rotation around first axis
  22049. * @param beta defines the rotation around second axis
  22050. * @param gamma defines the rotation around third axis
  22051. * @returns the new quaternion
  22052. */
  22053. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22054. /**
  22055. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22056. * @param alpha defines the rotation around first axis
  22057. * @param beta defines the rotation around second axis
  22058. * @param gamma defines the rotation around third axis
  22059. * @param result defines the target quaternion
  22060. */
  22061. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22062. /**
  22063. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  22064. * @param axis1 defines the first axis
  22065. * @param axis2 defines the second axis
  22066. * @param axis3 defines the third axis
  22067. * @returns the new quaternion
  22068. */
  22069. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  22070. /**
  22071. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  22072. * @param axis1 defines the first axis
  22073. * @param axis2 defines the second axis
  22074. * @param axis3 defines the third axis
  22075. * @param ref defines the target quaternion
  22076. */
  22077. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  22078. /**
  22079. * Interpolates between two quaternions
  22080. * @param left defines first quaternion
  22081. * @param right defines second quaternion
  22082. * @param amount defines the gradient to use
  22083. * @returns the new interpolated quaternion
  22084. */
  22085. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  22086. /**
  22087. * Interpolates between two quaternions and stores it into a target quaternion
  22088. * @param left defines first quaternion
  22089. * @param right defines second quaternion
  22090. * @param amount defines the gradient to use
  22091. * @param result defines the target quaternion
  22092. */
  22093. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  22094. /**
  22095. * Interpolate between two quaternions using Hermite interpolation
  22096. * @param value1 defines first quaternion
  22097. * @param tangent1 defines the incoming tangent
  22098. * @param value2 defines second quaternion
  22099. * @param tangent2 defines the outgoing tangent
  22100. * @param amount defines the target quaternion
  22101. * @returns the new interpolated quaternion
  22102. */
  22103. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  22104. }
  22105. /**
  22106. * Class used to store matrix data (4x4)
  22107. */
  22108. class Matrix {
  22109. private static _tempQuaternion;
  22110. private static _xAxis;
  22111. private static _yAxis;
  22112. private static _zAxis;
  22113. private static _updateFlagSeed;
  22114. private static _identityReadOnly;
  22115. private _isIdentity;
  22116. private _isIdentityDirty;
  22117. /**
  22118. * Gets the update flag of the matrix which is an unique number for the matrix.
  22119. * It will be incremented every time the matrix data change.
  22120. * You can use it to speed the comparison between two versions of the same matrix.
  22121. */
  22122. updateFlag: number;
  22123. /**
  22124. * Gets or sets the internal data of the matrix
  22125. */
  22126. m: Float32Array;
  22127. /** @hidden */
  22128. _markAsUpdated(): void;
  22129. /**
  22130. * Creates an empty matrix (filled with zeros)
  22131. */
  22132. constructor();
  22133. /**
  22134. * Check if the current matrix is indentity
  22135. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  22136. * @returns true is the matrix is the identity matrix
  22137. */
  22138. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  22139. /**
  22140. * Gets the determinant of the matrix
  22141. * @returns the matrix determinant
  22142. */
  22143. determinant(): number;
  22144. /**
  22145. * Returns the matrix as a Float32Array
  22146. * @returns the matrix underlying array
  22147. */
  22148. toArray(): Float32Array;
  22149. /**
  22150. * Returns the matrix as a Float32Array
  22151. * @returns the matrix underlying array.
  22152. */
  22153. asArray(): Float32Array;
  22154. /**
  22155. * Inverts the current matrix in place
  22156. * @returns the current inverted matrix
  22157. */
  22158. invert(): Matrix;
  22159. /**
  22160. * Sets all the matrix elements to zero
  22161. * @returns the current matrix
  22162. */
  22163. reset(): Matrix;
  22164. /**
  22165. * Adds the current matrix with a second one
  22166. * @param other defines the matrix to add
  22167. * @returns a new matrix as the addition of the current matrix and the given one
  22168. */
  22169. add(other: Matrix): Matrix;
  22170. /**
  22171. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22172. * @param other defines the matrix to add
  22173. * @param result defines the target matrix
  22174. * @returns the current matrix
  22175. */
  22176. addToRef(other: Matrix, result: Matrix): Matrix;
  22177. /**
  22178. * Adds in place the given matrix to the current matrix
  22179. * @param other defines the second operand
  22180. * @returns the current updated matrix
  22181. */
  22182. addToSelf(other: Matrix): Matrix;
  22183. /**
  22184. * Sets the given matrix to the current inverted Matrix
  22185. * @param other defines the target matrix
  22186. * @returns the unmodified current matrix
  22187. */
  22188. invertToRef(other: Matrix): Matrix;
  22189. /**
  22190. * Inserts the translation vector (using 3 floats) in the current matrix
  22191. * @param x defines the 1st component of the translation
  22192. * @param y defines the 2nd component of the translation
  22193. * @param z defines the 3rd component of the translation
  22194. * @returns the current updated matrix
  22195. */
  22196. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22197. /**
  22198. * Inserts the translation vector in the current matrix
  22199. * @param vector3 defines the translation to insert
  22200. * @returns the current updated matrix
  22201. */
  22202. setTranslation(vector3: Vector3): Matrix;
  22203. /**
  22204. * Gets the translation value of the current matrix
  22205. * @returns a new Vector3 as the extracted translation from the matrix
  22206. */
  22207. getTranslation(): Vector3;
  22208. /**
  22209. * Fill a Vector3 with the extracted translation from the matrix
  22210. * @param result defines the Vector3 where to store the translation
  22211. * @returns the current matrix
  22212. */
  22213. getTranslationToRef(result: Vector3): Matrix;
  22214. /**
  22215. * Remove rotation and scaling part from the matrix
  22216. * @returns the updated matrix
  22217. */
  22218. removeRotationAndScaling(): Matrix;
  22219. /**
  22220. * Multiply two matrices
  22221. * @param other defines the second operand
  22222. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22223. */
  22224. multiply(other: Matrix): Matrix;
  22225. /**
  22226. * Copy the current matrix from the given one
  22227. * @param other defines the source matrix
  22228. * @returns the current updated matrix
  22229. */
  22230. copyFrom(other: Matrix): Matrix;
  22231. /**
  22232. * Populates the given array from the starting index with the current matrix values
  22233. * @param array defines the target array
  22234. * @param offset defines the offset in the target array where to start storing values
  22235. * @returns the current matrix
  22236. */
  22237. copyToArray(array: Float32Array, offset?: number): Matrix;
  22238. /**
  22239. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22240. * @param other defines the second operand
  22241. * @param result defines the matrix where to store the multiplication
  22242. * @returns the current matrix
  22243. */
  22244. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  22245. /**
  22246. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22247. * @param other defines the second operand
  22248. * @param result defines the array where to store the multiplication
  22249. * @param offset defines the offset in the target array where to start storing values
  22250. * @returns the current matrix
  22251. */
  22252. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  22253. /**
  22254. * Check equality between this matrix and a second one
  22255. * @param value defines the second matrix to compare
  22256. * @returns true is the current matrix and the given one values are strictly equal
  22257. */
  22258. equals(value: Matrix): boolean;
  22259. /**
  22260. * Clone the current matrix
  22261. * @returns a new matrix from the current matrix
  22262. */
  22263. clone(): Matrix;
  22264. /**
  22265. * Returns the name of the current matrix class
  22266. * @returns the string "Matrix"
  22267. */
  22268. getClassName(): string;
  22269. /**
  22270. * Gets the hash code of the current matrix
  22271. * @returns the hash code
  22272. */
  22273. getHashCode(): number;
  22274. /**
  22275. * Decomposes the current Matrix into a translation, rotation and scaling components
  22276. * @param scale defines the scale vector3 given as a reference to update
  22277. * @param rotation defines the rotation quaternion given as a reference to update
  22278. * @param translation defines the translation vector3 given as a reference to update
  22279. * @returns true if operation was successful
  22280. */
  22281. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22282. /**
  22283. * Gets specific row of the matrix
  22284. * @param index defines the number of the row to get
  22285. * @returns the index-th row of the current matrix as a new Vector4
  22286. */
  22287. getRow(index: number): Nullable<Vector4>;
  22288. /**
  22289. * Sets the index-th row of the current matrix to the vector4 values
  22290. * @param index defines the number of the row to set
  22291. * @param row defines the target vector4
  22292. * @returns the updated current matrix
  22293. */
  22294. setRow(index: number, row: Vector4): Matrix;
  22295. /**
  22296. * Compute the transpose of the matrix
  22297. * @returns the new transposed matrix
  22298. */
  22299. transpose(): Matrix;
  22300. /**
  22301. * Compute the transpose of the matrix and store it in a given matrix
  22302. * @param result defines the target matrix
  22303. * @returns the current matrix
  22304. */
  22305. transposeToRef(result: Matrix): Matrix;
  22306. /**
  22307. * Sets the index-th row of the current matrix with the given 4 x float values
  22308. * @param index defines the row index
  22309. * @param x defines the x component to set
  22310. * @param y defines the y component to set
  22311. * @param z defines the z component to set
  22312. * @param w defines the w component to set
  22313. * @returns the updated current matrix
  22314. */
  22315. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22316. /**
  22317. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22318. * @param scale defines the scale factor
  22319. * @returns a new matrix
  22320. */
  22321. scale(scale: number): Matrix;
  22322. /**
  22323. * Scale the current matrix values by a factor to a given result matrix
  22324. * @param scale defines the scale factor
  22325. * @param result defines the matrix to store the result
  22326. * @returns the current matrix
  22327. */
  22328. scaleToRef(scale: number, result: Matrix): Matrix;
  22329. /**
  22330. * Scale the current matrix values by a factor and add the result to a given matrix
  22331. * @param scale defines the scale factor
  22332. * @param result defines the Matrix to store the result
  22333. * @returns the current matrix
  22334. */
  22335. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22336. /**
  22337. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22338. * @param ref matrix to store the result
  22339. */
  22340. toNormalMatrix(ref: Matrix): void;
  22341. /**
  22342. * Gets only rotation part of the current matrix
  22343. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22344. */
  22345. getRotationMatrix(): Matrix;
  22346. /**
  22347. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22348. * @param result defines the target matrix to store data to
  22349. * @returns the current matrix
  22350. */
  22351. getRotationMatrixToRef(result: Matrix): Matrix;
  22352. /**
  22353. * Creates a matrix from an array
  22354. * @param array defines the source array
  22355. * @param offset defines an offset in the source array
  22356. * @returns a new Matrix set from the starting index of the given array
  22357. */
  22358. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  22359. /**
  22360. * Copy the content of an array into a given matrix
  22361. * @param array defines the source array
  22362. * @param offset defines an offset in the source array
  22363. * @param result defines the target matrix
  22364. */
  22365. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  22366. /**
  22367. * Stores an array into a matrix after having multiplied each component by a given factor
  22368. * @param array defines the source array
  22369. * @param offset defines the offset in the source array
  22370. * @param scale defines the scaling factor
  22371. * @param result defines the target matrix
  22372. */
  22373. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  22374. /**
  22375. * Stores a list of values (16) inside a given matrix
  22376. * @param initialM11 defines 1st value of 1st row
  22377. * @param initialM12 defines 2nd value of 1st row
  22378. * @param initialM13 defines 3rd value of 1st row
  22379. * @param initialM14 defines 4th value of 1st row
  22380. * @param initialM21 defines 1st value of 2nd row
  22381. * @param initialM22 defines 2nd value of 2nd row
  22382. * @param initialM23 defines 3rd value of 2nd row
  22383. * @param initialM24 defines 4th value of 2nd row
  22384. * @param initialM31 defines 1st value of 3rd row
  22385. * @param initialM32 defines 2nd value of 3rd row
  22386. * @param initialM33 defines 3rd value of 3rd row
  22387. * @param initialM34 defines 4th value of 3rd row
  22388. * @param initialM41 defines 1st value of 4th row
  22389. * @param initialM42 defines 2nd value of 4th row
  22390. * @param initialM43 defines 3rd value of 4th row
  22391. * @param initialM44 defines 4th value of 4th row
  22392. * @param result defines the target matrix
  22393. */
  22394. 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;
  22395. /**
  22396. * Gets an identity matrix that must not be updated
  22397. */
  22398. static readonly IdentityReadOnly: Matrix;
  22399. /**
  22400. * Creates new matrix from a list of values (16)
  22401. * @param initialM11 defines 1st value of 1st row
  22402. * @param initialM12 defines 2nd value of 1st row
  22403. * @param initialM13 defines 3rd value of 1st row
  22404. * @param initialM14 defines 4th value of 1st row
  22405. * @param initialM21 defines 1st value of 2nd row
  22406. * @param initialM22 defines 2nd value of 2nd row
  22407. * @param initialM23 defines 3rd value of 2nd row
  22408. * @param initialM24 defines 4th value of 2nd row
  22409. * @param initialM31 defines 1st value of 3rd row
  22410. * @param initialM32 defines 2nd value of 3rd row
  22411. * @param initialM33 defines 3rd value of 3rd row
  22412. * @param initialM34 defines 4th value of 3rd row
  22413. * @param initialM41 defines 1st value of 4th row
  22414. * @param initialM42 defines 2nd value of 4th row
  22415. * @param initialM43 defines 3rd value of 4th row
  22416. * @param initialM44 defines 4th value of 4th row
  22417. * @returns the new matrix
  22418. */
  22419. 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;
  22420. /**
  22421. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22422. * @param scale defines the scale vector3
  22423. * @param rotation defines the rotation quaternion
  22424. * @param translation defines the translation vector3
  22425. * @returns a new matrix
  22426. */
  22427. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22428. /**
  22429. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22430. * @param scale defines the scale vector3
  22431. * @param rotation defines the rotation quaternion
  22432. * @param translation defines the translation vector3
  22433. * @param result defines the target matrix
  22434. */
  22435. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22436. /**
  22437. * Creates a new identity matrix
  22438. * @returns a new identity matrix
  22439. */
  22440. static Identity(): Matrix;
  22441. /**
  22442. * Creates a new identity matrix and stores the result in a given matrix
  22443. * @param result defines the target matrix
  22444. */
  22445. static IdentityToRef(result: Matrix): void;
  22446. /**
  22447. * Creates a new zero matrix
  22448. * @returns a new zero matrix
  22449. */
  22450. static Zero(): Matrix;
  22451. /**
  22452. * Creates a new rotation matrix for "angle" radians around the X axis
  22453. * @param angle defines the angle (in radians) to use
  22454. * @return the new matrix
  22455. */
  22456. static RotationX(angle: number): Matrix;
  22457. /**
  22458. * Creates a new matrix as the invert of a given matrix
  22459. * @param source defines the source matrix
  22460. * @returns the new matrix
  22461. */
  22462. static Invert(source: Matrix): Matrix;
  22463. /**
  22464. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22465. * @param angle defines the angle (in radians) to use
  22466. * @param result defines the target matrix
  22467. */
  22468. static RotationXToRef(angle: number, result: Matrix): void;
  22469. /**
  22470. * Creates a new rotation matrix for "angle" radians around the Y axis
  22471. * @param angle defines the angle (in radians) to use
  22472. * @return the new matrix
  22473. */
  22474. static RotationY(angle: number): Matrix;
  22475. /**
  22476. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22477. * @param angle defines the angle (in radians) to use
  22478. * @param result defines the target matrix
  22479. */
  22480. static RotationYToRef(angle: number, result: Matrix): void;
  22481. /**
  22482. * Creates a new rotation matrix for "angle" radians around the Z axis
  22483. * @param angle defines the angle (in radians) to use
  22484. * @return the new matrix
  22485. */
  22486. static RotationZ(angle: number): Matrix;
  22487. /**
  22488. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22489. * @param angle defines the angle (in radians) to use
  22490. * @param result defines the target matrix
  22491. */
  22492. static RotationZToRef(angle: number, result: Matrix): void;
  22493. /**
  22494. * Creates a new rotation matrix for "angle" radians around the given axis
  22495. * @param axis defines the axis to use
  22496. * @param angle defines the angle (in radians) to use
  22497. * @return the new matrix
  22498. */
  22499. static RotationAxis(axis: Vector3, angle: number): Matrix;
  22500. /**
  22501. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22502. * @param axis defines the axis to use
  22503. * @param angle defines the angle (in radians) to use
  22504. * @param result defines the target matrix
  22505. */
  22506. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  22507. /**
  22508. * Creates a rotation matrix
  22509. * @param yaw defines the yaw angle in radians (Y axis)
  22510. * @param pitch defines the pitch angle in radians (X axis)
  22511. * @param roll defines the roll angle in radians (X axis)
  22512. * @returns the new rotation matrix
  22513. */
  22514. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22515. /**
  22516. * Creates a rotation matrix and stores it in a given matrix
  22517. * @param yaw defines the yaw angle in radians (Y axis)
  22518. * @param pitch defines the pitch angle in radians (X axis)
  22519. * @param roll defines the roll angle in radians (X axis)
  22520. * @param result defines the target matrix
  22521. */
  22522. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22523. /**
  22524. * Creates a scaling matrix
  22525. * @param x defines the scale factor on X axis
  22526. * @param y defines the scale factor on Y axis
  22527. * @param z defines the scale factor on Z axis
  22528. * @returns the new matrix
  22529. */
  22530. static Scaling(x: number, y: number, z: number): Matrix;
  22531. /**
  22532. * Creates a scaling matrix and stores it in a given matrix
  22533. * @param x defines the scale factor on X axis
  22534. * @param y defines the scale factor on Y axis
  22535. * @param z defines the scale factor on Z axis
  22536. * @param result defines the target matrix
  22537. */
  22538. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22539. /**
  22540. * Creates a translation matrix
  22541. * @param x defines the translation on X axis
  22542. * @param y defines the translation on Y axis
  22543. * @param z defines the translationon Z axis
  22544. * @returns the new matrix
  22545. */
  22546. static Translation(x: number, y: number, z: number): Matrix;
  22547. /**
  22548. * Creates a translation matrix and stores it in a given matrix
  22549. * @param x defines the translation on X axis
  22550. * @param y defines the translation on Y axis
  22551. * @param z defines the translationon Z axis
  22552. * @param result defines the target matrix
  22553. */
  22554. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22555. /**
  22556. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22557. * @param startValue defines the start value
  22558. * @param endValue defines the end value
  22559. * @param gradient defines the gradient factor
  22560. * @returns the new matrix
  22561. */
  22562. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22563. /**
  22564. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22565. * @param startValue defines the start value
  22566. * @param endValue defines the end value
  22567. * @param gradient defines the gradient factor
  22568. * @param result defines the Matrix object where to store data
  22569. */
  22570. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22571. /**
  22572. * Builds a new matrix whose values are computed by:
  22573. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22574. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22575. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22576. * @param startValue defines the first matrix
  22577. * @param endValue defines the second matrix
  22578. * @param gradient defines the gradient between the two matrices
  22579. * @returns the new matrix
  22580. */
  22581. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22582. /**
  22583. * Update a matrix to values which are computed by:
  22584. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22585. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22586. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22587. * @param startValue defines the first matrix
  22588. * @param endValue defines the second matrix
  22589. * @param gradient defines the gradient between the two matrices
  22590. * @param result defines the target matrix
  22591. */
  22592. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22593. /**
  22594. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  22595. * This function works in left handed mode
  22596. * @param eye defines the final position of the entity
  22597. * @param target defines where the entity should look at
  22598. * @param up defines the up vector for the entity
  22599. * @returns the new matrix
  22600. */
  22601. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22602. /**
  22603. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  22604. * This function works in left handed mode
  22605. * @param eye defines the final position of the entity
  22606. * @param target defines where the entity should look at
  22607. * @param up defines the up vector for the entity
  22608. * @param result defines the target matrix
  22609. */
  22610. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22611. /**
  22612. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  22613. * This function works in right handed mode
  22614. * @param eye defines the final position of the entity
  22615. * @param target defines where the entity should look at
  22616. * @param up defines the up vector for the entity
  22617. * @returns the new matrix
  22618. */
  22619. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22620. /**
  22621. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  22622. * This function works in right handed mode
  22623. * @param eye defines the final position of the entity
  22624. * @param target defines where the entity should look at
  22625. * @param up defines the up vector for the entity
  22626. * @param result defines the target matrix
  22627. */
  22628. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22629. /**
  22630. * Create a left-handed orthographic projection matrix
  22631. * @param width defines the viewport width
  22632. * @param height defines the viewport height
  22633. * @param znear defines the near clip plane
  22634. * @param zfar defines the far clip plane
  22635. * @returns a new matrix as a left-handed orthographic projection matrix
  22636. */
  22637. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22638. /**
  22639. * Store a left-handed orthographic projection to a given matrix
  22640. * @param width defines the viewport width
  22641. * @param height defines the viewport height
  22642. * @param znear defines the near clip plane
  22643. * @param zfar defines the far clip plane
  22644. * @param result defines the target matrix
  22645. */
  22646. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  22647. /**
  22648. * Create a left-handed orthographic projection matrix
  22649. * @param left defines the viewport left coordinate
  22650. * @param right defines the viewport right coordinate
  22651. * @param bottom defines the viewport bottom coordinate
  22652. * @param top defines the viewport top coordinate
  22653. * @param znear defines the near clip plane
  22654. * @param zfar defines the far clip plane
  22655. * @returns a new matrix as a left-handed orthographic projection matrix
  22656. */
  22657. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22658. /**
  22659. * Stores a left-handed orthographic projection into a given matrix
  22660. * @param left defines the viewport left coordinate
  22661. * @param right defines the viewport right coordinate
  22662. * @param bottom defines the viewport bottom coordinate
  22663. * @param top defines the viewport top coordinate
  22664. * @param znear defines the near clip plane
  22665. * @param zfar defines the far clip plane
  22666. * @param result defines the target matrix
  22667. */
  22668. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22669. /**
  22670. * Creates a right-handed orthographic projection matrix
  22671. * @param left defines the viewport left coordinate
  22672. * @param right defines the viewport right coordinate
  22673. * @param bottom defines the viewport bottom coordinate
  22674. * @param top defines the viewport top coordinate
  22675. * @param znear defines the near clip plane
  22676. * @param zfar defines the far clip plane
  22677. * @returns a new matrix as a right-handed orthographic projection matrix
  22678. */
  22679. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22680. /**
  22681. * Stores a right-handed orthographic projection into a given matrix
  22682. * @param left defines the viewport left coordinate
  22683. * @param right defines the viewport right coordinate
  22684. * @param bottom defines the viewport bottom coordinate
  22685. * @param top defines the viewport top coordinate
  22686. * @param znear defines the near clip plane
  22687. * @param zfar defines the far clip plane
  22688. * @param result defines the target matrix
  22689. */
  22690. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22691. /**
  22692. * Creates a left-handed perspective projection matrix
  22693. * @param width defines the viewport width
  22694. * @param height defines the viewport height
  22695. * @param znear defines the near clip plane
  22696. * @param zfar defines the far clip plane
  22697. * @returns a new matrix as a left-handed perspective projection matrix
  22698. */
  22699. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22700. /**
  22701. * Creates a left-handed perspective projection matrix
  22702. * @param fov defines the horizontal field of view
  22703. * @param aspect defines the aspect ratio
  22704. * @param znear defines the near clip plane
  22705. * @param zfar defines the far clip plane
  22706. * @returns a new matrix as a left-handed perspective projection matrix
  22707. */
  22708. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22709. /**
  22710. * Stores a left-handed perspective projection into a given matrix
  22711. * @param fov defines the horizontal field of view
  22712. * @param aspect defines the aspect ratio
  22713. * @param znear defines the near clip plane
  22714. * @param zfar defines the far clip plane
  22715. * @param result defines the target matrix
  22716. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22717. */
  22718. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  22719. /**
  22720. * Creates a right-handed perspective projection matrix
  22721. * @param fov defines the horizontal field of view
  22722. * @param aspect defines the aspect ratio
  22723. * @param znear defines the near clip plane
  22724. * @param zfar defines the far clip plane
  22725. * @returns a new matrix as a right-handed perspective projection matrix
  22726. */
  22727. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22728. /**
  22729. * Stores a right-handed perspective projection into a given matrix
  22730. * @param fov defines the horizontal field of view
  22731. * @param aspect defines the aspect ratio
  22732. * @param znear defines the near clip plane
  22733. * @param zfar defines the far clip plane
  22734. * @param result defines the target matrix
  22735. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22736. */
  22737. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  22738. /**
  22739. * Stores a perspective projection for WebVR info a given matrix
  22740. * @param fov defines the field of view
  22741. * @param znear defines the near clip plane
  22742. * @param zfar defines the far clip plane
  22743. * @param result defines the target matrix
  22744. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  22745. */
  22746. static PerspectiveFovWebVRToRef(fov: {
  22747. upDegrees: number;
  22748. downDegrees: number;
  22749. leftDegrees: number;
  22750. rightDegrees: number;
  22751. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  22752. /**
  22753. * Computes a complete transformation matrix
  22754. * @param viewport defines the viewport to use
  22755. * @param world defines the world matrix
  22756. * @param view defines the view matrix
  22757. * @param projection defines the projection matrix
  22758. * @param zmin defines the near clip plane
  22759. * @param zmax defines the far clip plane
  22760. * @returns the transformation matrix
  22761. */
  22762. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  22763. /**
  22764. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  22765. * @param matrix defines the matrix to use
  22766. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  22767. */
  22768. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  22769. /**
  22770. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  22771. * @param matrix defines the matrix to use
  22772. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  22773. */
  22774. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  22775. /**
  22776. * Compute the transpose of a given matrix
  22777. * @param matrix defines the matrix to transpose
  22778. * @returns the new matrix
  22779. */
  22780. static Transpose(matrix: Matrix): Matrix;
  22781. /**
  22782. * Compute the transpose of a matrix and store it in a target matrix
  22783. * @param matrix defines the matrix to transpose
  22784. * @param result defines the target matrix
  22785. */
  22786. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  22787. /**
  22788. * Computes a reflection matrix from a plane
  22789. * @param plane defines the reflection plane
  22790. * @returns a new matrix
  22791. */
  22792. static Reflection(plane: Plane): Matrix;
  22793. /**
  22794. * Computes a reflection matrix from a plane
  22795. * @param plane defines the reflection plane
  22796. * @param result defines the target matrix
  22797. */
  22798. static ReflectionToRef(plane: Plane, result: Matrix): void;
  22799. /**
  22800. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  22801. * @param xaxis defines the value of the 1st axis
  22802. * @param yaxis defines the value of the 2nd axis
  22803. * @param zaxis defines the value of the 3rd axis
  22804. * @param result defines the target matrix
  22805. */
  22806. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  22807. /**
  22808. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  22809. * @param quat defines the quaternion to use
  22810. * @param result defines the target matrix
  22811. */
  22812. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  22813. }
  22814. /**
  22815. * Represens a plane by the equation ax + by + cz + d = 0
  22816. */
  22817. class Plane {
  22818. /**
  22819. * Normal of the plane (a,b,c)
  22820. */
  22821. normal: Vector3;
  22822. /**
  22823. * d component of the plane
  22824. */
  22825. d: number;
  22826. /**
  22827. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  22828. * @param a a component of the plane
  22829. * @param b b component of the plane
  22830. * @param c c component of the plane
  22831. * @param d d component of the plane
  22832. */
  22833. constructor(a: number, b: number, c: number, d: number);
  22834. /**
  22835. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  22836. */
  22837. asArray(): number[];
  22838. /**
  22839. * @returns a new plane copied from the current Plane.
  22840. */
  22841. clone(): Plane;
  22842. /**
  22843. * @returns the string "Plane".
  22844. */
  22845. getClassName(): string;
  22846. /**
  22847. * @returns the Plane hash code.
  22848. */
  22849. getHashCode(): number;
  22850. /**
  22851. * Normalize the current Plane in place.
  22852. * @returns the updated Plane.
  22853. */
  22854. normalize(): Plane;
  22855. /**
  22856. * Applies a transformation the plane and returns the result
  22857. * @param transformation the transformation matrix to be applied to the plane
  22858. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  22859. */
  22860. transform(transformation: Matrix): Plane;
  22861. /**
  22862. * Calcualtte the dot product between the point and the plane normal
  22863. * @param point point to calculate the dot product with
  22864. * @returns the dot product (float) of the point coordinates and the plane normal.
  22865. */
  22866. dotCoordinate(point: Vector3): number;
  22867. /**
  22868. * Updates the current Plane from the plane defined by the three given points.
  22869. * @param point1 one of the points used to contruct the plane
  22870. * @param point2 one of the points used to contruct the plane
  22871. * @param point3 one of the points used to contruct the plane
  22872. * @returns the updated Plane.
  22873. */
  22874. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  22875. /**
  22876. * Checks if the plane is facing a given direction
  22877. * @param direction the direction to check if the plane is facing
  22878. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  22879. * @returns True is the vector "direction" is the same side than the plane normal.
  22880. */
  22881. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  22882. /**
  22883. * Calculates the distance to a point
  22884. * @param point point to calculate distance to
  22885. * @returns the signed distance (float) from the given point to the Plane.
  22886. */
  22887. signedDistanceTo(point: Vector3): number;
  22888. /**
  22889. * Creates a plane from an array
  22890. * @param array the array to create a plane from
  22891. * @returns a new Plane from the given array.
  22892. */
  22893. static FromArray(array: ArrayLike<number>): Plane;
  22894. /**
  22895. * Creates a plane from three points
  22896. * @param point1 point used to create the plane
  22897. * @param point2 point used to create the plane
  22898. * @param point3 point used to create the plane
  22899. * @returns a new Plane defined by the three given points.
  22900. */
  22901. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  22902. /**
  22903. * Creates a plane from an origin point and a normal
  22904. * @param origin origin of the plane to be constructed
  22905. * @param normal normal of the plane to be constructed
  22906. * @returns a new Plane the normal vector to this plane at the given origin point.
  22907. * Note : the vector "normal" is updated because normalized.
  22908. */
  22909. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  22910. /**
  22911. * Calculates the distance from a plane and a point
  22912. * @param origin origin of the plane to be constructed
  22913. * @param normal normal of the plane to be constructed
  22914. * @param point point to calculate distance to
  22915. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  22916. */
  22917. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  22918. }
  22919. /**
  22920. * Class used to represent a viewport on screen
  22921. */
  22922. class Viewport {
  22923. /** viewport left coordinate */
  22924. x: number;
  22925. /** viewport top coordinate */
  22926. y: number;
  22927. /**viewport width */
  22928. width: number;
  22929. /** viewport height */
  22930. height: number;
  22931. /**
  22932. * Creates a Viewport object located at (x, y) and sized (width, height)
  22933. * @param x defines viewport left coordinate
  22934. * @param y defines viewport top coordinate
  22935. * @param width defines the viewport width
  22936. * @param height defines the viewport height
  22937. */
  22938. constructor(
  22939. /** viewport left coordinate */
  22940. x: number,
  22941. /** viewport top coordinate */
  22942. y: number,
  22943. /**viewport width */
  22944. width: number,
  22945. /** viewport height */
  22946. height: number);
  22947. /**
  22948. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  22949. * @param renderWidthOrEngine defines either an engine or the rendering width
  22950. * @param renderHeight defines the rendering height
  22951. * @returns a new Viewport
  22952. */
  22953. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  22954. /**
  22955. * Returns a new Viewport copied from the current one
  22956. * @returns a new Viewport
  22957. */
  22958. clone(): Viewport;
  22959. }
  22960. /**
  22961. * Reprasents a camera frustum
  22962. */
  22963. class Frustum {
  22964. /**
  22965. * Gets the planes representing the frustum
  22966. * @param transform matrix to be applied to the returned planes
  22967. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  22968. */
  22969. static GetPlanes(transform: Matrix): Plane[];
  22970. /**
  22971. * Gets the near frustum plane transformed by the transform matrix
  22972. * @param transform transformation matrix to be applied to the resulting frustum plane
  22973. * @param frustumPlane the resuling frustum plane
  22974. */
  22975. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22976. /**
  22977. * Gets the far frustum plane transformed by the transform matrix
  22978. * @param transform transformation matrix to be applied to the resulting frustum plane
  22979. * @param frustumPlane the resuling frustum plane
  22980. */
  22981. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22982. /**
  22983. * Gets the left frustum plane transformed by the transform matrix
  22984. * @param transform transformation matrix to be applied to the resulting frustum plane
  22985. * @param frustumPlane the resuling frustum plane
  22986. */
  22987. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22988. /**
  22989. * Gets the right frustum plane transformed by the transform matrix
  22990. * @param transform transformation matrix to be applied to the resulting frustum plane
  22991. * @param frustumPlane the resuling frustum plane
  22992. */
  22993. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22994. /**
  22995. * Gets the top frustum plane transformed by the transform matrix
  22996. * @param transform transformation matrix to be applied to the resulting frustum plane
  22997. * @param frustumPlane the resuling frustum plane
  22998. */
  22999. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23000. /**
  23001. * Gets the bottom frustum plane transformed by the transform matrix
  23002. * @param transform transformation matrix to be applied to the resulting frustum plane
  23003. * @param frustumPlane the resuling frustum plane
  23004. */
  23005. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23006. /**
  23007. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23008. * @param transform transformation matrix to be applied to the resulting frustum planes
  23009. * @param frustumPlanes the resuling frustum planes
  23010. */
  23011. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  23012. }
  23013. /** Defines supported spaces */
  23014. enum Space {
  23015. /** Local (object) space */
  23016. LOCAL = 0,
  23017. /** World space */
  23018. WORLD = 1,
  23019. /** Bone space */
  23020. BONE = 2
  23021. }
  23022. /** Defines the 3 main axes */
  23023. class Axis {
  23024. /** X axis */
  23025. static X: Vector3;
  23026. /** Y axis */
  23027. static Y: Vector3;
  23028. /** Z axis */
  23029. static Z: Vector3;
  23030. }
  23031. /** Class used to represent a Bezier curve */
  23032. class BezierCurve {
  23033. /**
  23034. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23035. * @param t defines the time
  23036. * @param x1 defines the left coordinate on X axis
  23037. * @param y1 defines the left coordinate on Y axis
  23038. * @param x2 defines the right coordinate on X axis
  23039. * @param y2 defines the right coordinate on Y axis
  23040. * @returns the interpolated value
  23041. */
  23042. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23043. }
  23044. /**
  23045. * Defines potential orientation for back face culling
  23046. */
  23047. enum Orientation {
  23048. /**
  23049. * Clockwise
  23050. */
  23051. CW = 0,
  23052. /** Counter clockwise */
  23053. CCW = 1
  23054. }
  23055. /**
  23056. * Defines angle representation
  23057. */
  23058. class Angle {
  23059. private _radians;
  23060. /**
  23061. * Creates an Angle object of "radians" radians (float).
  23062. */
  23063. constructor(radians: number);
  23064. /**
  23065. * Get value in degrees
  23066. * @returns the Angle value in degrees (float)
  23067. */
  23068. degrees(): number;
  23069. /**
  23070. * Get value in radians
  23071. * @returns the Angle value in radians (float)
  23072. */
  23073. radians(): number;
  23074. /**
  23075. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23076. * @param a defines first vector
  23077. * @param b defines second vector
  23078. * @returns a new Angle
  23079. */
  23080. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  23081. /**
  23082. * Gets a new Angle object from the given float in radians
  23083. * @param radians defines the angle value in radians
  23084. * @returns a new Angle
  23085. */
  23086. static FromRadians(radians: number): Angle;
  23087. /**
  23088. * Gets a new Angle object from the given float in degrees
  23089. * @param degrees defines the angle value in degrees
  23090. * @returns a new Angle
  23091. */
  23092. static FromDegrees(degrees: number): Angle;
  23093. }
  23094. /**
  23095. * This represents an arc in a 2d space.
  23096. */
  23097. class Arc2 {
  23098. /** Defines the start point of the arc */
  23099. startPoint: Vector2;
  23100. /** Defines the mid point of the arc */
  23101. midPoint: Vector2;
  23102. /** Defines the end point of the arc */
  23103. endPoint: Vector2;
  23104. /**
  23105. * Defines the center point of the arc.
  23106. */
  23107. centerPoint: Vector2;
  23108. /**
  23109. * Defines the radius of the arc.
  23110. */
  23111. radius: number;
  23112. /**
  23113. * Defines the angle of the arc (from mid point to end point).
  23114. */
  23115. angle: Angle;
  23116. /**
  23117. * Defines the start angle of the arc (from start point to middle point).
  23118. */
  23119. startAngle: Angle;
  23120. /**
  23121. * Defines the orientation of the arc (clock wise/counter clock wise).
  23122. */
  23123. orientation: Orientation;
  23124. /**
  23125. * Creates an Arc object from the three given points : start, middle and end.
  23126. * @param startPoint Defines the start point of the arc
  23127. * @param midPoint Defines the midlle point of the arc
  23128. * @param endPoint Defines the end point of the arc
  23129. */
  23130. constructor(
  23131. /** Defines the start point of the arc */
  23132. startPoint: Vector2,
  23133. /** Defines the mid point of the arc */
  23134. midPoint: Vector2,
  23135. /** Defines the end point of the arc */
  23136. endPoint: Vector2);
  23137. }
  23138. /**
  23139. * Represents a 2D path made up of multiple 2D points
  23140. */
  23141. class Path2 {
  23142. private _points;
  23143. private _length;
  23144. /**
  23145. * If the path start and end point are the same
  23146. */
  23147. closed: boolean;
  23148. /**
  23149. * Creates a Path2 object from the starting 2D coordinates x and y.
  23150. * @param x the starting points x value
  23151. * @param y the starting points y value
  23152. */
  23153. constructor(x: number, y: number);
  23154. /**
  23155. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23156. * @param x the added points x value
  23157. * @param y the added points y value
  23158. * @returns the updated Path2.
  23159. */
  23160. addLineTo(x: number, y: number): Path2;
  23161. /**
  23162. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  23163. * @param midX middle point x value
  23164. * @param midY middle point y value
  23165. * @param endX end point x value
  23166. * @param endY end point y value
  23167. * @param numberOfSegments (default: 36)
  23168. * @returns the updated Path2.
  23169. */
  23170. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23171. /**
  23172. * Closes the Path2.
  23173. * @returns the Path2.
  23174. */
  23175. close(): Path2;
  23176. /**
  23177. * Gets the sum of the distance between each sequential point in the path
  23178. * @returns the Path2 total length (float).
  23179. */
  23180. length(): number;
  23181. /**
  23182. * Gets the points which construct the path
  23183. * @returns the Path2 internal array of points.
  23184. */
  23185. getPoints(): Vector2[];
  23186. /**
  23187. * Retreives the point at the distance aways from the starting point
  23188. * @param normalizedLengthPosition the length along the path to retreive the point from
  23189. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23190. */
  23191. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23192. /**
  23193. * Creates a new path starting from an x and y position
  23194. * @param x starting x value
  23195. * @param y starting y value
  23196. * @returns a new Path2 starting at the coordinates (x, y).
  23197. */
  23198. static StartingAt(x: number, y: number): Path2;
  23199. }
  23200. /**
  23201. * Represents a 3D path made up of multiple 3D points
  23202. */
  23203. class Path3D {
  23204. /**
  23205. * an array of Vector3, the curve axis of the Path3D
  23206. */
  23207. path: Vector3[];
  23208. private _curve;
  23209. private _distances;
  23210. private _tangents;
  23211. private _normals;
  23212. private _binormals;
  23213. private _raw;
  23214. /**
  23215. * new Path3D(path, normal, raw)
  23216. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23217. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23218. * @param path an array of Vector3, the curve axis of the Path3D
  23219. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23220. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23221. */
  23222. constructor(
  23223. /**
  23224. * an array of Vector3, the curve axis of the Path3D
  23225. */
  23226. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23227. /**
  23228. * Returns the Path3D array of successive Vector3 designing its curve.
  23229. * @returns the Path3D array of successive Vector3 designing its curve.
  23230. */
  23231. getCurve(): Vector3[];
  23232. /**
  23233. * Returns an array populated with tangent vectors on each Path3D curve point.
  23234. * @returns an array populated with tangent vectors on each Path3D curve point.
  23235. */
  23236. getTangents(): Vector3[];
  23237. /**
  23238. * Returns an array populated with normal vectors on each Path3D curve point.
  23239. * @returns an array populated with normal vectors on each Path3D curve point.
  23240. */
  23241. getNormals(): Vector3[];
  23242. /**
  23243. * Returns an array populated with binormal vectors on each Path3D curve point.
  23244. * @returns an array populated with binormal vectors on each Path3D curve point.
  23245. */
  23246. getBinormals(): Vector3[];
  23247. /**
  23248. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23249. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23250. */
  23251. getDistances(): number[];
  23252. /**
  23253. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23254. * @param path path which all values are copied into the curves points
  23255. * @param firstNormal which should be projected onto the curve
  23256. * @returns the same object updated.
  23257. */
  23258. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23259. private _compute;
  23260. private _getFirstNonNullVector;
  23261. private _getLastNonNullVector;
  23262. private _normalVector;
  23263. }
  23264. /**
  23265. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23266. * A Curve3 is designed from a series of successive Vector3.
  23267. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23268. */
  23269. class Curve3 {
  23270. private _points;
  23271. private _length;
  23272. /**
  23273. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23274. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23275. * @param v1 (Vector3) the control point
  23276. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23277. * @param nbPoints (integer) the wanted number of points in the curve
  23278. * @returns the created Curve3
  23279. */
  23280. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  23281. /**
  23282. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23283. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23284. * @param v1 (Vector3) the first control point
  23285. * @param v2 (Vector3) the second control point
  23286. * @param v3 (Vector3) the end point of the Cubic Bezier
  23287. * @param nbPoints (integer) the wanted number of points in the curve
  23288. * @returns the created Curve3
  23289. */
  23290. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  23291. /**
  23292. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23293. * @param p1 (Vector3) the origin point of the Hermite Spline
  23294. * @param t1 (Vector3) the tangent vector at the origin point
  23295. * @param p2 (Vector3) the end point of the Hermite Spline
  23296. * @param t2 (Vector3) the tangent vector at the end point
  23297. * @param nbPoints (integer) the wanted number of points in the curve
  23298. * @returns the created Curve3
  23299. */
  23300. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  23301. /**
  23302. * Returns a Curve3 object along a CatmullRom Spline curve :
  23303. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23304. * @param nbPoints (integer) the wanted number of points between each curve control points
  23305. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23306. * @returns the created Curve3
  23307. */
  23308. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  23309. /**
  23310. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23311. * A Curve3 is designed from a series of successive Vector3.
  23312. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23313. * @param points points which make up the curve
  23314. */
  23315. constructor(points: Vector3[]);
  23316. /**
  23317. * @returns the Curve3 stored array of successive Vector3
  23318. */
  23319. getPoints(): Vector3[];
  23320. /**
  23321. * @returns the computed length (float) of the curve.
  23322. */
  23323. length(): number;
  23324. /**
  23325. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23326. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23327. * curveA and curveB keep unchanged.
  23328. * @param curve the curve to continue from this curve
  23329. * @returns the newly constructed curve
  23330. */
  23331. continue(curve: Curve3): Curve3;
  23332. private _computeLength;
  23333. }
  23334. /**
  23335. * Contains position and normal vectors for a vertex
  23336. */
  23337. class PositionNormalVertex {
  23338. /** the position of the vertex (defaut: 0,0,0) */
  23339. position: Vector3;
  23340. /** the normal of the vertex (defaut: 0,1,0) */
  23341. normal: Vector3;
  23342. /**
  23343. * Creates a PositionNormalVertex
  23344. * @param position the position of the vertex (defaut: 0,0,0)
  23345. * @param normal the normal of the vertex (defaut: 0,1,0)
  23346. */
  23347. constructor(
  23348. /** the position of the vertex (defaut: 0,0,0) */
  23349. position?: Vector3,
  23350. /** the normal of the vertex (defaut: 0,1,0) */
  23351. normal?: Vector3);
  23352. /**
  23353. * Clones the PositionNormalVertex
  23354. * @returns the cloned PositionNormalVertex
  23355. */
  23356. clone(): PositionNormalVertex;
  23357. }
  23358. /**
  23359. * Contains position, normal and uv vectors for a vertex
  23360. */
  23361. class PositionNormalTextureVertex {
  23362. /** the position of the vertex (defaut: 0,0,0) */
  23363. position: Vector3;
  23364. /** the normal of the vertex (defaut: 0,1,0) */
  23365. normal: Vector3;
  23366. /** the uv of the vertex (default: 0,0) */
  23367. uv: Vector2;
  23368. /**
  23369. * Creates a PositionNormalTextureVertex
  23370. * @param position the position of the vertex (defaut: 0,0,0)
  23371. * @param normal the normal of the vertex (defaut: 0,1,0)
  23372. * @param uv the uv of the vertex (default: 0,0)
  23373. */
  23374. constructor(
  23375. /** the position of the vertex (defaut: 0,0,0) */
  23376. position?: Vector3,
  23377. /** the normal of the vertex (defaut: 0,1,0) */
  23378. normal?: Vector3,
  23379. /** the uv of the vertex (default: 0,0) */
  23380. uv?: Vector2);
  23381. /**
  23382. * Clones the PositionNormalTextureVertex
  23383. * @returns the cloned PositionNormalTextureVertex
  23384. */
  23385. clone(): PositionNormalTextureVertex;
  23386. }
  23387. /**
  23388. * @hidden
  23389. */
  23390. class Tmp {
  23391. static Color3: Color3[];
  23392. static Color4: Color4[];
  23393. static Vector2: Vector2[];
  23394. static Vector3: Vector3[];
  23395. static Vector4: Vector4[];
  23396. static Quaternion: Quaternion[];
  23397. static Matrix: Matrix[];
  23398. }
  23399. }
  23400. declare module BABYLON {
  23401. /**
  23402. * Class representing spherical polynomial coefficients to the 3rd degree
  23403. */
  23404. class SphericalPolynomial {
  23405. /**
  23406. * The x coefficients of the spherical polynomial
  23407. */
  23408. x: Vector3;
  23409. /**
  23410. * The y coefficients of the spherical polynomial
  23411. */
  23412. y: Vector3;
  23413. /**
  23414. * The z coefficients of the spherical polynomial
  23415. */
  23416. z: Vector3;
  23417. /**
  23418. * The xx coefficients of the spherical polynomial
  23419. */
  23420. xx: Vector3;
  23421. /**
  23422. * The yy coefficients of the spherical polynomial
  23423. */
  23424. yy: Vector3;
  23425. /**
  23426. * The zz coefficients of the spherical polynomial
  23427. */
  23428. zz: Vector3;
  23429. /**
  23430. * The xy coefficients of the spherical polynomial
  23431. */
  23432. xy: Vector3;
  23433. /**
  23434. * The yz coefficients of the spherical polynomial
  23435. */
  23436. yz: Vector3;
  23437. /**
  23438. * The zx coefficients of the spherical polynomial
  23439. */
  23440. zx: Vector3;
  23441. /**
  23442. * Adds an ambient color to the spherical polynomial
  23443. * @param color the color to add
  23444. */
  23445. addAmbient(color: Color3): void;
  23446. /**
  23447. * Scales the spherical polynomial by the given amount
  23448. * @param scale the amount to scale
  23449. */
  23450. scale(scale: number): void;
  23451. /**
  23452. * Gets the spherical polynomial from harmonics
  23453. * @param harmonics the spherical harmonics
  23454. * @returns the spherical polynomial
  23455. */
  23456. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23457. /**
  23458. * Constructs a spherical polynomial from an array.
  23459. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23460. * @returns the spherical polynomial
  23461. */
  23462. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23463. }
  23464. /**
  23465. * Class representing spherical harmonics coefficients to the 3rd degree
  23466. */
  23467. class SphericalHarmonics {
  23468. /**
  23469. * The l0,0 coefficients of the spherical harmonics
  23470. */
  23471. l00: Vector3;
  23472. /**
  23473. * The l1,-1 coefficients of the spherical harmonics
  23474. */
  23475. l1_1: Vector3;
  23476. /**
  23477. * The l1,0 coefficients of the spherical harmonics
  23478. */
  23479. l10: Vector3;
  23480. /**
  23481. * The l1,1 coefficients of the spherical harmonics
  23482. */
  23483. l11: Vector3;
  23484. /**
  23485. * The l2,-2 coefficients of the spherical harmonics
  23486. */
  23487. l2_2: Vector3;
  23488. /**
  23489. * The l2,-1 coefficients of the spherical harmonics
  23490. */
  23491. l2_1: Vector3;
  23492. /**
  23493. * The l2,0 coefficients of the spherical harmonics
  23494. */
  23495. l20: Vector3;
  23496. /**
  23497. * The l2,1 coefficients of the spherical harmonics
  23498. */
  23499. l21: Vector3;
  23500. /**
  23501. * The l2,2 coefficients of the spherical harmonics
  23502. */
  23503. lL22: Vector3;
  23504. /**
  23505. * Adds a light to the spherical harmonics
  23506. * @param direction the direction of the light
  23507. * @param color the color of the light
  23508. * @param deltaSolidAngle the delta solid angle of the light
  23509. */
  23510. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23511. /**
  23512. * Scales the spherical harmonics by the given amount
  23513. * @param scale the amount to scale
  23514. */
  23515. scale(scale: number): void;
  23516. /**
  23517. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23518. *
  23519. * ```
  23520. * E_lm = A_l * L_lm
  23521. * ```
  23522. *
  23523. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23524. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23525. * the scaling factors are given in equation 9.
  23526. */
  23527. convertIncidentRadianceToIrradiance(): void;
  23528. /**
  23529. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23530. *
  23531. * ```
  23532. * L = (1/pi) * E * rho
  23533. * ```
  23534. *
  23535. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23536. */
  23537. convertIrradianceToLambertianRadiance(): void;
  23538. /**
  23539. * Gets the spherical harmonics from polynomial
  23540. * @param polynomial the spherical polynomial
  23541. * @returns the spherical harmonics
  23542. */
  23543. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23544. /**
  23545. * Constructs a spherical harmonics from an array.
  23546. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23547. * @returns the spherical harmonics
  23548. */
  23549. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23550. }
  23551. }
  23552. declare module BABYLON {
  23553. /**
  23554. * Class used to store all common mesh properties
  23555. */
  23556. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23557. /** No occlusion */
  23558. static OCCLUSION_TYPE_NONE: number;
  23559. /** Occlusion set to optimisitic */
  23560. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23561. /** Occlusion set to strict */
  23562. static OCCLUSION_TYPE_STRICT: number;
  23563. /** Use an accurante occlusion algorithm */
  23564. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23565. /** Use a conservative occlusion algorithm */
  23566. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23567. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  23568. static readonly CULLINGSTRATEGY_STANDARD: number;
  23569. /** Culling strategy with bounding sphere only and then frustum culling */
  23570. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23571. /**
  23572. * No billboard
  23573. */
  23574. static readonly BILLBOARDMODE_NONE: number;
  23575. /** Billboard on X axis */
  23576. static readonly BILLBOARDMODE_X: number;
  23577. /** Billboard on Y axis */
  23578. static readonly BILLBOARDMODE_Y: number;
  23579. /** Billboard on Z axis */
  23580. static readonly BILLBOARDMODE_Z: number;
  23581. /** Billboard on all axes */
  23582. static readonly BILLBOARDMODE_ALL: number;
  23583. private _facetData;
  23584. /** Gets ot sets the culling strategy to use to find visible meshes */
  23585. cullingStrategy: number;
  23586. /**
  23587. * Gets the number of facets in the mesh
  23588. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23589. */
  23590. readonly facetNb: number;
  23591. /**
  23592. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23593. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23594. */
  23595. partitioningSubdivisions: number;
  23596. /**
  23597. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23598. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23600. */
  23601. partitioningBBoxRatio: number;
  23602. /**
  23603. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23604. * Works only for updatable meshes.
  23605. * Doesn't work with multi-materials
  23606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23607. */
  23608. mustDepthSortFacets: boolean;
  23609. /**
  23610. * The location (Vector3) where the facet depth sort must be computed from.
  23611. * By default, the active camera position.
  23612. * Used only when facet depth sort is enabled
  23613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23614. */
  23615. facetDepthSortFrom: Vector3;
  23616. /**
  23617. * gets a boolean indicating if facetData is enabled
  23618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23619. */
  23620. readonly isFacetDataEnabled: boolean;
  23621. /** @hidden */
  23622. _updateNonUniformScalingState(value: boolean): boolean;
  23623. /**
  23624. * An event triggered when this mesh collides with another one
  23625. */
  23626. onCollideObservable: Observable<AbstractMesh>;
  23627. private _onCollideObserver;
  23628. /** Set a function to call when this mesh collides with another one */
  23629. onCollide: () => void;
  23630. /**
  23631. * An event triggered when the collision's position changes
  23632. */
  23633. onCollisionPositionChangeObservable: Observable<Vector3>;
  23634. private _onCollisionPositionChangeObserver;
  23635. /** Set a function to call when the collision's position changes */
  23636. onCollisionPositionChange: () => void;
  23637. /**
  23638. * An event triggered when material is changed
  23639. */
  23640. onMaterialChangedObservable: Observable<AbstractMesh>;
  23641. /**
  23642. * Gets or sets the orientation for POV movement & rotation
  23643. */
  23644. definedFacingForward: boolean;
  23645. /** @hidden */
  23646. _occlusionQuery: Nullable<WebGLQuery>;
  23647. private _visibility;
  23648. /**
  23649. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23650. */
  23651. /**
  23652. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23653. */
  23654. visibility: number;
  23655. /** Gets or sets the alpha index used to sort transparent meshes
  23656. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23657. */
  23658. alphaIndex: number;
  23659. /**
  23660. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23661. */
  23662. isVisible: boolean;
  23663. /**
  23664. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23665. */
  23666. isPickable: boolean;
  23667. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23668. showSubMeshesBoundingBox: boolean;
  23669. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23670. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23671. */
  23672. isBlocker: boolean;
  23673. /**
  23674. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23675. */
  23676. enablePointerMoveEvents: boolean;
  23677. /**
  23678. * Specifies the rendering group id for this mesh (0 by default)
  23679. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23680. */
  23681. renderingGroupId: number;
  23682. private _material;
  23683. /** Gets or sets current material */
  23684. material: Nullable<Material>;
  23685. private _receiveShadows;
  23686. /**
  23687. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23688. * @see http://doc.babylonjs.com/babylon101/shadows
  23689. */
  23690. receiveShadows: boolean;
  23691. /** Defines color to use when rendering outline */
  23692. outlineColor: Color3;
  23693. /** Define width to use when rendering outline */
  23694. outlineWidth: number;
  23695. /** Defines color to use when rendering overlay */
  23696. overlayColor: Color3;
  23697. /** Defines alpha to use when rendering overlay */
  23698. overlayAlpha: number;
  23699. private _hasVertexAlpha;
  23700. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23701. hasVertexAlpha: boolean;
  23702. private _useVertexColors;
  23703. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  23704. useVertexColors: boolean;
  23705. private _computeBonesUsingShaders;
  23706. /**
  23707. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23708. */
  23709. computeBonesUsingShaders: boolean;
  23710. private _numBoneInfluencers;
  23711. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23712. numBoneInfluencers: number;
  23713. private _applyFog;
  23714. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23715. applyFog: boolean;
  23716. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23717. useOctreeForRenderingSelection: boolean;
  23718. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23719. useOctreeForPicking: boolean;
  23720. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23721. useOctreeForCollisions: boolean;
  23722. private _layerMask;
  23723. /**
  23724. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23725. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23726. */
  23727. layerMask: number;
  23728. /**
  23729. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23730. */
  23731. alwaysSelectAsActiveMesh: boolean;
  23732. /**
  23733. * Gets or sets the current action manager
  23734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23735. */
  23736. actionManager: Nullable<ActionManager>;
  23737. private _checkCollisions;
  23738. private _collisionMask;
  23739. private _collisionGroup;
  23740. /**
  23741. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23742. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23743. */
  23744. ellipsoid: Vector3;
  23745. /**
  23746. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23747. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23748. */
  23749. ellipsoidOffset: Vector3;
  23750. private _collider;
  23751. private _oldPositionForCollisions;
  23752. private _diffPositionForCollisions;
  23753. /**
  23754. * Gets or sets a collision mask used to mask collisions (default is -1).
  23755. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23756. */
  23757. collisionMask: number;
  23758. /**
  23759. * Gets or sets the current collision group mask (-1 by default).
  23760. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23761. */
  23762. collisionGroup: number;
  23763. /**
  23764. * Defines edge width used when edgesRenderer is enabled
  23765. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23766. */
  23767. edgesWidth: number;
  23768. /**
  23769. * Defines edge color used when edgesRenderer is enabled
  23770. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23771. */
  23772. edgesColor: Color4;
  23773. /** @hidden */
  23774. _edgesRenderer: Nullable<IEdgesRenderer>;
  23775. /** @hidden */
  23776. _masterMesh: Nullable<AbstractMesh>;
  23777. /** @hidden */
  23778. _boundingInfo: Nullable<BoundingInfo>;
  23779. /** @hidden */
  23780. _renderId: number;
  23781. /**
  23782. * Gets or sets the list of subMeshes
  23783. * @see http://doc.babylonjs.com/how_to/multi_materials
  23784. */
  23785. subMeshes: SubMesh[];
  23786. /** @hidden */
  23787. _intersectionsInProgress: AbstractMesh[];
  23788. /** @hidden */
  23789. _unIndexed: boolean;
  23790. /** @hidden */
  23791. _lightSources: Light[];
  23792. /** @hidden */
  23793. readonly _positions: Nullable<Vector3[]>;
  23794. /** @hidden */
  23795. _waitingActions: any;
  23796. /** @hidden */
  23797. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23798. private _skeleton;
  23799. /** @hidden */
  23800. _bonesTransformMatrices: Nullable<Float32Array>;
  23801. /**
  23802. * Gets or sets a skeleton to apply skining transformations
  23803. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23804. */
  23805. skeleton: Nullable<Skeleton>;
  23806. /**
  23807. * An event triggered when the mesh is rebuilt.
  23808. */
  23809. onRebuildObservable: Observable<AbstractMesh>;
  23810. /**
  23811. * Creates a new AbstractMesh
  23812. * @param name defines the name of the mesh
  23813. * @param scene defines the hosting scene
  23814. */
  23815. constructor(name: string, scene?: Nullable<Scene>);
  23816. /**
  23817. * Returns the string "AbstractMesh"
  23818. * @returns "AbstractMesh"
  23819. */
  23820. getClassName(): string;
  23821. /**
  23822. * Gets a string representation of the current mesh
  23823. * @param fullDetails defines a boolean indicating if full details must be included
  23824. * @returns a string representation of the current mesh
  23825. */
  23826. toString(fullDetails?: boolean): string;
  23827. /** @hidden */
  23828. _rebuild(): void;
  23829. /** @hidden */
  23830. _resyncLightSources(): void;
  23831. /** @hidden */
  23832. _resyncLighSource(light: Light): void;
  23833. /** @hidden */
  23834. _unBindEffect(): void;
  23835. /** @hidden */
  23836. _removeLightSource(light: Light): void;
  23837. private _markSubMeshesAsDirty;
  23838. /** @hidden */
  23839. _markSubMeshesAsLightDirty(): void;
  23840. /** @hidden */
  23841. _markSubMeshesAsAttributesDirty(): void;
  23842. /** @hidden */
  23843. _markSubMeshesAsMiscDirty(): void;
  23844. /**
  23845. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23846. */
  23847. scaling: Vector3;
  23848. /**
  23849. * Returns true if the mesh is blocked. Implemented by child classes
  23850. */
  23851. readonly isBlocked: boolean;
  23852. /**
  23853. * Returns the mesh itself by default. Implemented by child classes
  23854. * @param camera defines the camera to use to pick the right LOD level
  23855. * @returns the currentAbstractMesh
  23856. */
  23857. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23858. /**
  23859. * Returns 0 by default. Implemented by child classes
  23860. * @returns an integer
  23861. */
  23862. getTotalVertices(): number;
  23863. /**
  23864. * Returns null by default. Implemented by child classes
  23865. * @returns null
  23866. */
  23867. getIndices(): Nullable<IndicesArray>;
  23868. /**
  23869. * Returns the array of the requested vertex data kind. Implemented by child classes
  23870. * @param kind defines the vertex data kind to use
  23871. * @returns null
  23872. */
  23873. getVerticesData(kind: string): Nullable<FloatArray>;
  23874. /**
  23875. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23876. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23877. * Note that a new underlying VertexBuffer object is created each call.
  23878. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23879. * @param kind defines vertex data kind:
  23880. * * BABYLON.VertexBuffer.PositionKind
  23881. * * BABYLON.VertexBuffer.UVKind
  23882. * * BABYLON.VertexBuffer.UV2Kind
  23883. * * BABYLON.VertexBuffer.UV3Kind
  23884. * * BABYLON.VertexBuffer.UV4Kind
  23885. * * BABYLON.VertexBuffer.UV5Kind
  23886. * * BABYLON.VertexBuffer.UV6Kind
  23887. * * BABYLON.VertexBuffer.ColorKind
  23888. * * BABYLON.VertexBuffer.MatricesIndicesKind
  23889. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23890. * * BABYLON.VertexBuffer.MatricesWeightsKind
  23891. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23892. * @param data defines the data source
  23893. * @param updatable defines if the data must be flagged as updatable (or static)
  23894. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  23895. * @returns the current mesh
  23896. */
  23897. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23898. /**
  23899. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23900. * If the mesh has no geometry, it is simply returned as it is.
  23901. * @param kind defines vertex data kind:
  23902. * * BABYLON.VertexBuffer.PositionKind
  23903. * * BABYLON.VertexBuffer.UVKind
  23904. * * BABYLON.VertexBuffer.UV2Kind
  23905. * * BABYLON.VertexBuffer.UV3Kind
  23906. * * BABYLON.VertexBuffer.UV4Kind
  23907. * * BABYLON.VertexBuffer.UV5Kind
  23908. * * BABYLON.VertexBuffer.UV6Kind
  23909. * * BABYLON.VertexBuffer.ColorKind
  23910. * * BABYLON.VertexBuffer.MatricesIndicesKind
  23911. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23912. * * BABYLON.VertexBuffer.MatricesWeightsKind
  23913. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23914. * @param data defines the data source
  23915. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  23916. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23917. * @returns the current mesh
  23918. */
  23919. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23920. /**
  23921. * Sets the mesh indices,
  23922. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23923. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23924. * @param totalVertices Defines the total number of vertices
  23925. * @returns the current mesh
  23926. */
  23927. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23928. /**
  23929. * Gets a boolean indicating if specific vertex data is present
  23930. * @param kind defines the vertex data kind to use
  23931. * @returns true is data kind is present
  23932. */
  23933. isVerticesDataPresent(kind: string): boolean;
  23934. /**
  23935. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23936. * @returns a BoundingInfo
  23937. */
  23938. getBoundingInfo(): BoundingInfo;
  23939. /**
  23940. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23941. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23942. * @returns the current mesh
  23943. */
  23944. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23945. /**
  23946. * Overwrite the current bounding info
  23947. * @param boundingInfo defines the new bounding info
  23948. * @returns the current mesh
  23949. */
  23950. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23951. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23952. readonly useBones: boolean;
  23953. /** @hidden */
  23954. _preActivate(): void;
  23955. /** @hidden */
  23956. _preActivateForIntermediateRendering(renderId: number): void;
  23957. /** @hidden */
  23958. _activate(renderId: number): void;
  23959. /**
  23960. * Gets the current world matrix
  23961. * @returns a Matrix
  23962. */
  23963. getWorldMatrix(): Matrix;
  23964. /** @hidden */
  23965. _getWorldMatrixDeterminant(): number;
  23966. /**
  23967. * Perform relative position change from the point of view of behind the front of the mesh.
  23968. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23969. * Supports definition of mesh facing forward or backward
  23970. * @param amountRight defines the distance on the right axis
  23971. * @param amountUp defines the distance on the up axis
  23972. * @param amountForward defines the distance on the forward axis
  23973. * @returns the current mesh
  23974. */
  23975. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23976. /**
  23977. * Calculate relative position change from the point of view of behind the front of the mesh.
  23978. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23979. * Supports definition of mesh facing forward or backward
  23980. * @param amountRight defines the distance on the right axis
  23981. * @param amountUp defines the distance on the up axis
  23982. * @param amountForward defines the distance on the forward axis
  23983. * @returns the new displacement vector
  23984. */
  23985. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23986. /**
  23987. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23988. * Supports definition of mesh facing forward or backward
  23989. * @param flipBack defines the flip
  23990. * @param twirlClockwise defines the twirl
  23991. * @param tiltRight defines the tilt
  23992. * @returns the current mesh
  23993. */
  23994. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23995. /**
  23996. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23997. * Supports definition of mesh facing forward or backward.
  23998. * @param flipBack defines the flip
  23999. * @param twirlClockwise defines the twirl
  24000. * @param tiltRight defines the tilt
  24001. * @returns the new rotation vector
  24002. */
  24003. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24004. /**
  24005. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24006. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24007. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  24008. * @returns the new bounding vectors
  24009. */
  24010. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24011. min: Vector3;
  24012. max: Vector3;
  24013. };
  24014. /** @hidden */
  24015. _updateBoundingInfo(): AbstractMesh;
  24016. /** @hidden */
  24017. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24018. /** @hidden */
  24019. protected _afterComputeWorldMatrix(): void;
  24020. /**
  24021. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24022. * A mesh is in the frustum if its bounding box intersects the frustum
  24023. * @param frustumPlanes defines the frustum to test
  24024. * @returns true if the mesh is in the frustum planes
  24025. */
  24026. isInFrustum(frustumPlanes: Plane[]): boolean;
  24027. /**
  24028. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24029. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24030. * @param frustumPlanes defines the frustum to test
  24031. * @returns true if the mesh is completely in the frustum planes
  24032. */
  24033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24034. /**
  24035. * True if the mesh intersects another mesh or a SolidParticle object
  24036. * @param mesh defines a target mesh or SolidParticle to test
  24037. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  24038. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24039. * @returns true if there is an intersection
  24040. */
  24041. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24042. /**
  24043. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24044. * @param point defines the point to test
  24045. * @returns true if there is an intersection
  24046. */
  24047. intersectsPoint(point: Vector3): boolean;
  24048. /**
  24049. * Gets the position of the current mesh in camera space
  24050. * @param camera defines the camera to use
  24051. * @returns a position
  24052. */
  24053. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24054. /**
  24055. * Returns the distance from the mesh to the active camera
  24056. * @param camera defines the camera to use
  24057. * @returns the distance
  24058. */
  24059. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24060. /**
  24061. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24062. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24063. */
  24064. checkCollisions: boolean;
  24065. /**
  24066. * Gets Collider object used to compute collisions (not physics)
  24067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24068. */
  24069. readonly collider: Collider;
  24070. /**
  24071. * Move the mesh using collision engine
  24072. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24073. * @param displacement defines the requested displacement vector
  24074. * @returns the current mesh
  24075. */
  24076. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24077. private _onCollisionPositionChange;
  24078. /** @hidden */
  24079. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24080. /** @hidden */
  24081. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24082. /** @hidden */
  24083. _checkCollision(collider: Collider): AbstractMesh;
  24084. /** @hidden */
  24085. _generatePointsArray(): boolean;
  24086. /**
  24087. * Checks if the passed Ray intersects with the mesh
  24088. * @param ray defines the ray to use
  24089. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24090. * @returns the picking info
  24091. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24092. */
  24093. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24094. /**
  24095. * Clones the current mesh
  24096. * @param name defines the mesh name
  24097. * @param newParent defines the new mesh parent
  24098. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24099. * @returns the new mesh
  24100. */
  24101. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24102. /**
  24103. * Disposes all the submeshes of the current meshnp
  24104. * @returns the current mesh
  24105. */
  24106. releaseSubMeshes(): AbstractMesh;
  24107. /**
  24108. * Releases resources associated with this abstract mesh.
  24109. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24110. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24111. */
  24112. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24113. /**
  24114. * Adds the passed mesh as a child to the current mesh
  24115. * @param mesh defines the child mesh
  24116. * @returns the current mesh
  24117. */
  24118. addChild(mesh: AbstractMesh): AbstractMesh;
  24119. /**
  24120. * Removes the passed mesh from the current mesh children list
  24121. * @param mesh defines the child mesh
  24122. * @returns the current mesh
  24123. */
  24124. removeChild(mesh: AbstractMesh): AbstractMesh;
  24125. /** @hidden */
  24126. private _initFacetData;
  24127. /**
  24128. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24129. * This method can be called within the render loop.
  24130. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  24131. * @returns the current mesh
  24132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24133. */
  24134. updateFacetData(): AbstractMesh;
  24135. /**
  24136. * Returns the facetLocalNormals array.
  24137. * The normals are expressed in the mesh local spac
  24138. * @returns an array of Vector3
  24139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24140. */
  24141. getFacetLocalNormals(): Vector3[];
  24142. /**
  24143. * Returns the facetLocalPositions array.
  24144. * The facet positions are expressed in the mesh local space
  24145. * @returns an array of Vector3
  24146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24147. */
  24148. getFacetLocalPositions(): Vector3[];
  24149. /**
  24150. * Returns the facetLocalPartioning array
  24151. * @returns an array of array of numbers
  24152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24153. */
  24154. getFacetLocalPartitioning(): number[][];
  24155. /**
  24156. * Returns the i-th facet position in the world system.
  24157. * This method allocates a new Vector3 per call
  24158. * @param i defines the facet index
  24159. * @returns a new Vector3
  24160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24161. */
  24162. getFacetPosition(i: number): Vector3;
  24163. /**
  24164. * Sets the reference Vector3 with the i-th facet position in the world system
  24165. * @param i defines the facet index
  24166. * @param ref defines the target vector
  24167. * @returns the current mesh
  24168. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24169. */
  24170. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24171. /**
  24172. * Returns the i-th facet normal in the world system.
  24173. * This method allocates a new Vector3 per call
  24174. * @param i defines the facet index
  24175. * @returns a new Vector3
  24176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24177. */
  24178. getFacetNormal(i: number): Vector3;
  24179. /**
  24180. * Sets the reference Vector3 with the i-th facet normal in the world system
  24181. * @param i defines the facet index
  24182. * @param ref defines the target vector
  24183. * @returns the current mesh
  24184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24185. */
  24186. getFacetNormalToRef(i: number, ref: Vector3): this;
  24187. /**
  24188. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  24189. * @param x defines x coordinate
  24190. * @param y defines y coordinate
  24191. * @param z defines z coordinate
  24192. * @returns the array of facet indexes
  24193. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24194. */
  24195. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24196. /**
  24197. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24198. * @param projected sets as the (x,y,z) world projection on the facet
  24199. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  24200. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  24201. * @param x defines x coordinate
  24202. * @param y defines y coordinate
  24203. * @param z defines z coordinate
  24204. * @returns the face index if found (or null instead)
  24205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24206. */
  24207. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24208. /**
  24209. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24210. * @param projected sets as the (x,y,z) local projection on the facet
  24211. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  24212. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  24213. * @param x defines x coordinate
  24214. * @param y defines y coordinate
  24215. * @param z defines z coordinate
  24216. * @returns the face index if found (or null instead)
  24217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24218. */
  24219. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24220. /**
  24221. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24222. * @returns the parameters
  24223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24224. */
  24225. getFacetDataParameters(): any;
  24226. /**
  24227. * Disables the feature FacetData and frees the related memory
  24228. * @returns the current mesh
  24229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24230. */
  24231. disableFacetData(): AbstractMesh;
  24232. /**
  24233. * Updates the AbstractMesh indices array
  24234. * @param indices defines the data source
  24235. * @returns the current mesh
  24236. */
  24237. updateIndices(indices: IndicesArray): AbstractMesh;
  24238. /**
  24239. * Creates new normals data for the mesh
  24240. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24241. * @returns the current mesh
  24242. */
  24243. createNormals(updatable: boolean): AbstractMesh;
  24244. /**
  24245. * Align the mesh with a normal
  24246. * @param normal defines the normal to use
  24247. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24248. * @returns the current mesh
  24249. */
  24250. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24251. /** @hidden */
  24252. _checkOcclusionQuery(): boolean;
  24253. }
  24254. }
  24255. declare module BABYLON {
  24256. /**
  24257. * Class used to store data that will be store in GPU memory
  24258. */
  24259. class Buffer {
  24260. private _engine;
  24261. private _buffer;
  24262. /** @hidden */
  24263. _data: Nullable<DataArray>;
  24264. private _updatable;
  24265. private _instanced;
  24266. /**
  24267. * Gets the byte stride.
  24268. */
  24269. readonly byteStride: number;
  24270. /**
  24271. * Constructor
  24272. * @param engine the engine
  24273. * @param data the data to use for this buffer
  24274. * @param updatable whether the data is updatable
  24275. * @param stride the stride (optional)
  24276. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24277. * @param instanced whether the buffer is instanced (optional)
  24278. * @param useBytes set to true if the stride in in bytes (optional)
  24279. */
  24280. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24281. /**
  24282. * Create a new VertexBuffer based on the current buffer
  24283. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24284. * @param offset defines offset in the buffer (0 by default)
  24285. * @param size defines the size in floats of attributes (position is 3 for instance)
  24286. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24287. * @param instanced defines if the vertex buffer contains indexed data
  24288. * @param useBytes defines if the offset and stride are in bytes
  24289. * @returns the new vertex buffer
  24290. */
  24291. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24292. /**
  24293. * Gets a boolean indicating if the Buffer is updatable?
  24294. * @returns true if the buffer is updatable
  24295. */
  24296. isUpdatable(): boolean;
  24297. /**
  24298. * Gets current buffer's data
  24299. * @returns a DataArray or null
  24300. */
  24301. getData(): Nullable<DataArray>;
  24302. /**
  24303. * Gets underlying native buffer
  24304. * @returns underlying native buffer
  24305. */
  24306. getBuffer(): Nullable<WebGLBuffer>;
  24307. /**
  24308. * Gets the stride in float32 units (i.e. byte stride / 4).
  24309. * May not be an integer if the byte stride is not divisible by 4.
  24310. * DEPRECATED. Use byteStride instead.
  24311. * @returns the stride in float32 units
  24312. */
  24313. getStrideSize(): number;
  24314. /**
  24315. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24316. * @param data defines the data to store
  24317. */
  24318. create(data?: Nullable<DataArray>): void;
  24319. /** @hidden */
  24320. _rebuild(): void;
  24321. /**
  24322. * Update current buffer data
  24323. * @param data defines the data to store
  24324. */
  24325. update(data: DataArray): void;
  24326. /**
  24327. * Updates the data directly.
  24328. * @param data the new data
  24329. * @param offset the new offset
  24330. * @param vertexCount the vertex count (optional)
  24331. * @param useBytes set to true if the offset is in bytes
  24332. */
  24333. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24334. /**
  24335. * Release all resources
  24336. */
  24337. dispose(): void;
  24338. }
  24339. }
  24340. declare module BABYLON {
  24341. /**
  24342. * Class for building Constructive Solid Geometry
  24343. */
  24344. class CSG {
  24345. private polygons;
  24346. /**
  24347. * The world matrix
  24348. */
  24349. matrix: Matrix;
  24350. /**
  24351. * Stores the position
  24352. */
  24353. position: Vector3;
  24354. /**
  24355. * Stores the rotation
  24356. */
  24357. rotation: Vector3;
  24358. /**
  24359. * Stores the rotation quaternion
  24360. */
  24361. rotationQuaternion: Nullable<Quaternion>;
  24362. /**
  24363. * Stores the scaling vector
  24364. */
  24365. scaling: Vector3;
  24366. /**
  24367. * Convert the BABYLON.Mesh to BABYLON.CSG
  24368. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24369. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24370. */
  24371. static FromMesh(mesh: Mesh): CSG;
  24372. /**
  24373. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24374. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24375. */
  24376. private static FromPolygons;
  24377. /**
  24378. * Clones, or makes a deep copy, of the BABYLON.CSG
  24379. * @returns A new BABYLON.CSG
  24380. */
  24381. clone(): CSG;
  24382. /**
  24383. * Unions this CSG with another CSG
  24384. * @param csg The CSG to union against this CSG
  24385. * @returns The unioned CSG
  24386. */
  24387. union(csg: CSG): CSG;
  24388. /**
  24389. * Unions this CSG with another CSG in place
  24390. * @param csg The CSG to union against this CSG
  24391. */
  24392. unionInPlace(csg: CSG): void;
  24393. /**
  24394. * Subtracts this CSG with another CSG
  24395. * @param csg The CSG to subtract against this CSG
  24396. * @returns A new BABYLON.CSG
  24397. */
  24398. subtract(csg: CSG): CSG;
  24399. /**
  24400. * Subtracts this CSG with another CSG in place
  24401. * @param csg The CSG to subtact against this CSG
  24402. */
  24403. subtractInPlace(csg: CSG): void;
  24404. /**
  24405. * Intersect this CSG with another CSG
  24406. * @param csg The CSG to intersect against this CSG
  24407. * @returns A new BABYLON.CSG
  24408. */
  24409. intersect(csg: CSG): CSG;
  24410. /**
  24411. * Intersects this CSG with another CSG in place
  24412. * @param csg The CSG to intersect against this CSG
  24413. */
  24414. intersectInPlace(csg: CSG): void;
  24415. /**
  24416. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24417. * not modified.
  24418. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24419. */
  24420. inverse(): CSG;
  24421. /**
  24422. * Inverses the BABYLON.CSG in place
  24423. */
  24424. inverseInPlace(): void;
  24425. /**
  24426. * This is used to keep meshes transformations so they can be restored
  24427. * when we build back a Babylon Mesh
  24428. * NB : All CSG operations are performed in world coordinates
  24429. * @param csg The BABYLON.CSG to copy the transform attributes from
  24430. * @returns This BABYLON.CSG
  24431. */
  24432. copyTransformAttributes(csg: CSG): CSG;
  24433. /**
  24434. * Build Raw mesh from CSG
  24435. * Coordinates here are in world space
  24436. * @param name The name of the mesh geometry
  24437. * @param scene The BABYLON.Scene
  24438. * @param keepSubMeshes Specifies if the submeshes should be kept
  24439. * @returns A new BABYLON.Mesh
  24440. */
  24441. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24442. /**
  24443. * Build Mesh from CSG taking material and transforms into account
  24444. * @param name The name of the BABYLON.Mesh
  24445. * @param material The material of the BABYLON.Mesh
  24446. * @param scene The BABYLON.Scene
  24447. * @param keepSubMeshes Specifies if submeshes should be kept
  24448. * @returns The new BABYLON.Mesh
  24449. */
  24450. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24451. }
  24452. }
  24453. declare module BABYLON {
  24454. /**
  24455. * Class used to store geometry data (vertex buffers + index buffer)
  24456. */
  24457. class Geometry implements IGetSetVerticesData {
  24458. /**
  24459. * Gets or sets the unique ID of the geometry
  24460. */
  24461. id: string;
  24462. /**
  24463. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24464. */
  24465. delayLoadState: number;
  24466. /**
  24467. * Gets the file containing the data to load when running in delay load state
  24468. */
  24469. delayLoadingFile: Nullable<string>;
  24470. /**
  24471. * Callback called when the geometry is updated
  24472. */
  24473. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24474. private _scene;
  24475. private _engine;
  24476. private _meshes;
  24477. private _totalVertices;
  24478. /** @hidden */
  24479. _indices: IndicesArray;
  24480. /** @hidden */
  24481. _vertexBuffers: {
  24482. [key: string]: VertexBuffer;
  24483. };
  24484. private _isDisposed;
  24485. private _extend;
  24486. private _boundingBias;
  24487. /** @hidden */
  24488. _delayInfo: Array<string>;
  24489. private _indexBuffer;
  24490. private _indexBufferIsUpdatable;
  24491. /** @hidden */
  24492. _boundingInfo: Nullable<BoundingInfo>;
  24493. /** @hidden */
  24494. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24495. /** @hidden */
  24496. _softwareSkinningFrameId: number;
  24497. private _vertexArrayObjects;
  24498. private _updatable;
  24499. /** @hidden */
  24500. _positions: Nullable<Vector3[]>;
  24501. /**
  24502. * Gets or sets 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
  24503. */
  24504. /**
  24505. * Gets or sets 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
  24506. */
  24507. boundingBias: Vector2;
  24508. /**
  24509. * Static function used to attach a new empty geometry to a mesh
  24510. * @param mesh defines the mesh to attach the geometry to
  24511. * @returns the new Geometry
  24512. */
  24513. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24514. /**
  24515. * Creates a new geometry
  24516. * @param id defines the unique ID
  24517. * @param scene defines the hosting scene
  24518. * @param vertexData defines the VertexData used to get geometry data
  24519. * @param updatable defines if geometry must be updatable (false by default)
  24520. * @param mesh defines the mesh that will be associated with the geometry
  24521. */
  24522. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24523. /**
  24524. * Gets the current extend of the geometry
  24525. */
  24526. readonly extend: {
  24527. minimum: Vector3;
  24528. maximum: Vector3;
  24529. };
  24530. /**
  24531. * Gets the hosting scene
  24532. * @returns the hosting Scene
  24533. */
  24534. getScene(): Scene;
  24535. /**
  24536. * Gets the hosting engine
  24537. * @returns the hosting Engine
  24538. */
  24539. getEngine(): Engine;
  24540. /**
  24541. * Defines if the geometry is ready to use
  24542. * @returns true if the geometry is ready to be used
  24543. */
  24544. isReady(): boolean;
  24545. /**
  24546. * Gets a value indicating that the geometry should not be serialized
  24547. */
  24548. readonly doNotSerialize: boolean;
  24549. /** @hidden */
  24550. _rebuild(): void;
  24551. /**
  24552. * Affects all geometry data in one call
  24553. * @param vertexData defines the geometry data
  24554. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24555. */
  24556. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24557. /**
  24558. * Set specific vertex data
  24559. * @param kind defines the data kind (Position, normal, etc...)
  24560. * @param data defines the vertex data to use
  24561. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24562. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24563. */
  24564. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24565. /**
  24566. * Removes a specific vertex data
  24567. * @param kind defines the data kind (Position, normal, etc...)
  24568. */
  24569. removeVerticesData(kind: string): void;
  24570. /**
  24571. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24572. * @param buffer defines the vertex buffer to use
  24573. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24574. */
  24575. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24576. /**
  24577. * Update a specific vertex buffer
  24578. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  24579. * It will do nothing if the buffer is not updatable
  24580. * @param kind defines the data kind (Position, normal, etc...)
  24581. * @param data defines the data to use
  24582. * @param offset defines the offset in the target buffer where to store the data
  24583. * @param useBytes set to true if the offset is in bytes
  24584. */
  24585. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24586. /**
  24587. * Update a specific vertex buffer
  24588. * This function will create a new buffer if the current one is not updatable
  24589. * @param kind defines the data kind (Position, normal, etc...)
  24590. * @param data defines the data to use
  24591. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24592. */
  24593. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24594. private _updateBoundingInfo;
  24595. /** @hidden */
  24596. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  24597. /**
  24598. * Gets total number of vertices
  24599. * @returns the total number of vertices
  24600. */
  24601. getTotalVertices(): number;
  24602. /**
  24603. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24604. * @param kind defines the data kind (Position, normal, etc...)
  24605. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24606. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24607. * @returns a float array containing vertex data
  24608. */
  24609. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24610. /**
  24611. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24612. * @param kind defines the data kind (Position, normal, etc...)
  24613. * @returns true if the vertex buffer with the specified kind is updatable
  24614. */
  24615. isVertexBufferUpdatable(kind: string): boolean;
  24616. /**
  24617. * Gets a specific vertex buffer
  24618. * @param kind defines the data kind (Position, normal, etc...)
  24619. * @returns a VertexBuffer
  24620. */
  24621. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24622. /**
  24623. * Returns all vertex buffers
  24624. * @return an object holding all vertex buffers indexed by kind
  24625. */
  24626. getVertexBuffers(): Nullable<{
  24627. [key: string]: VertexBuffer;
  24628. }>;
  24629. /**
  24630. * Gets a boolean indicating if specific vertex buffer is present
  24631. * @param kind defines the data kind (Position, normal, etc...)
  24632. * @returns true if data is present
  24633. */
  24634. isVerticesDataPresent(kind: string): boolean;
  24635. /**
  24636. * Gets a list of all attached data kinds (Position, normal, etc...)
  24637. * @returns a list of string containing all kinds
  24638. */
  24639. getVerticesDataKinds(): string[];
  24640. /**
  24641. * Update index buffer
  24642. * @param indices defines the indices to store in the index buffer
  24643. * @param offset defines the offset in the target buffer where to store the data
  24644. */
  24645. updateIndices(indices: IndicesArray, offset?: number): void;
  24646. /**
  24647. * Creates a new index buffer
  24648. * @param indices defines the indices to store in the index buffer
  24649. * @param totalVertices defines the total number of vertices (could be null)
  24650. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24651. */
  24652. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24653. /**
  24654. * Return the total number of indices
  24655. * @returns the total number of indices
  24656. */
  24657. getTotalIndices(): number;
  24658. /**
  24659. * Gets the index buffer array
  24660. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24662. * @returns the index buffer array
  24663. */
  24664. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24665. /**
  24666. * Gets the index buffer
  24667. * @return the index buffer
  24668. */
  24669. getIndexBuffer(): Nullable<WebGLBuffer>;
  24670. /** @hidden */
  24671. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24672. /**
  24673. * Release the associated resources for a specific mesh
  24674. * @param mesh defines the source mesh
  24675. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24676. */
  24677. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24678. /**
  24679. * Apply current geometry to a given mesh
  24680. * @param mesh defines the mesh to apply geometry to
  24681. */
  24682. applyToMesh(mesh: Mesh): void;
  24683. private _updateExtend;
  24684. private _applyToMesh;
  24685. private notifyUpdate;
  24686. /**
  24687. * Load the geometry if it was flagged as delay loaded
  24688. * @param scene defines the hosting scene
  24689. * @param onLoaded defines a callback called when the geometry is loaded
  24690. */
  24691. load(scene: Scene, onLoaded?: () => void): void;
  24692. private _queueLoad;
  24693. /**
  24694. * Invert the geometry to move from a right handed system to a left handed one.
  24695. */
  24696. toLeftHanded(): void;
  24697. /** @hidden */
  24698. _resetPointsArrayCache(): void;
  24699. /** @hidden */
  24700. _generatePointsArray(): boolean;
  24701. /**
  24702. * Gets a value indicating if the geometry is disposed
  24703. * @returns true if the geometry was disposed
  24704. */
  24705. isDisposed(): boolean;
  24706. private _disposeVertexArrayObjects;
  24707. /**
  24708. * Free all associated resources
  24709. */
  24710. dispose(): void;
  24711. /**
  24712. * Clone the current geometry into a new geometry
  24713. * @param id defines the unique ID of the new geometry
  24714. * @returns a new geometry object
  24715. */
  24716. copy(id: string): Geometry;
  24717. /**
  24718. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24719. * @return a JSON representation of the current geometry data (without the vertices data)
  24720. */
  24721. serialize(): any;
  24722. private toNumberArray;
  24723. /**
  24724. * Serialize all vertices data into a JSON oject
  24725. * @returns a JSON representation of the current geometry data
  24726. */
  24727. serializeVerticeData(): any;
  24728. /**
  24729. * Extracts a clone of a mesh geometry
  24730. * @param mesh defines the source mesh
  24731. * @param id defines the unique ID of the new geometry object
  24732. * @returns the new geometry object
  24733. */
  24734. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24735. /**
  24736. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24737. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24738. * Be aware Math.random() could cause collisions, but:
  24739. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  24740. * @returns a string containing a new GUID
  24741. */
  24742. static RandomId(): string;
  24743. /** @hidden */
  24744. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24745. private static _CleanMatricesWeights;
  24746. /**
  24747. * Create a new geometry from persisted data (Using .babylon file format)
  24748. * @param parsedVertexData defines the persisted data
  24749. * @param scene defines the hosting scene
  24750. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24751. * @returns the new geometry object
  24752. */
  24753. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24754. }
  24755. /**
  24756. * Abstract class used to provide common services for all typed geometries
  24757. * @hidden
  24758. */
  24759. class _PrimitiveGeometry extends Geometry {
  24760. private _canBeRegenerated;
  24761. private _beingRegenerated;
  24762. /**
  24763. * Creates a new typed geometry
  24764. * @param id defines the unique ID of the geometry
  24765. * @param scene defines the hosting scene
  24766. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24767. * @param mesh defines the hosting mesh (can be null)
  24768. */
  24769. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  24770. /**
  24771. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  24772. * @returns true if the geometry can be regenerated
  24773. */
  24774. canBeRegenerated(): boolean;
  24775. /**
  24776. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  24777. */
  24778. regenerate(): void;
  24779. /**
  24780. * Clone the geometry
  24781. * @param id defines the unique ID of the new geometry
  24782. * @returns the new geometry
  24783. */
  24784. asNewGeometry(id: string): Geometry;
  24785. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24786. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  24787. /** @hidden */
  24788. _regenerateVertexData(): VertexData;
  24789. copy(id: string): Geometry;
  24790. serialize(): any;
  24791. }
  24792. /**
  24793. * Creates a ribbon geometry
  24794. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  24795. */
  24796. class RibbonGeometry extends _PrimitiveGeometry {
  24797. /**
  24798. * Defines the array of paths to use
  24799. */
  24800. pathArray: Vector3[][];
  24801. /**
  24802. * Defines if the last and first points of each path in your pathArray must be joined
  24803. */
  24804. closeArray: boolean;
  24805. /**
  24806. * Defines if the last and first points of each path in your pathArray must be joined
  24807. */
  24808. closePath: boolean;
  24809. /**
  24810. * Defines the offset between points
  24811. */
  24812. offset: number;
  24813. /**
  24814. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24815. */
  24816. side: number;
  24817. /**
  24818. * Creates a ribbon geometry
  24819. * @param id defines the unique ID of the geometry
  24820. * @param scene defines the hosting scene
  24821. * @param pathArray defines the array of paths to use
  24822. * @param closeArray defines if the last path and the first path must be joined
  24823. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  24824. * @param offset defines the offset between points
  24825. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24826. * @param mesh defines the hosting mesh (can be null)
  24827. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24828. */
  24829. constructor(id: string, scene: Scene,
  24830. /**
  24831. * Defines the array of paths to use
  24832. */
  24833. pathArray: Vector3[][],
  24834. /**
  24835. * Defines if the last and first points of each path in your pathArray must be joined
  24836. */
  24837. closeArray: boolean,
  24838. /**
  24839. * Defines if the last and first points of each path in your pathArray must be joined
  24840. */
  24841. closePath: boolean,
  24842. /**
  24843. * Defines the offset between points
  24844. */
  24845. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  24846. /**
  24847. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24848. */
  24849. side?: number);
  24850. /** @hidden */
  24851. _regenerateVertexData(): VertexData;
  24852. copy(id: string): Geometry;
  24853. }
  24854. /**
  24855. * Creates a box geometry
  24856. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  24857. */
  24858. class BoxGeometry extends _PrimitiveGeometry {
  24859. /**
  24860. * Defines the zise of the box (width, height and depth are the same)
  24861. */
  24862. size: number;
  24863. /**
  24864. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24865. */
  24866. side: number;
  24867. /**
  24868. * Creates a box geometry
  24869. * @param id defines the unique ID of the geometry
  24870. * @param scene defines the hosting scene
  24871. * @param size defines the zise of the box (width, height and depth are the same)
  24872. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24873. * @param mesh defines the hosting mesh (can be null)
  24874. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24875. */
  24876. constructor(id: string, scene: Scene,
  24877. /**
  24878. * Defines the zise of the box (width, height and depth are the same)
  24879. */
  24880. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24881. /**
  24882. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24883. */
  24884. side?: number);
  24885. /** @hidden */
  24886. _regenerateVertexData(): VertexData;
  24887. copy(id: string): Geometry;
  24888. serialize(): any;
  24889. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  24890. }
  24891. /**
  24892. * Creates a sphere geometry
  24893. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  24894. */
  24895. class SphereGeometry extends _PrimitiveGeometry {
  24896. /**
  24897. * Defines the number of segments to use to create the sphere
  24898. */
  24899. segments: number;
  24900. /**
  24901. * Defines the diameter of the sphere
  24902. */
  24903. diameter: number;
  24904. /**
  24905. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24906. */
  24907. side: number;
  24908. /**
  24909. * Create a new sphere geometry
  24910. * @param id defines the unique ID of the geometry
  24911. * @param scene defines the hosting scene
  24912. * @param segments defines the number of segments to use to create the sphere
  24913. * @param diameter defines the diameter of the sphere
  24914. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24915. * @param mesh defines the hosting mesh (can be null)
  24916. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24917. */
  24918. constructor(id: string, scene: Scene,
  24919. /**
  24920. * Defines the number of segments to use to create the sphere
  24921. */
  24922. segments: number,
  24923. /**
  24924. * Defines the diameter of the sphere
  24925. */
  24926. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24927. /**
  24928. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24929. */
  24930. side?: number);
  24931. /** @hidden */
  24932. _regenerateVertexData(): VertexData;
  24933. copy(id: string): Geometry;
  24934. serialize(): any;
  24935. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  24936. }
  24937. /**
  24938. * Creates a disc geometry
  24939. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24940. */
  24941. class DiscGeometry extends _PrimitiveGeometry {
  24942. /**
  24943. * Defines the radius of the disc
  24944. */
  24945. radius: number;
  24946. /**
  24947. * Defines the tesselation factor to apply to the disc
  24948. */
  24949. tessellation: number;
  24950. /**
  24951. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24952. */
  24953. side: number;
  24954. /**
  24955. * Creates a new disc geometry
  24956. * @param id defines the unique ID of the geometry
  24957. * @param scene defines the hosting scene
  24958. * @param radius defines the radius of the disc
  24959. * @param tessellation defines the tesselation factor to apply to the disc
  24960. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24961. * @param mesh defines the hosting mesh (can be null)
  24962. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24963. */
  24964. constructor(id: string, scene: Scene,
  24965. /**
  24966. * Defines the radius of the disc
  24967. */
  24968. radius: number,
  24969. /**
  24970. * Defines the tesselation factor to apply to the disc
  24971. */
  24972. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24973. /**
  24974. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24975. */
  24976. side?: number);
  24977. /** @hidden */
  24978. _regenerateVertexData(): VertexData;
  24979. copy(id: string): Geometry;
  24980. }
  24981. /**
  24982. * Creates a new cylinder geometry
  24983. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  24984. */
  24985. class CylinderGeometry extends _PrimitiveGeometry {
  24986. /**
  24987. * Defines the height of the cylinder
  24988. */
  24989. height: number;
  24990. /**
  24991. * Defines the diameter of the cylinder's top cap
  24992. */
  24993. diameterTop: number;
  24994. /**
  24995. * Defines the diameter of the cylinder's bottom cap
  24996. */
  24997. diameterBottom: number;
  24998. /**
  24999. * Defines the tessellation factor to apply to the cylinder
  25000. */
  25001. tessellation: number;
  25002. /**
  25003. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25004. */
  25005. subdivisions: number;
  25006. /**
  25007. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25008. */
  25009. side: number;
  25010. /**
  25011. * Creates a new cylinder geometry
  25012. * @param id defines the unique ID of the geometry
  25013. * @param scene defines the hosting scene
  25014. * @param height defines the height of the cylinder
  25015. * @param diameterTop defines the diameter of the cylinder's top cap
  25016. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25017. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25018. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25019. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25020. * @param mesh defines the hosting mesh (can be null)
  25021. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25022. */
  25023. constructor(id: string, scene: Scene,
  25024. /**
  25025. * Defines the height of the cylinder
  25026. */
  25027. height: number,
  25028. /**
  25029. * Defines the diameter of the cylinder's top cap
  25030. */
  25031. diameterTop: number,
  25032. /**
  25033. * Defines the diameter of the cylinder's bottom cap
  25034. */
  25035. diameterBottom: number,
  25036. /**
  25037. * Defines the tessellation factor to apply to the cylinder
  25038. */
  25039. tessellation: number,
  25040. /**
  25041. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25042. */
  25043. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25044. /**
  25045. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25046. */
  25047. side?: number);
  25048. /** @hidden */
  25049. _regenerateVertexData(): VertexData;
  25050. copy(id: string): Geometry;
  25051. serialize(): any;
  25052. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25053. }
  25054. /**
  25055. * Creates a new torus geometry
  25056. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25057. */
  25058. class TorusGeometry extends _PrimitiveGeometry {
  25059. /**
  25060. * Defines the diameter of the torus
  25061. */
  25062. diameter: number;
  25063. /**
  25064. * Defines the thickness of the torus (ie. internal diameter)
  25065. */
  25066. thickness: number;
  25067. /**
  25068. * Defines the tesselation factor to apply to the torus
  25069. */
  25070. tessellation: number;
  25071. /**
  25072. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25073. */
  25074. side: number;
  25075. /**
  25076. * Creates a new torus geometry
  25077. * @param id defines the unique ID of the geometry
  25078. * @param scene defines the hosting scene
  25079. * @param diameter defines the diameter of the torus
  25080. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25081. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25082. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25083. * @param mesh defines the hosting mesh (can be null)
  25084. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25085. */
  25086. constructor(id: string, scene: Scene,
  25087. /**
  25088. * Defines the diameter of the torus
  25089. */
  25090. diameter: number,
  25091. /**
  25092. * Defines the thickness of the torus (ie. internal diameter)
  25093. */
  25094. thickness: number,
  25095. /**
  25096. * Defines the tesselation factor to apply to the torus
  25097. */
  25098. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25099. /**
  25100. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25101. */
  25102. side?: number);
  25103. /** @hidden */
  25104. _regenerateVertexData(): VertexData;
  25105. copy(id: string): Geometry;
  25106. serialize(): any;
  25107. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25108. }
  25109. /**
  25110. * Creates a new ground geometry
  25111. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25112. */
  25113. class GroundGeometry extends _PrimitiveGeometry {
  25114. /**
  25115. * Defines the width of the ground
  25116. */
  25117. width: number;
  25118. /**
  25119. * Defines the height of the ground
  25120. */
  25121. height: number;
  25122. /**
  25123. * Defines the subdivisions to apply to the ground
  25124. */
  25125. subdivisions: number;
  25126. /**
  25127. * Creates a new ground geometry
  25128. * @param id defines the unique ID of the geometry
  25129. * @param scene defines the hosting scene
  25130. * @param width defines the width of the ground
  25131. * @param height defines the height of the ground
  25132. * @param subdivisions defines the subdivisions to apply to the ground
  25133. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25134. * @param mesh defines the hosting mesh (can be null)
  25135. */
  25136. constructor(id: string, scene: Scene,
  25137. /**
  25138. * Defines the width of the ground
  25139. */
  25140. width: number,
  25141. /**
  25142. * Defines the height of the ground
  25143. */
  25144. height: number,
  25145. /**
  25146. * Defines the subdivisions to apply to the ground
  25147. */
  25148. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25149. /** @hidden */
  25150. _regenerateVertexData(): VertexData;
  25151. copy(id: string): Geometry;
  25152. serialize(): any;
  25153. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25154. }
  25155. /**
  25156. * Creates a tiled ground geometry
  25157. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25158. */
  25159. class TiledGroundGeometry extends _PrimitiveGeometry {
  25160. /**
  25161. * Defines the minimum value on X axis
  25162. */
  25163. xmin: number;
  25164. /**
  25165. * Defines the minimum value on Z axis
  25166. */
  25167. zmin: number;
  25168. /**
  25169. * Defines the maximum value on X axis
  25170. */
  25171. xmax: number;
  25172. /**
  25173. * Defines the maximum value on Z axis
  25174. */
  25175. zmax: number;
  25176. /**
  25177. * Defines the subdivisions to apply to the ground
  25178. */
  25179. subdivisions: {
  25180. w: number;
  25181. h: number;
  25182. };
  25183. /**
  25184. * Defines the precision to use when computing the tiles
  25185. */
  25186. precision: {
  25187. w: number;
  25188. h: number;
  25189. };
  25190. /**
  25191. * Creates a tiled ground geometry
  25192. * @param id defines the unique ID of the geometry
  25193. * @param scene defines the hosting scene
  25194. * @param xmin defines the minimum value on X axis
  25195. * @param zmin defines the minimum value on Z axis
  25196. * @param xmax defines the maximum value on X axis
  25197. * @param zmax defines the maximum value on Z axis
  25198. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25199. * @param precision defines the precision to use when computing the tiles
  25200. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25201. * @param mesh defines the hosting mesh (can be null)
  25202. */
  25203. constructor(id: string, scene: Scene,
  25204. /**
  25205. * Defines the minimum value on X axis
  25206. */
  25207. xmin: number,
  25208. /**
  25209. * Defines the minimum value on Z axis
  25210. */
  25211. zmin: number,
  25212. /**
  25213. * Defines the maximum value on X axis
  25214. */
  25215. xmax: number,
  25216. /**
  25217. * Defines the maximum value on Z axis
  25218. */
  25219. zmax: number,
  25220. /**
  25221. * Defines the subdivisions to apply to the ground
  25222. */
  25223. subdivisions: {
  25224. w: number;
  25225. h: number;
  25226. },
  25227. /**
  25228. * Defines the precision to use when computing the tiles
  25229. */
  25230. precision: {
  25231. w: number;
  25232. h: number;
  25233. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25234. /** @hidden */
  25235. _regenerateVertexData(): VertexData;
  25236. copy(id: string): Geometry;
  25237. }
  25238. /**
  25239. * Creates a plane geometry
  25240. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25241. */
  25242. class PlaneGeometry extends _PrimitiveGeometry {
  25243. /**
  25244. * Defines the size of the plane (width === height)
  25245. */
  25246. size: number;
  25247. /**
  25248. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25249. */
  25250. side: number;
  25251. /**
  25252. * Creates a plane geometry
  25253. * @param id defines the unique ID of the geometry
  25254. * @param scene defines the hosting scene
  25255. * @param size defines the size of the plane (width === height)
  25256. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25257. * @param mesh defines the hosting mesh (can be null)
  25258. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25259. */
  25260. constructor(id: string, scene: Scene,
  25261. /**
  25262. * Defines the size of the plane (width === height)
  25263. */
  25264. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25265. /**
  25266. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25267. */
  25268. side?: number);
  25269. /** @hidden */
  25270. _regenerateVertexData(): VertexData;
  25271. copy(id: string): Geometry;
  25272. serialize(): any;
  25273. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25274. }
  25275. /**
  25276. * Creates a torus knot geometry
  25277. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25278. */
  25279. class TorusKnotGeometry extends _PrimitiveGeometry {
  25280. /**
  25281. * Defines the radius of the torus knot
  25282. */
  25283. radius: number;
  25284. /**
  25285. * Defines the thickness of the torus knot tube
  25286. */
  25287. tube: number;
  25288. /**
  25289. * Defines the number of radial segments
  25290. */
  25291. radialSegments: number;
  25292. /**
  25293. * Defines the number of tubular segments
  25294. */
  25295. tubularSegments: number;
  25296. /**
  25297. * Defines the first number of windings
  25298. */
  25299. p: number;
  25300. /**
  25301. * Defines the second number of windings
  25302. */
  25303. q: number;
  25304. /**
  25305. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25306. */
  25307. side: number;
  25308. /**
  25309. * Creates a torus knot geometry
  25310. * @param id defines the unique ID of the geometry
  25311. * @param scene defines the hosting scene
  25312. * @param radius defines the radius of the torus knot
  25313. * @param tube defines the thickness of the torus knot tube
  25314. * @param radialSegments defines the number of radial segments
  25315. * @param tubularSegments defines the number of tubular segments
  25316. * @param p defines the first number of windings
  25317. * @param q defines the second number of windings
  25318. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25319. * @param mesh defines the hosting mesh (can be null)
  25320. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25321. */
  25322. constructor(id: string, scene: Scene,
  25323. /**
  25324. * Defines the radius of the torus knot
  25325. */
  25326. radius: number,
  25327. /**
  25328. * Defines the thickness of the torus knot tube
  25329. */
  25330. tube: number,
  25331. /**
  25332. * Defines the number of radial segments
  25333. */
  25334. radialSegments: number,
  25335. /**
  25336. * Defines the number of tubular segments
  25337. */
  25338. tubularSegments: number,
  25339. /**
  25340. * Defines the first number of windings
  25341. */
  25342. p: number,
  25343. /**
  25344. * Defines the second number of windings
  25345. */
  25346. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25347. /**
  25348. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25349. */
  25350. side?: number);
  25351. /** @hidden */
  25352. _regenerateVertexData(): VertexData;
  25353. copy(id: string): Geometry;
  25354. serialize(): any;
  25355. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25356. }
  25357. }
  25358. declare module BABYLON {
  25359. /**
  25360. * Mesh representing the gorund
  25361. */
  25362. class GroundMesh extends Mesh {
  25363. /** If octree should be generated */
  25364. generateOctree: boolean;
  25365. private _heightQuads;
  25366. /** @hidden */
  25367. _subdivisionsX: number;
  25368. /** @hidden */
  25369. _subdivisionsY: number;
  25370. /** @hidden */
  25371. _width: number;
  25372. /** @hidden */
  25373. _height: number;
  25374. /** @hidden */
  25375. _minX: number;
  25376. /** @hidden */
  25377. _maxX: number;
  25378. /** @hidden */
  25379. _minZ: number;
  25380. /** @hidden */
  25381. _maxZ: number;
  25382. constructor(name: string, scene: Scene);
  25383. /**
  25384. * "GroundMesh"
  25385. * @returns "GroundMesh"
  25386. */
  25387. getClassName(): string;
  25388. /**
  25389. * The minimum of x and y subdivisions
  25390. */
  25391. readonly subdivisions: number;
  25392. /**
  25393. * X subdivisions
  25394. */
  25395. readonly subdivisionsX: number;
  25396. /**
  25397. * Y subdivisions
  25398. */
  25399. readonly subdivisionsY: number;
  25400. /**
  25401. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25402. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25403. * @param chunksCount the number of subdivisions for x and y
  25404. * @param octreeBlocksSize (Default: 32)
  25405. */
  25406. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25407. /**
  25408. * Returns a height (y) value in the Worl system :
  25409. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25410. * @param x x coordinate
  25411. * @param z z coordinate
  25412. * @returns the ground y position if (x, z) are outside the ground surface.
  25413. */
  25414. getHeightAtCoordinates(x: number, z: number): number;
  25415. /**
  25416. * Returns a normalized vector (Vector3) orthogonal to the ground
  25417. * at the ground coordinates (x, z) expressed in the World system.
  25418. * @param x x coordinate
  25419. * @param z z coordinate
  25420. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25421. */
  25422. getNormalAtCoordinates(x: number, z: number): Vector3;
  25423. /**
  25424. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25425. * at the ground coordinates (x, z) expressed in the World system.
  25426. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25427. * @param x x coordinate
  25428. * @param z z coordinate
  25429. * @param ref vector to store the result
  25430. * @returns the GroundMesh.
  25431. */
  25432. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25433. /**
  25434. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25435. * if the ground has been updated.
  25436. * This can be used in the render loop.
  25437. * @returns the GroundMesh.
  25438. */
  25439. updateCoordinateHeights(): GroundMesh;
  25440. private _getFacetAt;
  25441. private _initHeightQuads;
  25442. private _computeHeightQuads;
  25443. /**
  25444. * Serializes this ground mesh
  25445. * @param serializationObject object to write serialization to
  25446. */
  25447. serialize(serializationObject: any): void;
  25448. /**
  25449. * Parses a serialized ground mesh
  25450. * @param parsedMesh the serialized mesh
  25451. * @param scene the scene to create the ground mesh in
  25452. * @returns the created ground mesh
  25453. */
  25454. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25455. }
  25456. }
  25457. declare module BABYLON {
  25458. /**
  25459. * Creates an instance based on a source mesh.
  25460. */
  25461. class InstancedMesh extends AbstractMesh {
  25462. private _sourceMesh;
  25463. private _currentLOD;
  25464. constructor(name: string, source: Mesh);
  25465. /**
  25466. * Returns the string "InstancedMesh".
  25467. */
  25468. getClassName(): string;
  25469. /**
  25470. * If the source mesh receives shadows
  25471. */
  25472. readonly receiveShadows: boolean;
  25473. /**
  25474. * The material of the source mesh
  25475. */
  25476. readonly material: Nullable<Material>;
  25477. /**
  25478. * Visibility of the source mesh
  25479. */
  25480. readonly visibility: number;
  25481. /**
  25482. * Skeleton of the source mesh
  25483. */
  25484. readonly skeleton: Nullable<Skeleton>;
  25485. /**
  25486. * Rendering ground id of the source mesh
  25487. */
  25488. renderingGroupId: number;
  25489. /**
  25490. * Returns the total number of vertices (integer).
  25491. */
  25492. getTotalVertices(): number;
  25493. /**
  25494. * The source mesh of the instance
  25495. */
  25496. readonly sourceMesh: Mesh;
  25497. /**
  25498. * Is this node ready to be used/rendered
  25499. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25500. * @return {boolean} is it ready
  25501. */
  25502. isReady(completeCheck?: boolean): boolean;
  25503. /**
  25504. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25505. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  25506. * @param copyWhenShared If 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.
  25507. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25508. */
  25509. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  25510. /**
  25511. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25512. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25513. * The `data` are either a numeric array either a Float32Array.
  25514. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  25515. * 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).
  25516. * Note that a new underlying VertexBuffer object is created each call.
  25517. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25518. *
  25519. * Possible `kind` values :
  25520. * - BABYLON.VertexBuffer.PositionKind
  25521. * - BABYLON.VertexBuffer.UVKind
  25522. * - BABYLON.VertexBuffer.UV2Kind
  25523. * - BABYLON.VertexBuffer.UV3Kind
  25524. * - BABYLON.VertexBuffer.UV4Kind
  25525. * - BABYLON.VertexBuffer.UV5Kind
  25526. * - BABYLON.VertexBuffer.UV6Kind
  25527. * - BABYLON.VertexBuffer.ColorKind
  25528. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25529. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25530. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25531. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25532. *
  25533. * Returns the Mesh.
  25534. */
  25535. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25536. /**
  25537. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25538. * If the mesh has no geometry, it is simply returned as it is.
  25539. * The `data` are either a numeric array either a Float32Array.
  25540. * No new underlying VertexBuffer object is created.
  25541. * 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.
  25542. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  25543. *
  25544. * Possible `kind` values :
  25545. * - BABYLON.VertexBuffer.PositionKind
  25546. * - BABYLON.VertexBuffer.UVKind
  25547. * - BABYLON.VertexBuffer.UV2Kind
  25548. * - BABYLON.VertexBuffer.UV3Kind
  25549. * - BABYLON.VertexBuffer.UV4Kind
  25550. * - BABYLON.VertexBuffer.UV5Kind
  25551. * - BABYLON.VertexBuffer.UV6Kind
  25552. * - BABYLON.VertexBuffer.ColorKind
  25553. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25554. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25555. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25556. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25557. *
  25558. * Returns the Mesh.
  25559. */
  25560. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  25561. /**
  25562. * Sets the mesh indices.
  25563. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  25564. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25565. * This method creates a new index buffer each call.
  25566. * Returns the Mesh.
  25567. */
  25568. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  25569. /**
  25570. * Boolean : True if the mesh owns the requested kind of data.
  25571. */
  25572. isVerticesDataPresent(kind: string): boolean;
  25573. /**
  25574. * Returns an array of indices (IndicesArray).
  25575. */
  25576. getIndices(): Nullable<IndicesArray>;
  25577. readonly _positions: Nullable<Vector3[]>;
  25578. /**
  25579. * Sets a new updated BoundingInfo to the mesh.
  25580. * @returns the mesh.
  25581. */
  25582. refreshBoundingInfo(): InstancedMesh;
  25583. /** @hidden */
  25584. _preActivate(): InstancedMesh;
  25585. /** @hidden */
  25586. _activate(renderId: number): InstancedMesh;
  25587. /**
  25588. * Returns the current associated LOD AbstractMesh.
  25589. */
  25590. getLOD(camera: Camera): AbstractMesh;
  25591. /** @hidden */
  25592. _syncSubMeshes(): InstancedMesh;
  25593. /** @hidden */
  25594. _generatePointsArray(): boolean;
  25595. /**
  25596. * Creates a new InstancedMesh from the current mesh.
  25597. * - name (string) : the cloned mesh name
  25598. * - newParent (optional Node) : the optional Node to parent the clone to.
  25599. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  25600. *
  25601. * Returns the clone.
  25602. */
  25603. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  25604. /**
  25605. * Disposes the InstancedMesh.
  25606. * Returns nothing.
  25607. */
  25608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25609. }
  25610. }
  25611. declare module BABYLON {
  25612. /**
  25613. * Line mesh
  25614. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  25615. */
  25616. class LinesMesh extends Mesh {
  25617. /**
  25618. * If vertex color should be applied to the mesh
  25619. */
  25620. useVertexColor?: boolean | undefined;
  25621. /**
  25622. * If vertex alpha should be applied to the mesh
  25623. */
  25624. useVertexAlpha?: boolean | undefined;
  25625. /**
  25626. * Color of the line (Default: White)
  25627. */
  25628. color: Color3;
  25629. /**
  25630. * Alpha of the line (Default: 1)
  25631. */
  25632. alpha: number;
  25633. /**
  25634. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25635. * This margin is expressed in world space coordinates, so its value may vary.
  25636. * Default value is 0.1
  25637. * @returns the intersection Threshold value.
  25638. */
  25639. /**
  25640. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25641. * This margin is expressed in world space coordinates, so its value may vary.
  25642. */
  25643. intersectionThreshold: number;
  25644. private _intersectionThreshold;
  25645. private _colorShader;
  25646. /**
  25647. * Creates a new LinesMesh
  25648. * @param name defines the name
  25649. * @param scene defines the hosting scene
  25650. * @param parent defines the parent mesh if any
  25651. * @param source defines the optional source LinesMesh used to clone data from
  25652. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25653. * When false, achieved by calling a clone(), also passing False.
  25654. * This will make creation of children, recursive.
  25655. * @param useVertexColor defines if this LinesMesh supports vertex color
  25656. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  25657. */
  25658. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  25659. /**
  25660. * If vertex color should be applied to the mesh
  25661. */
  25662. useVertexColor?: boolean | undefined,
  25663. /**
  25664. * If vertex alpha should be applied to the mesh
  25665. */
  25666. useVertexAlpha?: boolean | undefined);
  25667. /**
  25668. * Returns the string "LineMesh"
  25669. */
  25670. getClassName(): string;
  25671. /**
  25672. * @hidden
  25673. */
  25674. /**
  25675. * @hidden
  25676. */
  25677. material: Material;
  25678. /**
  25679. * @hidden
  25680. */
  25681. readonly checkCollisions: boolean;
  25682. /** @hidden */
  25683. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  25684. /** @hidden */
  25685. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  25686. /**
  25687. * Disposes of the line mesh
  25688. * @param doNotRecurse If children should be disposed
  25689. */
  25690. dispose(doNotRecurse?: boolean): void;
  25691. /**
  25692. * Returns a new LineMesh object cloned from the current one.
  25693. */
  25694. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  25695. }
  25696. }
  25697. declare module BABYLON {
  25698. /**
  25699. * @hidden
  25700. **/
  25701. class _CreationDataStorage {
  25702. closePath?: boolean;
  25703. closeArray?: boolean;
  25704. idx: number[];
  25705. dashSize: number;
  25706. gapSize: number;
  25707. path3D: Path3D;
  25708. pathArray: Vector3[][];
  25709. arc: number;
  25710. radius: number;
  25711. cap: number;
  25712. tessellation: number;
  25713. }
  25714. /**
  25715. * @hidden
  25716. **/
  25717. class _InstanceDataStorage {
  25718. visibleInstances: any;
  25719. renderIdForInstances: number[];
  25720. batchCache: _InstancesBatch;
  25721. instancesBufferSize: number;
  25722. instancesBuffer: Nullable<Buffer>;
  25723. instancesData: Float32Array;
  25724. overridenInstanceCount: number;
  25725. }
  25726. /**
  25727. * @hidden
  25728. **/
  25729. class _InstancesBatch {
  25730. mustReturn: boolean;
  25731. visibleInstances: Nullable<InstancedMesh[]>[];
  25732. renderSelf: boolean[];
  25733. }
  25734. /**
  25735. * Class used to represent renderable models
  25736. */
  25737. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25738. /**
  25739. * Mesh side orientation : usually the external or front surface
  25740. */
  25741. static readonly FRONTSIDE: number;
  25742. /**
  25743. * Mesh side orientation : usually the internal or back surface
  25744. */
  25745. static readonly BACKSIDE: number;
  25746. /**
  25747. * Mesh side orientation : both internal and external or front and back surfaces
  25748. */
  25749. static readonly DOUBLESIDE: number;
  25750. /**
  25751. * Mesh side orientation : by default, `FRONTSIDE`
  25752. */
  25753. static readonly DEFAULTSIDE: number;
  25754. /**
  25755. * Mesh cap setting : no cap
  25756. */
  25757. static readonly NO_CAP: number;
  25758. /**
  25759. * Mesh cap setting : one cap at the beginning of the mesh
  25760. */
  25761. static readonly CAP_START: number;
  25762. /**
  25763. * Mesh cap setting : one cap at the end of the mesh
  25764. */
  25765. static readonly CAP_END: number;
  25766. /**
  25767. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25768. */
  25769. static readonly CAP_ALL: number;
  25770. private _onBeforeRenderObservable;
  25771. private _onAfterRenderObservable;
  25772. private _onBeforeDrawObservable;
  25773. /**
  25774. * An event triggered before rendering the mesh
  25775. */
  25776. readonly onBeforeRenderObservable: Observable<Mesh>;
  25777. /**
  25778. * An event triggered after rendering the mesh
  25779. */
  25780. readonly onAfterRenderObservable: Observable<Mesh>;
  25781. /**
  25782. * An event triggered before drawing the mesh
  25783. */
  25784. readonly onBeforeDrawObservable: Observable<Mesh>;
  25785. private _onBeforeDrawObserver;
  25786. /**
  25787. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25788. */
  25789. onBeforeDraw: () => void;
  25790. /**
  25791. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25792. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25793. */
  25794. delayLoadState: number;
  25795. /**
  25796. * Gets the list of instances created from this mesh
  25797. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25798. */
  25799. instances: InstancedMesh[];
  25800. /**
  25801. * Gets the file containing delay loading data for this mesh
  25802. */
  25803. delayLoadingFile: string;
  25804. /** @hidden */
  25805. _binaryInfo: any;
  25806. private _LODLevels;
  25807. /**
  25808. * User defined function used to change how LOD level selection is done
  25809. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25810. */
  25811. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25812. private _morphTargetManager;
  25813. /**
  25814. * Gets or sets the morph target manager
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25816. */
  25817. morphTargetManager: Nullable<MorphTargetManager>;
  25818. /** @hidden */
  25819. _creationDataStorage: Nullable<_CreationDataStorage>;
  25820. /** @hidden */
  25821. _geometry: Nullable<Geometry>;
  25822. /** @hidden */
  25823. _delayInfo: Array<string>;
  25824. /** @hidden */
  25825. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25826. /** @hidden */
  25827. _instanceDataStorage: _InstanceDataStorage;
  25828. private _effectiveMaterial;
  25829. /** @hidden */
  25830. _shouldGenerateFlatShading: boolean;
  25831. private _preActivateId;
  25832. /** @hidden */
  25833. _originalBuilderSideOrientation: number;
  25834. /**
  25835. * Use this property to change the original side orientation defined at construction time
  25836. */
  25837. overrideMaterialSideOrientation: Nullable<number>;
  25838. private _areNormalsFrozen;
  25839. private _sourcePositions;
  25840. private _sourceNormals;
  25841. private _source;
  25842. /**
  25843. * Gets the source mesh (the one used to clone this one from)
  25844. */
  25845. readonly source: Nullable<Mesh>;
  25846. /**
  25847. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25848. */
  25849. isUnIndexed: boolean;
  25850. /**
  25851. * @constructor
  25852. * @param name The value used by scene.getMeshByName() to do a lookup.
  25853. * @param scene The scene to add this mesh to.
  25854. * @param parent The parent of this mesh, if it has one
  25855. * @param source An optional Mesh from which geometry is shared, cloned.
  25856. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25857. * When false, achieved by calling a clone(), also passing False.
  25858. * This will make creation of children, recursive.
  25859. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25860. */
  25861. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25862. /**
  25863. * Gets the class name
  25864. * @returns the string "Mesh".
  25865. */
  25866. getClassName(): string;
  25867. /**
  25868. * Returns a description of this mesh
  25869. * @param fullDetails define if full details about this mesh must be used
  25870. * @returns a descriptive string representing this mesh
  25871. */
  25872. toString(fullDetails?: boolean): string;
  25873. /** @hidden */
  25874. _unBindEffect(): void;
  25875. /**
  25876. * Gets a boolean indicating if this mesh has LOD
  25877. */
  25878. readonly hasLODLevels: boolean;
  25879. /**
  25880. * Gets the list of MeshLODLevel associated with the current mesh
  25881. * @returns an array of MeshLODLevel
  25882. */
  25883. getLODLevels(): MeshLODLevel[];
  25884. private _sortLODLevels;
  25885. /**
  25886. * Add a mesh as LOD level triggered at the given distance.
  25887. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25888. * @param distance The distance from the center of the object to show this level
  25889. * @param mesh The mesh to be added as LOD level (can be null)
  25890. * @return This mesh (for chaining)
  25891. */
  25892. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25893. /**
  25894. * Returns the LOD level mesh at the passed distance or null if not found.
  25895. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25896. * @param distance The distance from the center of the object to show this level
  25897. * @returns a Mesh or `null`
  25898. */
  25899. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25900. /**
  25901. * Remove a mesh from the LOD array
  25902. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25903. * @param mesh defines the mesh to be removed
  25904. * @return This mesh (for chaining)
  25905. */
  25906. removeLODLevel(mesh: Mesh): Mesh;
  25907. /**
  25908. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25909. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25910. * @param camera defines the camera to use to compute distance
  25911. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25912. * @return This mesh (for chaining)
  25913. */
  25914. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25915. /**
  25916. * Gets the mesh internal Geometry object
  25917. */
  25918. readonly geometry: Nullable<Geometry>;
  25919. /**
  25920. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25921. * @returns the total number of vertices
  25922. */
  25923. getTotalVertices(): number;
  25924. /**
  25925. * Returns the content of an associated vertex buffer
  25926. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25927. * - BABYLON.VertexBuffer.PositionKind
  25928. * - BABYLON.VertexBuffer.UVKind
  25929. * - BABYLON.VertexBuffer.UV2Kind
  25930. * - BABYLON.VertexBuffer.UV3Kind
  25931. * - BABYLON.VertexBuffer.UV4Kind
  25932. * - BABYLON.VertexBuffer.UV5Kind
  25933. * - BABYLON.VertexBuffer.UV6Kind
  25934. * - BABYLON.VertexBuffer.ColorKind
  25935. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25936. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25937. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25938. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25939. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  25940. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25941. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25942. */
  25943. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25944. /**
  25945. * Returns the mesh VertexBuffer object from the requested `kind`
  25946. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25947. * - BABYLON.VertexBuffer.PositionKind
  25948. * - BABYLON.VertexBuffer.UVKind
  25949. * - BABYLON.VertexBuffer.UV2Kind
  25950. * - BABYLON.VertexBuffer.UV3Kind
  25951. * - BABYLON.VertexBuffer.UV4Kind
  25952. * - BABYLON.VertexBuffer.UV5Kind
  25953. * - BABYLON.VertexBuffer.UV6Kind
  25954. * - BABYLON.VertexBuffer.ColorKind
  25955. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25956. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25957. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25958. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25959. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25960. */
  25961. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25962. /**
  25963. * Tests if a specific vertex buffer is associated with this mesh
  25964. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25965. * - BABYLON.VertexBuffer.PositionKind
  25966. * - BABYLON.VertexBuffer.UVKind
  25967. * - BABYLON.VertexBuffer.UV2Kind
  25968. * - BABYLON.VertexBuffer.UV3Kind
  25969. * - BABYLON.VertexBuffer.UV4Kind
  25970. * - BABYLON.VertexBuffer.UV5Kind
  25971. * - BABYLON.VertexBuffer.UV6Kind
  25972. * - BABYLON.VertexBuffer.ColorKind
  25973. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25974. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25975. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25976. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25977. * @returns a boolean
  25978. */
  25979. isVerticesDataPresent(kind: string): boolean;
  25980. /**
  25981. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25982. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25983. * - BABYLON.VertexBuffer.PositionKind
  25984. * - BABYLON.VertexBuffer.UVKind
  25985. * - BABYLON.VertexBuffer.UV2Kind
  25986. * - BABYLON.VertexBuffer.UV3Kind
  25987. * - BABYLON.VertexBuffer.UV4Kind
  25988. * - BABYLON.VertexBuffer.UV5Kind
  25989. * - BABYLON.VertexBuffer.UV6Kind
  25990. * - BABYLON.VertexBuffer.ColorKind
  25991. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25992. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25993. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25994. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25995. * @returns a boolean
  25996. */
  25997. isVertexBufferUpdatable(kind: string): boolean;
  25998. /**
  25999. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26000. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26001. * - BABYLON.VertexBuffer.PositionKind
  26002. * - BABYLON.VertexBuffer.UVKind
  26003. * - BABYLON.VertexBuffer.UV2Kind
  26004. * - BABYLON.VertexBuffer.UV3Kind
  26005. * - BABYLON.VertexBuffer.UV4Kind
  26006. * - BABYLON.VertexBuffer.UV5Kind
  26007. * - BABYLON.VertexBuffer.UV6Kind
  26008. * - BABYLON.VertexBuffer.ColorKind
  26009. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26010. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26011. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26012. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26013. * @returns an array of strings
  26014. */
  26015. getVerticesDataKinds(): string[];
  26016. /**
  26017. * Returns a positive integer : the total number of indices in this mesh geometry.
  26018. * @returns the numner of indices or zero if the mesh has no geometry.
  26019. */
  26020. getTotalIndices(): number;
  26021. /**
  26022. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26023. * @param copyWhenShared If 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.
  26024. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26025. * @returns the indices array or an empty array if the mesh has no geometry
  26026. */
  26027. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26028. readonly isBlocked: boolean;
  26029. /**
  26030. * Determine if the current mesh is ready to be rendered
  26031. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26032. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26033. * @returns true if all associated assets are ready (material, textures, shaders)
  26034. */
  26035. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26036. /**
  26037. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  26038. */
  26039. readonly areNormalsFrozen: boolean;
  26040. /**
  26041. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  26042. * @returns the current mesh
  26043. */
  26044. freezeNormals(): Mesh;
  26045. /**
  26046. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  26047. * @returns the current mesh
  26048. */
  26049. unfreezeNormals(): Mesh;
  26050. /**
  26051. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26052. */
  26053. overridenInstanceCount: number;
  26054. /** @hidden */
  26055. _preActivate(): Mesh;
  26056. /** @hidden */
  26057. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26058. /** @hidden */
  26059. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26060. /**
  26061. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26062. * This means the mesh underlying bounding box and sphere are recomputed.
  26063. * @returns the current mesh
  26064. */
  26065. refreshBoundingInfo(): Mesh;
  26066. /** @hidden */
  26067. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26068. private _getPositionData;
  26069. /** @hidden */
  26070. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26071. /**
  26072. * This function will subdivide the mesh into multiple submeshes
  26073. * @param count defines the expected number of submeshes
  26074. */
  26075. subdivide(count: number): void;
  26076. /**
  26077. * Copy a FloatArray into a specific associated vertex buffer
  26078. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26079. * - BABYLON.VertexBuffer.PositionKind
  26080. * - BABYLON.VertexBuffer.UVKind
  26081. * - BABYLON.VertexBuffer.UV2Kind
  26082. * - BABYLON.VertexBuffer.UV3Kind
  26083. * - BABYLON.VertexBuffer.UV4Kind
  26084. * - BABYLON.VertexBuffer.UV5Kind
  26085. * - BABYLON.VertexBuffer.UV6Kind
  26086. * - BABYLON.VertexBuffer.ColorKind
  26087. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26088. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26089. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26090. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26091. * @param data defines the data source
  26092. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26093. * @param stride defines the data stride size (can be null)
  26094. * @returns the current mesh
  26095. */
  26096. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26097. /**
  26098. * Flags an associated vertex buffer as updatable
  26099. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26100. * - BABYLON.VertexBuffer.PositionKind
  26101. * - BABYLON.VertexBuffer.UVKind
  26102. * - BABYLON.VertexBuffer.UV2Kind
  26103. * - BABYLON.VertexBuffer.UV3Kind
  26104. * - BABYLON.VertexBuffer.UV4Kind
  26105. * - BABYLON.VertexBuffer.UV5Kind
  26106. * - BABYLON.VertexBuffer.UV6Kind
  26107. * - BABYLON.VertexBuffer.ColorKind
  26108. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26109. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26110. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26111. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26112. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26113. */
  26114. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26115. /**
  26116. * Sets the mesh global Vertex Buffer
  26117. * @param buffer defines the buffer to use
  26118. * @returns the current mesh
  26119. */
  26120. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26121. /**
  26122. * Update a specific associated vertex buffer
  26123. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26124. * - BABYLON.VertexBuffer.PositionKind
  26125. * - BABYLON.VertexBuffer.UVKind
  26126. * - BABYLON.VertexBuffer.UV2Kind
  26127. * - BABYLON.VertexBuffer.UV3Kind
  26128. * - BABYLON.VertexBuffer.UV4Kind
  26129. * - BABYLON.VertexBuffer.UV5Kind
  26130. * - BABYLON.VertexBuffer.UV6Kind
  26131. * - BABYLON.VertexBuffer.ColorKind
  26132. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26133. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26134. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26135. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26136. * @param data defines the data source
  26137. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26138. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  26139. * @returns the current mesh
  26140. */
  26141. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26142. /**
  26143. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26144. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26145. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26146. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26147. * @returns the current mesh
  26148. */
  26149. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26150. /**
  26151. * Creates a un-shared specific occurence of the geometry for the mesh.
  26152. * @returns the current mesh
  26153. */
  26154. makeGeometryUnique(): Mesh;
  26155. /**
  26156. * Set the index buffer of this mesh
  26157. * @param indices defines the source data
  26158. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26159. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26160. * @returns the current mesh
  26161. */
  26162. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26163. /**
  26164. * Update the current index buffer
  26165. * @param indices defines the source data
  26166. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26167. * @returns the current mesh
  26168. */
  26169. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26170. /**
  26171. * Invert the geometry to move from a right handed system to a left handed one.
  26172. * @returns the current mesh
  26173. */
  26174. toLeftHanded(): Mesh;
  26175. /** @hidden */
  26176. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26177. /** @hidden */
  26178. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26179. /**
  26180. * Registers for this mesh a javascript function called just before the rendering process
  26181. * @param func defines the function to call before rendering this mesh
  26182. * @returns the current mesh
  26183. */
  26184. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26185. /**
  26186. * Disposes a previously registered javascript function called before the rendering
  26187. * @param func defines the function to remove
  26188. * @returns the current mesh
  26189. */
  26190. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26191. /**
  26192. * Registers for this mesh a javascript function called just after the rendering is complete
  26193. * @param func defines the function to call after rendering this mesh
  26194. * @returns the current mesh
  26195. */
  26196. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26197. /**
  26198. * Disposes a previously registered javascript function called after the rendering.
  26199. * @param func defines the function to remove
  26200. * @returns the current mesh
  26201. */
  26202. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26203. /** @hidden */
  26204. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26205. /** @hidden */
  26206. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26207. /** @hidden */
  26208. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26209. /**
  26210. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  26211. * @param subMesh defines the subMesh to render
  26212. * @param enableAlphaMode defines if alpha mode can be changed
  26213. * @returns the current mesh
  26214. */
  26215. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26216. private _onBeforeDraw;
  26217. /**
  26218. * Renormalize the mesh and patch it up if there are no weights
  26219. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26220. * However in the case of zero weights then we set just a single influence to 1.
  26221. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26222. */
  26223. cleanMatrixWeights(): void;
  26224. private normalizeSkinFourWeights;
  26225. private normalizeSkinWeightsAndExtra;
  26226. /**
  26227. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26228. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26229. * the user know there was an issue with importing the mesh
  26230. * @returns a validation object with skinned, valid and report string
  26231. */
  26232. validateSkinning(): {
  26233. skinned: boolean;
  26234. valid: boolean;
  26235. report: string;
  26236. };
  26237. /** @hidden */
  26238. _checkDelayState(): Mesh;
  26239. private _queueLoad;
  26240. /**
  26241. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26242. * A mesh is in the frustum if its bounding box intersects the frustum
  26243. * @param frustumPlanes defines the frustum to test
  26244. * @returns true if the mesh is in the frustum planes
  26245. */
  26246. isInFrustum(frustumPlanes: Plane[]): boolean;
  26247. /**
  26248. * Sets the mesh material by the material or multiMaterial `id` property
  26249. * @param id is a string identifying the material or the multiMaterial
  26250. * @returns the current mesh
  26251. */
  26252. setMaterialByID(id: string): Mesh;
  26253. /**
  26254. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26255. * @returns an array of IAnimatable
  26256. */
  26257. getAnimatables(): IAnimatable[];
  26258. /**
  26259. * Modifies the mesh geometry according to the passed transformation matrix.
  26260. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26261. * The mesh normals are modified using the same transformation.
  26262. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26263. * @param transform defines the transform matrix to use
  26264. * @see http://doc.babylonjs.com/resources/baking_transformations
  26265. * @returns the current mesh
  26266. */
  26267. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26268. /**
  26269. * Modifies the mesh geometry according to its own current World Matrix.
  26270. * The mesh World Matrix is then reset.
  26271. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26272. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26273. * @see http://doc.babylonjs.com/resources/baking_transformations
  26274. * @returns the current mesh
  26275. */
  26276. bakeCurrentTransformIntoVertices(): Mesh;
  26277. /** @hidden */
  26278. readonly _positions: Nullable<Vector3[]>;
  26279. /** @hidden */
  26280. _resetPointsArrayCache(): Mesh;
  26281. /** @hidden */
  26282. _generatePointsArray(): boolean;
  26283. /**
  26284. * Returns a new Mesh object generated from the current mesh properties.
  26285. * This method must not get confused with createInstance()
  26286. * @param name is a string, the name given to the new mesh
  26287. * @param newParent can be any Node object (default `null`)
  26288. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26289. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26290. * @returns a new mesh
  26291. */
  26292. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26293. /**
  26294. * Releases resources associated with this mesh.
  26295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26297. */
  26298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26299. /**
  26300. * Modifies the mesh geometry according to a displacement map.
  26301. * 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.
  26302. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26303. * @param url is a string, the URL from the image file is to be downloaded.
  26304. * @param minHeight is the lower limit of the displacement.
  26305. * @param maxHeight is the upper limit of the displacement.
  26306. * @param 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.
  26307. * @param uvOffset is an optional vector2 used to offset UV.
  26308. * @param uvScale is an optional vector2 used to scale UV.
  26309. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26310. * @returns the Mesh.
  26311. */
  26312. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26313. /**
  26314. * Modifies the mesh geometry according to a displacementMap buffer.
  26315. * 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.
  26316. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26317. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26318. * @param heightMapWidth is the width of the buffer image.
  26319. * @param heightMapHeight is the height of the buffer image.
  26320. * @param minHeight is the lower limit of the displacement.
  26321. * @param maxHeight is the upper limit of the displacement.
  26322. * @param 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.
  26323. * @param uvOffset is an optional vector2 used to offset UV.
  26324. * @param uvScale is an optional vector2 used to scale UV.
  26325. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  26326. * @returns the Mesh.
  26327. */
  26328. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26329. /**
  26330. * Modify the mesh to get a flat shading rendering.
  26331. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26332. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26333. * @returns current mesh
  26334. */
  26335. convertToFlatShadedMesh(): Mesh;
  26336. /**
  26337. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26338. * In other words, more vertices, no more indices and a single bigger VBO.
  26339. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26340. * @returns current mesh
  26341. */
  26342. convertToUnIndexedMesh(): Mesh;
  26343. /**
  26344. * Inverses facet orientations.
  26345. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26346. * @param flipNormals will also inverts the normals
  26347. * @returns current mesh
  26348. */
  26349. flipFaces(flipNormals?: boolean): Mesh;
  26350. /**
  26351. * Creates a new InstancedMesh object from the mesh model.
  26352. * Warning : this method is not supported for Line mesh and LineSystem
  26353. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26354. * @param name defines the name of the new instance
  26355. * @returns a new InstancedMesh
  26356. */
  26357. createInstance(name: string): InstancedMesh;
  26358. /**
  26359. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26360. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26361. * @returns the current mesh
  26362. */
  26363. synchronizeInstances(): Mesh;
  26364. /**
  26365. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26366. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26367. * This should be used together with the simplification to avoid disappearing triangles.
  26368. * @param successCallback an optional success callback to be called after the optimization finished.
  26369. * @returns the current mesh
  26370. */
  26371. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26372. /**
  26373. * Serialize current mesh
  26374. * @param serializationObject defines the object which will receive the serialization data
  26375. */
  26376. serialize(serializationObject: any): void;
  26377. /** @hidden */
  26378. _syncGeometryWithMorphTargetManager(): void;
  26379. /**
  26380. * Returns a new Mesh object parsed from the source provided.
  26381. * @param parsedMesh is the source
  26382. * @param scene defines the hosting scene
  26383. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26384. * @returns a new Mesh
  26385. */
  26386. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26387. /**
  26388. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26389. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26390. * @param name defines the name of the mesh to create
  26391. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26392. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26393. * @param closePath creates a seam between the first and the last points of each path of the path array
  26394. * @param offset is taken in account only if the `pathArray` is containing a single path
  26395. * @param scene defines the hosting scene
  26396. * @param updatable defines if the mesh must be flagged as updatable
  26397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26398. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  26399. * @returns a new Mesh
  26400. */
  26401. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26402. /**
  26403. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26404. * @param name defines the name of the mesh to create
  26405. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26406. * @param 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
  26407. * @param scene defines the hosting scene
  26408. * @param updatable defines if the mesh must be flagged as updatable
  26409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26410. * @returns a new Mesh
  26411. */
  26412. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26413. /**
  26414. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26415. * @param name defines the name of the mesh to create
  26416. * @param size sets the size (float) of each box side (default 1)
  26417. * @param scene defines the hosting scene
  26418. * @param updatable defines if the mesh must be flagged as updatable
  26419. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26420. * @returns a new Mesh
  26421. */
  26422. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26423. /**
  26424. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26425. * @param name defines the name of the mesh to create
  26426. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26427. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26428. * @param scene defines the hosting scene
  26429. * @param updatable defines if the mesh must be flagged as updatable
  26430. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26431. * @returns a new Mesh
  26432. */
  26433. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26434. /**
  26435. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26436. * @param name defines the name of the mesh to create
  26437. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26438. * @param diameterTop set the top cap diameter (floats, default 1)
  26439. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26440. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26441. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26442. * @param scene defines the hosting scene
  26443. * @param updatable defines if the mesh must be flagged as updatable
  26444. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26445. * @returns a new Mesh
  26446. */
  26447. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26448. /**
  26449. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26450. * @param name defines the name of the mesh to create
  26451. * @param diameter sets the diameter size (float) of the torus (default 1)
  26452. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26453. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26454. * @param scene defines the hosting scene
  26455. * @param updatable defines if the mesh must be flagged as updatable
  26456. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26457. * @returns a new Mesh
  26458. */
  26459. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26460. /**
  26461. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26462. * @param name defines the name of the mesh to create
  26463. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26464. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26465. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26466. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26467. * @param p the number of windings on X axis (positive integers, default 2)
  26468. * @param q the number of windings on Y axis (positive integers, default 3)
  26469. * @param scene defines the hosting scene
  26470. * @param updatable defines if the mesh must be flagged as updatable
  26471. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26472. * @returns a new Mesh
  26473. */
  26474. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26475. /**
  26476. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26477. * @param name defines the name of the mesh to create
  26478. * @param points is an array successive Vector3
  26479. * @param scene defines the hosting scene
  26480. * @param updatable defines if the mesh must be flagged as updatable
  26481. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  26482. * @returns a new Mesh
  26483. */
  26484. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26485. /**
  26486. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26487. * @param name defines the name of the mesh to create
  26488. * @param points is an array successive Vector3
  26489. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26490. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26491. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26492. * @param scene defines the hosting scene
  26493. * @param updatable defines if the mesh must be flagged as updatable
  26494. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  26495. * @returns a new Mesh
  26496. */
  26497. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26498. /**
  26499. * Creates a polygon mesh.
  26500. * Please consider using the same method from the MeshBuilder class instead.
  26501. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26502. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  26503. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26504. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26505. * Remember you can only change the shape positions, not their number when updating a polygon.
  26506. */
  26507. /**
  26508. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26509. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26510. * @param name defines the name of the mesh to create
  26511. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  26512. * @param scene defines the hosting scene
  26513. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26514. * @param updatable defines if the mesh must be flagged as updatable
  26515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26516. * @returns a new Mesh
  26517. */
  26518. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26519. /**
  26520. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26521. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26522. * @param name defines the name of the mesh to create
  26523. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  26524. * @param depth defines the height of extrusion
  26525. * @param scene defines the hosting scene
  26526. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26527. * @param updatable defines if the mesh must be flagged as updatable
  26528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26529. * @returns a new Mesh
  26530. */
  26531. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26532. /**
  26533. * Creates an extruded shape mesh.
  26534. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  26535. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26536. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26537. * @param name defines the name of the mesh to create
  26538. * @param 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 extruded along the Z axis
  26539. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26540. * @param scale is the value to scale the shape
  26541. * @param rotation 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
  26542. * @param 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
  26543. * @param scene defines the hosting scene
  26544. * @param updatable defines if the mesh must be flagged as updatable
  26545. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26546. * @param 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/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  26547. * @returns a new Mesh
  26548. */
  26549. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26550. /**
  26551. * Creates an custom extruded shape mesh.
  26552. * The custom extrusion is a parametric shape.
  26553. * It has no predefined shape. Its final shape will depend on the input parameters.
  26554. * Please consider using the same method from the MeshBuilder class instead
  26555. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26556. * @param name defines the name of the mesh to create
  26557. * @param 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 extruded along the Z axis
  26558. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26559. * @param scaleFunction is a custom Javascript function called on each path point
  26560. * @param rotationFunction is a custom Javascript function called on each path point
  26561. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26562. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26563. * @param 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
  26564. * @param scene defines the hosting scene
  26565. * @param updatable defines if the mesh must be flagged as updatable
  26566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26567. * @param 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/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  26568. * @returns a new Mesh
  26569. */
  26570. 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;
  26571. /**
  26572. * Creates lathe mesh.
  26573. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26574. * Please consider using the same method from the MeshBuilder class instead
  26575. * @param name defines the name of the mesh to create
  26576. * @param 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 rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  26577. * @param radius is the radius value of the lathe
  26578. * @param tessellation is the side number of the lathe.
  26579. * @param scene defines the hosting scene
  26580. * @param updatable defines if the mesh must be flagged as updatable
  26581. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26582. * @returns a new Mesh
  26583. */
  26584. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26585. /**
  26586. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26587. * @param name defines the name of the mesh to create
  26588. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26589. * @param scene defines the hosting scene
  26590. * @param updatable defines if the mesh must be flagged as updatable
  26591. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26592. * @returns a new Mesh
  26593. */
  26594. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26595. /**
  26596. * Creates a ground mesh.
  26597. * Please consider using the same method from the MeshBuilder class instead
  26598. * @param name defines the name of the mesh to create
  26599. * @param width set the width of the ground
  26600. * @param height set the height of the ground
  26601. * @param subdivisions sets the number of subdivisions per side
  26602. * @param scene defines the hosting scene
  26603. * @param updatable defines if the mesh must be flagged as updatable
  26604. * @returns a new Mesh
  26605. */
  26606. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26607. /**
  26608. * Creates a tiled ground mesh.
  26609. * Please consider using the same method from the MeshBuilder class instead
  26610. * @param name defines the name of the mesh to create
  26611. * @param xmin set the ground minimum X coordinate
  26612. * @param zmin set the ground minimum Y coordinate
  26613. * @param xmax set the ground maximum X coordinate
  26614. * @param zmax set the ground maximum Z coordinate
  26615. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  26616. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  26617. * @param scene defines the hosting scene
  26618. * @param updatable defines if the mesh must be flagged as updatable
  26619. * @returns a new Mesh
  26620. */
  26621. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26622. w: number;
  26623. h: number;
  26624. }, precision: {
  26625. w: number;
  26626. h: number;
  26627. }, scene: Scene, updatable?: boolean): Mesh;
  26628. /**
  26629. * Creates a ground mesh from a height map.
  26630. * Please consider using the same method from the MeshBuilder class instead
  26631. * @see http://doc.babylonjs.com/babylon101/height_map
  26632. * @param name defines the name of the mesh to create
  26633. * @param url sets the URL of the height map image resource
  26634. * @param width set the ground width size
  26635. * @param height set the ground height size
  26636. * @param subdivisions sets the number of subdivision per side
  26637. * @param minHeight is the minimum altitude on the ground
  26638. * @param maxHeight is the maximum altitude on the ground
  26639. * @param scene defines the hosting scene
  26640. * @param updatable defines if the mesh must be flagged as updatable
  26641. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26642. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26643. * @returns a new Mesh
  26644. */
  26645. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  26646. /**
  26647. * Creates a tube mesh.
  26648. * The tube is a parametric shape.
  26649. * It has no predefined shape. Its final shape will depend on the input parameters.
  26650. * Please consider using the same method from the MeshBuilder class instead
  26651. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26652. * @param name defines the name of the mesh to create
  26653. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26654. * @param radius sets the tube radius size
  26655. * @param tessellation is the number of sides on the tubular surface
  26656. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. 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
  26657. * @param 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
  26658. * @param scene defines the hosting scene
  26659. * @param updatable defines if the mesh must be flagged as updatable
  26660. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26661. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  26662. * @returns a new Mesh
  26663. */
  26664. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26665. (i: number, distance: number): number;
  26666. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26667. /**
  26668. * Creates a polyhedron mesh.
  26669. * Please consider using the same method from the MeshBuilder class instead.
  26670. * * 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 to choose the wanted type
  26671. * * The parameter `size` (positive float, default 1) sets the polygon size
  26672. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26673. * * 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`
  26674. * * 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
  26675. * * 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)`)
  26676. * * 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
  26677. * * 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
  26678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26681. * @param name defines the name of the mesh to create
  26682. * @param options defines the options used to create the mesh
  26683. * @param scene defines the hosting scene
  26684. * @returns a new Mesh
  26685. */
  26686. static CreatePolyhedron(name: string, options: {
  26687. type?: number;
  26688. size?: number;
  26689. sizeX?: number;
  26690. sizeY?: number;
  26691. sizeZ?: number;
  26692. custom?: any;
  26693. faceUV?: Vector4[];
  26694. faceColors?: Color4[];
  26695. updatable?: boolean;
  26696. sideOrientation?: number;
  26697. }, scene: Scene): Mesh;
  26698. /**
  26699. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26700. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26701. * * 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`)
  26702. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26703. * * 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
  26704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26707. * @param name defines the name of the mesh
  26708. * @param options defines the options used to create the mesh
  26709. * @param scene defines the hosting scene
  26710. * @returns a new Mesh
  26711. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26712. */
  26713. static CreateIcoSphere(name: string, options: {
  26714. radius?: number;
  26715. flat?: boolean;
  26716. subdivisions?: number;
  26717. sideOrientation?: number;
  26718. updatable?: boolean;
  26719. }, scene: Scene): Mesh;
  26720. /**
  26721. * Creates a decal mesh.
  26722. * Please consider using the same method from the MeshBuilder class instead.
  26723. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26724. * @param name defines the name of the mesh
  26725. * @param sourceMesh defines the mesh receiving the decal
  26726. * @param position sets the position of the decal in world coordinates
  26727. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26728. * @param size sets the decal scaling
  26729. * @param angle sets the angle to rotate the decal
  26730. * @returns a new Mesh
  26731. */
  26732. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26733. /**
  26734. * Prepare internal position array for software CPU skinning
  26735. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26736. */
  26737. setPositionsForCPUSkinning(): Float32Array;
  26738. /**
  26739. * Prepare internal normal array for software CPU skinning
  26740. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26741. */
  26742. setNormalsForCPUSkinning(): Float32Array;
  26743. /**
  26744. * Updates the vertex buffer by applying transformation from the bones
  26745. * @param skeleton defines the skeleton to apply to current mesh
  26746. * @returns the current mesh
  26747. */
  26748. applySkeleton(skeleton: Skeleton): Mesh;
  26749. /**
  26750. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  26751. * @param meshes defines the list of meshes to scan
  26752. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26753. */
  26754. static MinMax(meshes: AbstractMesh[]): {
  26755. min: Vector3;
  26756. max: Vector3;
  26757. };
  26758. /**
  26759. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26760. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26761. * @returns a vector3
  26762. */
  26763. static Center(meshesOrMinMaxVector: {
  26764. min: Vector3;
  26765. max: Vector3;
  26766. } | AbstractMesh[]): Vector3;
  26767. /**
  26768. * Merge the array of meshes into a single mesh for performance reasons.
  26769. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26770. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26771. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26772. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26773. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26774. * @returns a new mesh
  26775. */
  26776. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  26777. }
  26778. }
  26779. declare module BABYLON {
  26780. /**
  26781. * Define an interface for all classes that will get and set the data on vertices
  26782. */
  26783. interface IGetSetVerticesData {
  26784. /**
  26785. * Gets a boolean indicating if specific vertex data is present
  26786. * @param kind defines the vertex data kind to use
  26787. * @returns true is data kind is present
  26788. */
  26789. isVerticesDataPresent(kind: string): boolean;
  26790. /**
  26791. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26792. * @param kind defines the data kind (Position, normal, etc...)
  26793. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26794. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26795. * @returns a float array containing vertex data
  26796. */
  26797. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26798. /**
  26799. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26800. * @param copyWhenShared If 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.
  26801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26802. * @returns the indices array or an empty array if the mesh has no geometry
  26803. */
  26804. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26805. /**
  26806. * Set specific vertex data
  26807. * @param kind defines the data kind (Position, normal, etc...)
  26808. * @param data defines the vertex data to use
  26809. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26810. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26811. */
  26812. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26813. /**
  26814. * Update a specific associated vertex buffer
  26815. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26816. * - BABYLON.VertexBuffer.PositionKind
  26817. * - BABYLON.VertexBuffer.UVKind
  26818. * - BABYLON.VertexBuffer.UV2Kind
  26819. * - BABYLON.VertexBuffer.UV3Kind
  26820. * - BABYLON.VertexBuffer.UV4Kind
  26821. * - BABYLON.VertexBuffer.UV5Kind
  26822. * - BABYLON.VertexBuffer.UV6Kind
  26823. * - BABYLON.VertexBuffer.ColorKind
  26824. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26825. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26826. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26827. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26828. * @param data defines the data source
  26829. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26830. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  26831. */
  26832. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26833. /**
  26834. * Creates a new index buffer
  26835. * @param indices defines the indices to store in the index buffer
  26836. * @param totalVertices defines the total number of vertices (could be null)
  26837. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26838. */
  26839. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26840. }
  26841. /**
  26842. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26843. */
  26844. class VertexData {
  26845. /**
  26846. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26847. */
  26848. positions: Nullable<FloatArray>;
  26849. /**
  26850. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26851. */
  26852. normals: Nullable<FloatArray>;
  26853. /**
  26854. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26855. */
  26856. tangents: Nullable<FloatArray>;
  26857. /**
  26858. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26859. */
  26860. uvs: Nullable<FloatArray>;
  26861. /**
  26862. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26863. */
  26864. uvs2: Nullable<FloatArray>;
  26865. /**
  26866. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26867. */
  26868. uvs3: Nullable<FloatArray>;
  26869. /**
  26870. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26871. */
  26872. uvs4: Nullable<FloatArray>;
  26873. /**
  26874. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26875. */
  26876. uvs5: Nullable<FloatArray>;
  26877. /**
  26878. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26879. */
  26880. uvs6: Nullable<FloatArray>;
  26881. /**
  26882. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26883. */
  26884. colors: Nullable<FloatArray>;
  26885. /**
  26886. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  26887. */
  26888. matricesIndices: Nullable<FloatArray>;
  26889. /**
  26890. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26891. */
  26892. matricesWeights: Nullable<FloatArray>;
  26893. /**
  26894. * An array extending the number of possible indices
  26895. */
  26896. matricesIndicesExtra: Nullable<FloatArray>;
  26897. /**
  26898. * An array extending the number of possible weights when the number of indices is extended
  26899. */
  26900. matricesWeightsExtra: Nullable<FloatArray>;
  26901. /**
  26902. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26903. */
  26904. indices: Nullable<IndicesArray>;
  26905. /**
  26906. * Uses the passed data array to set the set the values for the specified kind of data
  26907. * @param data a linear array of floating numbers
  26908. * @param kind the type of data that is being set, eg positions, colors etc
  26909. */
  26910. set(data: FloatArray, kind: string): void;
  26911. /**
  26912. * Associates the vertexData to the passed Mesh.
  26913. * Sets it as updatable or not (default `false`)
  26914. * @param mesh the mesh the vertexData is applied to
  26915. * @param updatable when used and having the value true allows new data to update the vertexData
  26916. * @returns the VertexData
  26917. */
  26918. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26919. /**
  26920. * Associates the vertexData to the passed Geometry.
  26921. * Sets it as updatable or not (default `false`)
  26922. * @param geometry the geometry the vertexData is applied to
  26923. * @param updatable when used and having the value true allows new data to update the vertexData
  26924. * @returns VertexData
  26925. */
  26926. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26927. /**
  26928. * Updates the associated mesh
  26929. * @param mesh the mesh to be updated
  26930. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26931. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  26932. * @returns VertexData
  26933. */
  26934. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  26935. /**
  26936. * Updates the associated geometry
  26937. * @param geometry the geometry to be updated
  26938. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26939. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  26940. * @returns VertexData.
  26941. */
  26942. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  26943. private _applyTo;
  26944. private _update;
  26945. /**
  26946. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26947. * @param matrix the transforming matrix
  26948. * @returns the VertexData
  26949. */
  26950. transform(matrix: Matrix): VertexData;
  26951. /**
  26952. * Merges the passed VertexData into the current one
  26953. * @param other the VertexData to be merged into the current one
  26954. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26955. * @returns the modified VertexData
  26956. */
  26957. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26958. private _mergeElement;
  26959. private _validate;
  26960. /**
  26961. * Serializes the VertexData
  26962. * @returns a serialized object
  26963. */
  26964. serialize(): any;
  26965. /**
  26966. * Extracts the vertexData from a mesh
  26967. * @param mesh the mesh from which to extract the VertexData
  26968. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26969. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26970. * @returns the object VertexData associated to the passed mesh
  26971. */
  26972. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26973. /**
  26974. * Extracts the vertexData from the geometry
  26975. * @param geometry the geometry from which to extract the VertexData
  26976. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26977. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26978. * @returns the object VertexData associated to the passed mesh
  26979. */
  26980. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26981. private static _ExtractFrom;
  26982. /**
  26983. * Creates the VertexData for a Ribbon
  26984. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26985. * * pathArray array of paths, each of which an array of successive Vector3
  26986. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26987. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26988. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  26989. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26990. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26991. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26992. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26993. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26994. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26995. * @returns the VertexData of the ribbon
  26996. */
  26997. static CreateRibbon(options: {
  26998. pathArray: Vector3[][];
  26999. closeArray?: boolean;
  27000. closePath?: boolean;
  27001. offset?: number;
  27002. sideOrientation?: number;
  27003. frontUVs?: Vector4;
  27004. backUVs?: Vector4;
  27005. invertUV?: boolean;
  27006. uvs?: Vector2[];
  27007. colors?: Color4[];
  27008. }): VertexData;
  27009. /**
  27010. * Creates the VertexData for a box
  27011. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27012. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27013. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27014. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27015. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27016. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27017. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27018. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27019. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27020. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27021. * @returns the VertexData of the box
  27022. */
  27023. static CreateBox(options: {
  27024. size?: number;
  27025. width?: number;
  27026. height?: number;
  27027. depth?: number;
  27028. faceUV?: Vector4[];
  27029. faceColors?: Color4[];
  27030. sideOrientation?: number;
  27031. frontUVs?: Vector4;
  27032. backUVs?: Vector4;
  27033. }): VertexData;
  27034. /**
  27035. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27037. * * segments sets the number of horizontal strips optional, default 32
  27038. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27039. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27040. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27041. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27042. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  27043. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  27044. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27045. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27046. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27047. * @returns the VertexData of the ellipsoid
  27048. */
  27049. static CreateSphere(options: {
  27050. segments?: number;
  27051. diameter?: number;
  27052. diameterX?: number;
  27053. diameterY?: number;
  27054. diameterZ?: number;
  27055. arc?: number;
  27056. slice?: number;
  27057. sideOrientation?: number;
  27058. frontUVs?: Vector4;
  27059. backUVs?: Vector4;
  27060. }): VertexData;
  27061. /**
  27062. * Creates the VertexData for a cylinder, cone or prism
  27063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27064. * * height sets the height (y direction) of the cylinder, optional, default 2
  27065. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27066. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27067. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27068. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27069. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27070. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  27071. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27072. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27073. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27074. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27075. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27076. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27077. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27078. * @returns the VertexData of the cylinder, cone or prism
  27079. */
  27080. static CreateCylinder(options: {
  27081. height?: number;
  27082. diameterTop?: number;
  27083. diameterBottom?: number;
  27084. diameter?: number;
  27085. tessellation?: number;
  27086. subdivisions?: number;
  27087. arc?: number;
  27088. faceColors?: Color4[];
  27089. faceUV?: Vector4[];
  27090. hasRings?: boolean;
  27091. enclose?: boolean;
  27092. sideOrientation?: number;
  27093. frontUVs?: Vector4;
  27094. backUVs?: Vector4;
  27095. }): VertexData;
  27096. /**
  27097. * Creates the VertexData for a torus
  27098. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27099. * * diameter the diameter of the torus, optional default 1
  27100. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27101. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27102. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27103. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27104. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27105. * @returns the VertexData of the torus
  27106. */
  27107. static CreateTorus(options: {
  27108. diameter?: number;
  27109. thickness?: number;
  27110. tessellation?: number;
  27111. sideOrientation?: number;
  27112. frontUVs?: Vector4;
  27113. backUVs?: Vector4;
  27114. }): VertexData;
  27115. /**
  27116. * Creates the VertexData of the LineSystem
  27117. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27118. * - lines an array of lines, each line being an array of successive Vector3
  27119. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27120. * @returns the VertexData of the LineSystem
  27121. */
  27122. static CreateLineSystem(options: {
  27123. lines: Vector3[][];
  27124. colors?: Nullable<Color4[][]>;
  27125. }): VertexData;
  27126. /**
  27127. * Create the VertexData for a DashedLines
  27128. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27129. * - points an array successive Vector3
  27130. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27131. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27132. * - dashNb the intended total number of dashes, optional, default 200
  27133. * @returns the VertexData for the DashedLines
  27134. */
  27135. static CreateDashedLines(options: {
  27136. points: Vector3[];
  27137. dashSize?: number;
  27138. gapSize?: number;
  27139. dashNb?: number;
  27140. }): VertexData;
  27141. /**
  27142. * Creates the VertexData for a Ground
  27143. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27144. * - width the width (x direction) of the ground, optional, default 1
  27145. * - height the height (z direction) of the ground, optional, default 1
  27146. * - subdivisions the number of subdivisions per side, optional, default 1
  27147. * @returns the VertexData of the Ground
  27148. */
  27149. static CreateGround(options: {
  27150. width?: number;
  27151. height?: number;
  27152. subdivisions?: number;
  27153. subdivisionsX?: number;
  27154. subdivisionsY?: number;
  27155. }): VertexData;
  27156. /**
  27157. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27158. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27159. * * xmin the ground minimum X coordinate, optional, default -1
  27160. * * zmin the ground minimum Z coordinate, optional, default -1
  27161. * * xmax the ground maximum X coordinate, optional, default 1
  27162. * * zmax the ground maximum Z coordinate, optional, default 1
  27163. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  27164. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  27165. * @returns the VertexData of the TiledGround
  27166. */
  27167. static CreateTiledGround(options: {
  27168. xmin: number;
  27169. zmin: number;
  27170. xmax: number;
  27171. zmax: number;
  27172. subdivisions?: {
  27173. w: number;
  27174. h: number;
  27175. };
  27176. precision?: {
  27177. w: number;
  27178. h: number;
  27179. };
  27180. }): VertexData;
  27181. /**
  27182. * Creates the VertexData of the Ground designed from a heightmap
  27183. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27184. * * width the width (x direction) of the ground
  27185. * * height the height (z direction) of the ground
  27186. * * subdivisions the number of subdivisions per side
  27187. * * minHeight the minimum altitude on the ground, optional, default 0
  27188. * * maxHeight the maximum altitude on the ground, optional default 1
  27189. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27190. * * buffer the array holding the image color data
  27191. * * bufferWidth the width of image
  27192. * * bufferHeight the height of image
  27193. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27194. * @returns the VertexData of the Ground designed from a heightmap
  27195. */
  27196. static CreateGroundFromHeightMap(options: {
  27197. width: number;
  27198. height: number;
  27199. subdivisions: number;
  27200. minHeight: number;
  27201. maxHeight: number;
  27202. colorFilter: Color3;
  27203. buffer: Uint8Array;
  27204. bufferWidth: number;
  27205. bufferHeight: number;
  27206. alphaFilter: number;
  27207. }): VertexData;
  27208. /**
  27209. * Creates the VertexData for a Plane
  27210. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27211. * * size sets the width and height of the plane to the value of size, optional default 1
  27212. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27213. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27214. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27215. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27216. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27217. * @returns the VertexData of the box
  27218. */
  27219. static CreatePlane(options: {
  27220. size?: number;
  27221. width?: number;
  27222. height?: number;
  27223. sideOrientation?: number;
  27224. frontUVs?: Vector4;
  27225. backUVs?: Vector4;
  27226. }): VertexData;
  27227. /**
  27228. * Creates the VertexData of the Disc or regular Polygon
  27229. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27230. * * radius the radius of the disc, optional default 0.5
  27231. * * tessellation the number of polygon sides, optional, default 64
  27232. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  27233. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27234. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27235. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27236. * @returns the VertexData of the box
  27237. */
  27238. static CreateDisc(options: {
  27239. radius?: number;
  27240. tessellation?: number;
  27241. arc?: number;
  27242. sideOrientation?: number;
  27243. frontUVs?: Vector4;
  27244. backUVs?: Vector4;
  27245. }): VertexData;
  27246. /**
  27247. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27248. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27249. * @param polygon a mesh built from polygonTriangulation.build()
  27250. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27251. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27252. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27253. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27254. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27255. * @returns the VertexData of the Polygon
  27256. */
  27257. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27258. /**
  27259. * Creates the VertexData of the IcoSphere
  27260. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27261. * * radius the radius of the IcoSphere, optional default 1
  27262. * * radiusX allows stretching in the x direction, optional, default radius
  27263. * * radiusY allows stretching in the y direction, optional, default radius
  27264. * * radiusZ allows stretching in the z direction, optional, default radius
  27265. * * flat when true creates a flat shaded mesh, optional, default true
  27266. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27267. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27268. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27269. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27270. * @returns the VertexData of the IcoSphere
  27271. */
  27272. static CreateIcoSphere(options: {
  27273. radius?: number;
  27274. radiusX?: number;
  27275. radiusY?: number;
  27276. radiusZ?: number;
  27277. flat?: boolean;
  27278. subdivisions?: number;
  27279. sideOrientation?: number;
  27280. frontUVs?: Vector4;
  27281. backUVs?: Vector4;
  27282. }): VertexData;
  27283. /**
  27284. * Creates the VertexData for a Polyhedron
  27285. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27286. * * type provided types are:
  27287. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27288. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  27289. * * size the size of the IcoSphere, optional default 1
  27290. * * sizeX allows stretching in the x direction, optional, default size
  27291. * * sizeY allows stretching in the y direction, optional, default size
  27292. * * sizeZ allows stretching in the z direction, optional, default size
  27293. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  27294. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27295. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27296. * * flat when true creates a flat shaded mesh, optional, default true
  27297. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27298. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27299. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27300. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27301. * @returns the VertexData of the Polyhedron
  27302. */
  27303. static CreatePolyhedron(options: {
  27304. type?: number;
  27305. size?: number;
  27306. sizeX?: number;
  27307. sizeY?: number;
  27308. sizeZ?: number;
  27309. custom?: any;
  27310. faceUV?: Vector4[];
  27311. faceColors?: Color4[];
  27312. flat?: boolean;
  27313. sideOrientation?: number;
  27314. frontUVs?: Vector4;
  27315. backUVs?: Vector4;
  27316. }): VertexData;
  27317. /**
  27318. * Creates the VertexData for a TorusKnot
  27319. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27320. * * radius the radius of the torus knot, optional, default 2
  27321. * * tube the thickness of the tube, optional, default 0.5
  27322. * * radialSegments the number of sides on each tube segments, optional, default 32
  27323. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27324. * * p the number of windings around the z axis, optional, default 2
  27325. * * q the number of windings around the x axis, optional, default 3
  27326. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27327. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27328. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27329. * @returns the VertexData of the Torus Knot
  27330. */
  27331. static CreateTorusKnot(options: {
  27332. radius?: number;
  27333. tube?: number;
  27334. radialSegments?: number;
  27335. tubularSegments?: number;
  27336. p?: number;
  27337. q?: number;
  27338. sideOrientation?: number;
  27339. frontUVs?: Vector4;
  27340. backUVs?: Vector4;
  27341. }): VertexData;
  27342. /**
  27343. * Compute normals for given positions and indices
  27344. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27345. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27346. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27347. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27348. * * facetNormals : optional array of facet normals (vector3)
  27349. * * facetPositions : optional array of facet positions (vector3)
  27350. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27351. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27352. * * bInfo : optional bounding info, required for facetPartitioning computation
  27353. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27354. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27355. * * useRightHandedSystem: optional boolean to for right handed system computation
  27356. * * depthSort : optional boolean to enable the facet depth sort computation
  27357. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27358. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27359. */
  27360. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27361. facetNormals?: any;
  27362. facetPositions?: any;
  27363. facetPartitioning?: any;
  27364. ratio?: number;
  27365. bInfo?: any;
  27366. bbSize?: Vector3;
  27367. subDiv?: any;
  27368. useRightHandedSystem?: boolean;
  27369. depthSort?: boolean;
  27370. distanceTo?: Vector3;
  27371. depthSortedFacets?: any;
  27372. }): void;
  27373. private static _ComputeSides;
  27374. /**
  27375. * Applies VertexData created from the imported parameters to the geometry
  27376. * @param parsedVertexData the parsed data from an imported file
  27377. * @param geometry the geometry to apply the VertexData to
  27378. */
  27379. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27380. }
  27381. }
  27382. declare module BABYLON {
  27383. /**
  27384. * Class containing static functions to help procedurally build meshes
  27385. */
  27386. class MeshBuilder {
  27387. private static updateSideOrientation;
  27388. /**
  27389. * Creates a box mesh
  27390. * * The parameter `size` sets the size (float) of each box side (default 1)
  27391. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27392. * * 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)
  27393. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27397. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27398. * @param name defines the name of the mesh
  27399. * @param options defines the options used to create the mesh
  27400. * @param scene defines the hosting scene
  27401. * @returns the box mesh
  27402. */
  27403. static CreateBox(name: string, options: {
  27404. size?: number;
  27405. width?: number;
  27406. height?: number;
  27407. depth?: number;
  27408. faceUV?: Vector4[];
  27409. faceColors?: Color4[];
  27410. sideOrientation?: number;
  27411. frontUVs?: Vector4;
  27412. backUVs?: Vector4;
  27413. updatable?: boolean;
  27414. }, scene?: Nullable<Scene>): Mesh;
  27415. /**
  27416. * Creates a sphere mesh
  27417. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27418. * * 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 of `diameter`)
  27419. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27420. * * 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
  27421. * * 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)
  27422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27425. * @param name defines the name of the mesh
  27426. * @param options defines the options used to create the mesh
  27427. * @param scene defines the hosting scene
  27428. * @returns the sphere mesh
  27429. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27430. */
  27431. static CreateSphere(name: string, options: {
  27432. segments?: number;
  27433. diameter?: number;
  27434. diameterX?: number;
  27435. diameterY?: number;
  27436. diameterZ?: number;
  27437. arc?: number;
  27438. slice?: number;
  27439. sideOrientation?: number;
  27440. frontUVs?: Vector4;
  27441. backUVs?: Vector4;
  27442. updatable?: boolean;
  27443. }, scene: any): Mesh;
  27444. /**
  27445. * Creates a plane polygonal mesh. By default, this is a disc
  27446. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27447. * * 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
  27448. * * 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
  27449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27452. * @param name defines the name of the mesh
  27453. * @param options defines the options used to create the mesh
  27454. * @param scene defines the hosting scene
  27455. * @returns the plane polygonal mesh
  27456. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27457. */
  27458. static CreateDisc(name: string, options: {
  27459. radius?: number;
  27460. tessellation?: number;
  27461. arc?: number;
  27462. updatable?: boolean;
  27463. sideOrientation?: number;
  27464. frontUVs?: Vector4;
  27465. backUVs?: Vector4;
  27466. }, scene?: Nullable<Scene>): Mesh;
  27467. /**
  27468. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27469. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27470. * * 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 of `radius`)
  27471. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27472. * * 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
  27473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27476. * @param name defines the name of the mesh
  27477. * @param options defines the options used to create the mesh
  27478. * @param scene defines the hosting scene
  27479. * @returns the icosahedron mesh
  27480. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27481. */
  27482. static CreateIcoSphere(name: string, options: {
  27483. radius?: number;
  27484. radiusX?: number;
  27485. radiusY?: number;
  27486. radiusZ?: number;
  27487. flat?: boolean;
  27488. subdivisions?: number;
  27489. sideOrientation?: number;
  27490. frontUVs?: Vector4;
  27491. backUVs?: Vector4;
  27492. updatable?: boolean;
  27493. }, scene: Scene): Mesh;
  27494. /**
  27495. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27496. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  27497. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  27498. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  27499. * * 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
  27500. * * 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
  27501. * * 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
  27502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27505. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  27506. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  27507. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  27508. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  27509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27510. * @param name defines the name of the mesh
  27511. * @param options defines the options used to create the mesh
  27512. * @param scene defines the hosting scene
  27513. * @returns the ribbon mesh
  27514. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  27515. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27516. */
  27517. static CreateRibbon(name: string, options: {
  27518. pathArray: Vector3[][];
  27519. closeArray?: boolean;
  27520. closePath?: boolean;
  27521. offset?: number;
  27522. updatable?: boolean;
  27523. sideOrientation?: number;
  27524. frontUVs?: Vector4;
  27525. backUVs?: Vector4;
  27526. instance?: Mesh;
  27527. invertUV?: boolean;
  27528. uvs?: Vector2[];
  27529. colors?: Color4[];
  27530. }, scene?: Nullable<Scene>): Mesh;
  27531. /**
  27532. * Creates a cylinder or a cone mesh
  27533. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  27534. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  27535. * * 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.
  27536. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  27537. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  27538. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  27539. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  27540. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  27541. * * 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).
  27542. * * 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
  27543. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  27544. * * 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
  27545. * * 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.
  27546. * * If `enclose` is false, a ring surface is one element.
  27547. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  27548. * * 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
  27549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27552. * @param name defines the name of the mesh
  27553. * @param options defines the options used to create the mesh
  27554. * @param scene defines the hosting scene
  27555. * @returns the cylinder mesh
  27556. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  27557. */
  27558. static CreateCylinder(name: string, options: {
  27559. height?: number;
  27560. diameterTop?: number;
  27561. diameterBottom?: number;
  27562. diameter?: number;
  27563. tessellation?: number;
  27564. subdivisions?: number;
  27565. arc?: number;
  27566. faceColors?: Color4[];
  27567. faceUV?: Vector4[];
  27568. updatable?: boolean;
  27569. hasRings?: boolean;
  27570. enclose?: boolean;
  27571. sideOrientation?: number;
  27572. frontUVs?: Vector4;
  27573. backUVs?: Vector4;
  27574. }, scene: any): Mesh;
  27575. /**
  27576. * Creates a torus mesh
  27577. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  27578. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  27579. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  27580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27583. * @param name defines the name of the mesh
  27584. * @param options defines the options used to create the mesh
  27585. * @param scene defines the hosting scene
  27586. * @returns the torus mesh
  27587. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  27588. */
  27589. static CreateTorus(name: string, options: {
  27590. diameter?: number;
  27591. thickness?: number;
  27592. tessellation?: number;
  27593. updatable?: boolean;
  27594. sideOrientation?: number;
  27595. frontUVs?: Vector4;
  27596. backUVs?: Vector4;
  27597. }, scene: any): Mesh;
  27598. /**
  27599. * Creates a torus knot mesh
  27600. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  27601. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  27602. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  27603. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  27604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27607. * @param name defines the name of the mesh
  27608. * @param options defines the options used to create the mesh
  27609. * @param scene defines the hosting scene
  27610. * @returns the torus knot mesh
  27611. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  27612. */
  27613. static CreateTorusKnot(name: string, options: {
  27614. radius?: number;
  27615. tube?: number;
  27616. radialSegments?: number;
  27617. tubularSegments?: number;
  27618. p?: number;
  27619. q?: number;
  27620. updatable?: boolean;
  27621. sideOrientation?: number;
  27622. frontUVs?: Vector4;
  27623. backUVs?: Vector4;
  27624. }, scene: any): Mesh;
  27625. /**
  27626. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  27627. * * 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
  27628. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  27629. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  27630. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  27631. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  27632. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  27633. * * 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
  27634. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  27635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27636. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  27637. * @param name defines the name of the new line system
  27638. * @param options defines the options used to create the line system
  27639. * @param scene defines the hosting scene
  27640. * @returns a new line system mesh
  27641. */
  27642. static CreateLineSystem(name: string, options: {
  27643. lines: Vector3[][];
  27644. updatable?: boolean;
  27645. instance?: Nullable<LinesMesh>;
  27646. colors?: Nullable<Color4[][]>;
  27647. useVertexAlpha?: boolean;
  27648. }, scene: Nullable<Scene>): LinesMesh;
  27649. /**
  27650. * Creates a line mesh
  27651. * 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
  27652. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27653. * * The parameter `points` is an array successive Vector3
  27654. * * 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
  27655. * * The optional parameter `colors` is an array of successive Color4, one per line point
  27656. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  27657. * * When updating an instance, remember that only point positions can change, not the number of points
  27658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27659. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  27660. * @param name defines the name of the new line system
  27661. * @param options defines the options used to create the line system
  27662. * @param scene defines the hosting scene
  27663. * @returns a new line mesh
  27664. */
  27665. static CreateLines(name: string, options: {
  27666. points: Vector3[];
  27667. updatable?: boolean;
  27668. instance?: Nullable<LinesMesh>;
  27669. colors?: Color4[];
  27670. useVertexAlpha?: boolean;
  27671. }, scene?: Nullable<Scene>): LinesMesh;
  27672. /**
  27673. * Creates a dashed line mesh
  27674. * * 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
  27675. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27676. * * The parameter `points` is an array successive Vector3
  27677. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  27678. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  27679. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27680. * * 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
  27681. * * When updating an instance, remember that only point positions can change, not the number of points
  27682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27683. * @param name defines the name of the mesh
  27684. * @param options defines the options used to create the mesh
  27685. * @param scene defines the hosting scene
  27686. * @returns the dashed line mesh
  27687. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  27688. */
  27689. static CreateDashedLines(name: string, options: {
  27690. points: Vector3[];
  27691. dashSize?: number;
  27692. gapSize?: number;
  27693. dashNb?: number;
  27694. updatable?: boolean;
  27695. instance?: LinesMesh;
  27696. }, scene?: Nullable<Scene>): LinesMesh;
  27697. /**
  27698. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  27699. * * 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 extruded along the Z axis.
  27700. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27701. * * 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.
  27702. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  27703. * * 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
  27704. * * 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
  27705. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  27706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  27709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27710. * @param name defines the name of the mesh
  27711. * @param options defines the options used to create the mesh
  27712. * @param scene defines the hosting scene
  27713. * @returns the extruded shape mesh
  27714. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27715. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27716. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27717. */
  27718. static ExtrudeShape(name: string, options: {
  27719. shape: Vector3[];
  27720. path: Vector3[];
  27721. scale?: number;
  27722. rotation?: number;
  27723. cap?: number;
  27724. updatable?: boolean;
  27725. sideOrientation?: number;
  27726. frontUVs?: Vector4;
  27727. backUVs?: Vector4;
  27728. instance?: Mesh;
  27729. invertUV?: boolean;
  27730. }, scene?: Nullable<Scene>): Mesh;
  27731. /**
  27732. * Creates an custom extruded shape mesh.
  27733. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  27734. * * 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 extruded along the Z axis.
  27735. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27736. * * 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 and the distance of this point from the begining of the path
  27737. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  27738. * * 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 and the distance of this point from the begining of the path
  27739. * * It must returns a float value that will be the scale value applied to the shape on each path point
  27740. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27741. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  27742. * * 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
  27743. * * 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
  27744. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  27745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27747. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27749. * @param name defines the name of the mesh
  27750. * @param options defines the options used to create the mesh
  27751. * @param scene defines the hosting scene
  27752. * @returns the custom extruded shape mesh
  27753. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  27754. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27755. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27756. */
  27757. static ExtrudeShapeCustom(name: string, options: {
  27758. shape: Vector3[];
  27759. path: Vector3[];
  27760. scaleFunction?: any;
  27761. rotationFunction?: any;
  27762. ribbonCloseArray?: boolean;
  27763. ribbonClosePath?: boolean;
  27764. cap?: number;
  27765. updatable?: boolean;
  27766. sideOrientation?: number;
  27767. frontUVs?: Vector4;
  27768. backUVs?: Vector4;
  27769. instance?: Mesh;
  27770. invertUV?: boolean;
  27771. }, scene: Scene): Mesh;
  27772. /**
  27773. * Creates lathe mesh.
  27774. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  27775. * * 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 rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  27776. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  27777. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  27778. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  27779. * * 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
  27780. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  27781. * * 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
  27782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27786. * @param name defines the name of the mesh
  27787. * @param options defines the options used to create the mesh
  27788. * @param scene defines the hosting scene
  27789. * @returns the lathe mesh
  27790. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  27791. */
  27792. static CreateLathe(name: string, options: {
  27793. shape: Vector3[];
  27794. radius?: number;
  27795. tessellation?: number;
  27796. clip?: number;
  27797. arc?: number;
  27798. closed?: boolean;
  27799. updatable?: boolean;
  27800. sideOrientation?: number;
  27801. frontUVs?: Vector4;
  27802. backUVs?: Vector4;
  27803. cap?: number;
  27804. invertUV?: boolean;
  27805. }, scene: Scene): Mesh;
  27806. /**
  27807. * Creates a plane mesh
  27808. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  27809. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  27810. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  27811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27814. * @param name defines the name of the mesh
  27815. * @param options defines the options used to create the mesh
  27816. * @param scene defines the hosting scene
  27817. * @returns the plane mesh
  27818. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  27819. */
  27820. static CreatePlane(name: string, options: {
  27821. size?: number;
  27822. width?: number;
  27823. height?: number;
  27824. sideOrientation?: number;
  27825. frontUVs?: Vector4;
  27826. backUVs?: Vector4;
  27827. updatable?: boolean;
  27828. sourcePlane?: Plane;
  27829. }, scene: Scene): Mesh;
  27830. /**
  27831. * Creates a ground mesh
  27832. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  27833. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  27834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27835. * @param name defines the name of the mesh
  27836. * @param options defines the options used to create the mesh
  27837. * @param scene defines the hosting scene
  27838. * @returns the ground mesh
  27839. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  27840. */
  27841. static CreateGround(name: string, options: {
  27842. width?: number;
  27843. height?: number;
  27844. subdivisions?: number;
  27845. subdivisionsX?: number;
  27846. subdivisionsY?: number;
  27847. updatable?: boolean;
  27848. }, scene: any): Mesh;
  27849. /**
  27850. * Creates a tiled ground mesh
  27851. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  27852. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  27853. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  27854. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  27855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27856. * @param name defines the name of the mesh
  27857. * @param options defines the options used to create the mesh
  27858. * @param scene defines the hosting scene
  27859. * @returns the tiled ground mesh
  27860. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  27861. */
  27862. static CreateTiledGround(name: string, options: {
  27863. xmin: number;
  27864. zmin: number;
  27865. xmax: number;
  27866. zmax: number;
  27867. subdivisions?: {
  27868. w: number;
  27869. h: number;
  27870. };
  27871. precision?: {
  27872. w: number;
  27873. h: number;
  27874. };
  27875. updatable?: boolean;
  27876. }, scene: Scene): Mesh;
  27877. /**
  27878. * Creates a ground mesh from a height map
  27879. * * The parameter `url` sets the URL of the height map image resource.
  27880. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  27881. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  27882. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  27883. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  27884. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  27885. * * 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).
  27886. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27888. * @param name defines the name of the mesh
  27889. * @param url defines the url to the height map
  27890. * @param options defines the options used to create the mesh
  27891. * @param scene defines the hosting scene
  27892. * @returns the ground mesh
  27893. * @see http://doc.babylonjs.com/babylon101/height_map
  27894. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  27895. */
  27896. static CreateGroundFromHeightMap(name: string, url: string, options: {
  27897. width?: number;
  27898. height?: number;
  27899. subdivisions?: number;
  27900. minHeight?: number;
  27901. maxHeight?: number;
  27902. colorFilter?: Color3;
  27903. alphaFilter?: number;
  27904. updatable?: boolean;
  27905. onReady?: (mesh: GroundMesh) => void;
  27906. }, scene: Scene): GroundMesh;
  27907. /**
  27908. * Creates a polygon mesh
  27909. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  27910. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  27911. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  27914. * * Remember you can only change the shape positions, not their number when updating a polygon
  27915. * @param name defines the name of the mesh
  27916. * @param options defines the options used to create the mesh
  27917. * @param scene defines the hosting scene
  27918. * @returns the polygon mesh
  27919. */
  27920. static CreatePolygon(name: string, options: {
  27921. shape: Vector3[];
  27922. holes?: Vector3[][];
  27923. depth?: number;
  27924. faceUV?: Vector4[];
  27925. faceColors?: Color4[];
  27926. updatable?: boolean;
  27927. sideOrientation?: number;
  27928. frontUVs?: Vector4;
  27929. backUVs?: Vector4;
  27930. }, scene: Scene): Mesh;
  27931. /**
  27932. * Creates an extruded polygon mesh, with depth in the Y direction.
  27933. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  27934. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27935. * @param name defines the name of the mesh
  27936. * @param options defines the options used to create the mesh
  27937. * @param scene defines the hosting scene
  27938. * @returns the polygon mesh
  27939. */
  27940. static ExtrudePolygon(name: string, options: {
  27941. shape: Vector3[];
  27942. holes?: Vector3[][];
  27943. depth?: number;
  27944. faceUV?: Vector4[];
  27945. faceColors?: Color4[];
  27946. updatable?: boolean;
  27947. sideOrientation?: number;
  27948. frontUVs?: Vector4;
  27949. backUVs?: Vector4;
  27950. }, scene: Scene): Mesh;
  27951. /**
  27952. * Creates a tube mesh.
  27953. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27954. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  27955. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  27956. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  27957. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  27958. * * 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. It must return a radius value (positive float)
  27959. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  27960. * * 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
  27961. * * 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
  27962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  27964. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27966. * @param name defines the name of the mesh
  27967. * @param options defines the options used to create the mesh
  27968. * @param scene defines the hosting scene
  27969. * @returns the tube mesh
  27970. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27971. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  27972. */
  27973. static CreateTube(name: string, options: {
  27974. path: Vector3[];
  27975. radius?: number;
  27976. tessellation?: number;
  27977. radiusFunction?: {
  27978. (i: number, distance: number): number;
  27979. };
  27980. cap?: number;
  27981. arc?: number;
  27982. updatable?: boolean;
  27983. sideOrientation?: number;
  27984. frontUVs?: Vector4;
  27985. backUVs?: Vector4;
  27986. instance?: Mesh;
  27987. invertUV?: boolean;
  27988. }, scene: Scene): Mesh;
  27989. /**
  27990. * Creates a polyhedron mesh
  27991. * * 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 to choose the wanted type
  27992. * * The parameter `size` (positive float, default 1) sets the polygon size
  27993. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27994. * * 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`
  27995. * * 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
  27996. * * 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)`)
  27997. * * 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
  27998. * * 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
  27999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28002. * @param name defines the name of the mesh
  28003. * @param options defines the options used to create the mesh
  28004. * @param scene defines the hosting scene
  28005. * @returns the polyhedron mesh
  28006. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28007. */
  28008. static CreatePolyhedron(name: string, options: {
  28009. type?: number;
  28010. size?: number;
  28011. sizeX?: number;
  28012. sizeY?: number;
  28013. sizeZ?: number;
  28014. custom?: any;
  28015. faceUV?: Vector4[];
  28016. faceColors?: Color4[];
  28017. flat?: boolean;
  28018. updatable?: boolean;
  28019. sideOrientation?: number;
  28020. frontUVs?: Vector4;
  28021. backUVs?: Vector4;
  28022. }, scene: Scene): Mesh;
  28023. /**
  28024. * Creates a decal mesh.
  28025. * 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
  28026. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28027. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28028. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28029. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28030. * @param name defines the name of the mesh
  28031. * @param sourceMesh defines the mesh where the decal must be applied
  28032. * @param options defines the options used to create the mesh
  28033. * @param scene defines the hosting scene
  28034. * @returns the decal mesh
  28035. * @see http://doc.babylonjs.com/how_to/decals
  28036. */
  28037. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28038. position?: Vector3;
  28039. normal?: Vector3;
  28040. size?: Vector3;
  28041. angle?: number;
  28042. }): Mesh;
  28043. private static _ExtrudeShapeGeneric;
  28044. }
  28045. }
  28046. declare module BABYLON {
  28047. /**
  28048. * Class used to represent a specific level of detail of a mesh
  28049. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28050. */
  28051. class MeshLODLevel {
  28052. /** Defines the distance where this level should star being displayed */
  28053. distance: number;
  28054. /** Defines the mesh to use to render this level */
  28055. mesh: Nullable<Mesh>;
  28056. /**
  28057. * Creates a new LOD level
  28058. * @param distance defines the distance where this level should star being displayed
  28059. * @param mesh defines the mesh to use to render this level
  28060. */
  28061. constructor(
  28062. /** Defines the distance where this level should star being displayed */
  28063. distance: number,
  28064. /** Defines the mesh to use to render this level */
  28065. mesh: Nullable<Mesh>);
  28066. }
  28067. }
  28068. declare module BABYLON {
  28069. /**
  28070. * A simplifier interface for future simplification implementations
  28071. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28072. */
  28073. interface ISimplifier {
  28074. /**
  28075. * Simplification of a given mesh according to the given settings.
  28076. * Since this requires computation, it is assumed that the function runs async.
  28077. * @param settings The settings of the simplification, including quality and distance
  28078. * @param successCallback A callback that will be called after the mesh was simplified.
  28079. * @param errorCallback in case of an error, this callback will be called. optional.
  28080. */
  28081. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28082. }
  28083. /**
  28084. * Expected simplification settings.
  28085. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28087. */
  28088. interface ISimplificationSettings {
  28089. /**
  28090. * Gets or sets the expected quality
  28091. */
  28092. quality: number;
  28093. /**
  28094. * Gets or sets the distance when this optimized version should be used
  28095. */
  28096. distance: number;
  28097. /**
  28098. * Gets an already optimized mesh
  28099. */
  28100. optimizeMesh?: boolean;
  28101. }
  28102. /**
  28103. * Class used to specify simplification options
  28104. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28105. */
  28106. class SimplificationSettings implements ISimplificationSettings {
  28107. /** expected quality */
  28108. quality: number;
  28109. /** distance when this optimized version should be used */
  28110. distance: number;
  28111. /** already optimized mesh */
  28112. optimizeMesh?: boolean | undefined;
  28113. /**
  28114. * Creates a SimplificationSettings
  28115. * @param quality expected quality
  28116. * @param distance distance when this optimized version should be used
  28117. * @param optimizeMesh already optimized mesh
  28118. */
  28119. constructor(
  28120. /** expected quality */
  28121. quality: number,
  28122. /** distance when this optimized version should be used */
  28123. distance: number,
  28124. /** already optimized mesh */
  28125. optimizeMesh?: boolean | undefined);
  28126. }
  28127. /**
  28128. * Interface used to define a simplification task
  28129. */
  28130. interface ISimplificationTask {
  28131. /**
  28132. * Array of settings
  28133. */
  28134. settings: Array<ISimplificationSettings>;
  28135. /**
  28136. * Simplification type
  28137. */
  28138. simplificationType: SimplificationType;
  28139. /**
  28140. * Mesh to simplify
  28141. */
  28142. mesh: Mesh;
  28143. /**
  28144. * Callback called on success
  28145. */
  28146. successCallback?: () => void;
  28147. /**
  28148. * Defines if parallel processing can be used
  28149. */
  28150. parallelProcessing: boolean;
  28151. }
  28152. /**
  28153. * Queue used to order the simplification tasks
  28154. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28155. */
  28156. class SimplificationQueue {
  28157. private _simplificationArray;
  28158. /**
  28159. * Gets a boolean indicating that the process is still running
  28160. */
  28161. running: boolean;
  28162. /**
  28163. * Creates a new queue
  28164. */
  28165. constructor();
  28166. /**
  28167. * Adds a new simplification task
  28168. * @param task defines a task to add
  28169. */
  28170. addTask(task: ISimplificationTask): void;
  28171. /**
  28172. * Execute next task
  28173. */
  28174. executeNext(): void;
  28175. /**
  28176. * Execute a simplification task
  28177. * @param task defines the task to run
  28178. */
  28179. runSimplification(task: ISimplificationTask): void;
  28180. private getSimplifier;
  28181. }
  28182. /**
  28183. * The implemented types of simplification
  28184. * At the moment only Quadratic Error Decimation is implemented
  28185. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28186. */
  28187. enum SimplificationType {
  28188. /** Quadratic error decimation */
  28189. QUADRATIC = 0
  28190. }
  28191. }
  28192. declare module BABYLON {
  28193. interface Scene {
  28194. /** @hidden (Backing field) */
  28195. _simplificationQueue: SimplificationQueue;
  28196. /**
  28197. * Gets or sets the simplification queue attached to the scene
  28198. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28199. */
  28200. simplificationQueue: SimplificationQueue;
  28201. }
  28202. interface Mesh {
  28203. /**
  28204. * Simplify the mesh according to the given array of settings.
  28205. * Function will return immediately and will simplify async
  28206. * @param settings a collection of simplification settings
  28207. * @param parallelProcessing should all levels calculate parallel or one after the other
  28208. * @param simplificationType the type of simplification to run
  28209. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28210. * @returns the current mesh
  28211. */
  28212. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28213. }
  28214. /**
  28215. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28216. * created in a scene
  28217. */
  28218. class SimplicationQueueSceneComponent implements ISceneComponent {
  28219. /**
  28220. * The component name helpfull to identify the component in the list of scene components.
  28221. */
  28222. readonly name: string;
  28223. /**
  28224. * The scene the component belongs to.
  28225. */
  28226. scene: Scene;
  28227. /**
  28228. * Creates a new instance of the component for the given scene
  28229. * @param scene Defines the scene to register the component in
  28230. */
  28231. constructor(scene: Scene);
  28232. /**
  28233. * Registers the component in a given scene
  28234. */
  28235. register(): void;
  28236. /**
  28237. * Rebuilds the elements related to this component in case of
  28238. * context lost for instance.
  28239. */
  28240. rebuild(): void;
  28241. /**
  28242. * Disposes the component and the associated ressources
  28243. */
  28244. dispose(): void;
  28245. private _beforeCameraUpdate;
  28246. }
  28247. }
  28248. declare module BABYLON {
  28249. /**
  28250. * Polygon
  28251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28252. */
  28253. class Polygon {
  28254. /**
  28255. * Creates a rectangle
  28256. * @param xmin bottom X coord
  28257. * @param ymin bottom Y coord
  28258. * @param xmax top X coord
  28259. * @param ymax top Y coord
  28260. * @returns points that make the resulting rectation
  28261. */
  28262. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28263. /**
  28264. * Creates a circle
  28265. * @param radius radius of circle
  28266. * @param cx scale in x
  28267. * @param cy scale in y
  28268. * @param numberOfSides number of sides that make up the circle
  28269. * @returns points that make the resulting circle
  28270. */
  28271. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28272. /**
  28273. * Creates a polygon from input string
  28274. * @param input Input polygon data
  28275. * @returns the parsed points
  28276. */
  28277. static Parse(input: string): Vector2[];
  28278. /**
  28279. * Starts building a polygon from x and y coordinates
  28280. * @param x x coordinate
  28281. * @param y y coordinate
  28282. * @returns the started path2
  28283. */
  28284. static StartingAt(x: number, y: number): Path2;
  28285. }
  28286. /**
  28287. * Builds a polygon
  28288. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28289. */
  28290. class PolygonMeshBuilder {
  28291. private _points;
  28292. private _outlinepoints;
  28293. private _holes;
  28294. private _name;
  28295. private _scene;
  28296. private _epoints;
  28297. private _eholes;
  28298. private _addToepoint;
  28299. /**
  28300. * Creates a PolygonMeshBuilder
  28301. * @param name name of the builder
  28302. * @param contours Path of the polygon
  28303. * @param scene scene to add to
  28304. */
  28305. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28306. /**
  28307. * Adds a whole within the polygon
  28308. * @param hole Array of points defining the hole
  28309. * @returns this
  28310. */
  28311. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28312. /**
  28313. * Creates the polygon
  28314. * @param updatable If the mesh should be updatable
  28315. * @param depth The depth of the mesh created
  28316. * @returns the created mesh
  28317. */
  28318. build(updatable?: boolean, depth?: number): Mesh;
  28319. /**
  28320. * Adds a side to the polygon
  28321. * @param positions points that make the polygon
  28322. * @param normals normals of the polygon
  28323. * @param uvs uvs of the polygon
  28324. * @param indices indices of the polygon
  28325. * @param bounds bounds of the polygon
  28326. * @param points points of the polygon
  28327. * @param depth depth of the polygon
  28328. * @param flip flip of the polygon
  28329. */
  28330. private addSide;
  28331. }
  28332. }
  28333. declare module BABYLON {
  28334. /**
  28335. * Base class for submeshes
  28336. */
  28337. class BaseSubMesh {
  28338. /** @hidden */
  28339. _materialDefines: Nullable<MaterialDefines>;
  28340. /** @hidden */
  28341. _materialEffect: Nullable<Effect>;
  28342. /**
  28343. * Gets associated effect
  28344. */
  28345. readonly effect: Nullable<Effect>;
  28346. /**
  28347. * Sets associated effect (effect used to render this submesh)
  28348. * @param effect defines the effect to associate with
  28349. * @param defines defines the set of defines used to compile this effect
  28350. */
  28351. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28352. }
  28353. /**
  28354. * Defines a subdivision inside a mesh
  28355. */
  28356. class SubMesh extends BaseSubMesh implements ICullable {
  28357. /** the material index to use */
  28358. materialIndex: number;
  28359. /** vertex index start */
  28360. verticesStart: number;
  28361. /** vertices count */
  28362. verticesCount: number;
  28363. /** index start */
  28364. indexStart: number;
  28365. /** indices count */
  28366. indexCount: number;
  28367. /** @hidden */
  28368. _linesIndexCount: number;
  28369. private _mesh;
  28370. private _renderingMesh;
  28371. private _boundingInfo;
  28372. private _linesIndexBuffer;
  28373. /** @hidden */
  28374. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28375. /** @hidden */
  28376. _trianglePlanes: Plane[];
  28377. /** @hidden */
  28378. _lastColliderTransformMatrix: Matrix;
  28379. /** @hidden */
  28380. _renderId: number;
  28381. /** @hidden */
  28382. _alphaIndex: number;
  28383. /** @hidden */
  28384. _distanceToCamera: number;
  28385. /** @hidden */
  28386. _id: number;
  28387. private _currentMaterial;
  28388. /**
  28389. * Add a new submesh to a mesh
  28390. * @param materialIndex defines the material index to use
  28391. * @param verticesStart defines vertex index start
  28392. * @param verticesCount defines vertices count
  28393. * @param indexStart defines index start
  28394. * @param indexCount defines indices count
  28395. * @param mesh defines the parent mesh
  28396. * @param renderingMesh defines an optional rendering mesh
  28397. * @param createBoundingBox defines if bounding box should be created for this submesh
  28398. * @returns the new submesh
  28399. */
  28400. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28401. /**
  28402. * Creates a new submesh
  28403. * @param materialIndex defines the material index to use
  28404. * @param verticesStart defines vertex index start
  28405. * @param verticesCount defines vertices count
  28406. * @param indexStart defines index start
  28407. * @param indexCount defines indices count
  28408. * @param mesh defines the parent mesh
  28409. * @param renderingMesh defines an optional rendering mesh
  28410. * @param createBoundingBox defines if bounding box should be created for this submesh
  28411. */
  28412. constructor(
  28413. /** the material index to use */
  28414. materialIndex: number,
  28415. /** vertex index start */
  28416. verticesStart: number,
  28417. /** vertices count */
  28418. verticesCount: number,
  28419. /** index start */
  28420. indexStart: number,
  28421. /** indices count */
  28422. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28423. /**
  28424. * Returns true if this submesh covers the entire parent mesh
  28425. * @ignorenaming
  28426. */
  28427. readonly IsGlobal: boolean;
  28428. /**
  28429. * Returns the submesh BoudingInfo object
  28430. * @returns current bounding info (or mesh's one if the submesh is global)
  28431. */
  28432. getBoundingInfo(): BoundingInfo;
  28433. /**
  28434. * Sets the submesh BoundingInfo
  28435. * @param boundingInfo defines the new bounding info to use
  28436. * @returns the SubMesh
  28437. */
  28438. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28439. /**
  28440. * Returns the mesh of the current submesh
  28441. * @return the parent mesh
  28442. */
  28443. getMesh(): AbstractMesh;
  28444. /**
  28445. * Returns the rendering mesh of the submesh
  28446. * @returns the rendering mesh (could be different from parent mesh)
  28447. */
  28448. getRenderingMesh(): Mesh;
  28449. /**
  28450. * Returns the submesh material
  28451. * @returns null or the current material
  28452. */
  28453. getMaterial(): Nullable<Material>;
  28454. /**
  28455. * Sets a new updated BoundingInfo object to the submesh
  28456. * @returns the SubMesh
  28457. */
  28458. refreshBoundingInfo(): SubMesh;
  28459. /** @hidden */
  28460. _checkCollision(collider: Collider): boolean;
  28461. /**
  28462. * Updates the submesh BoundingInfo
  28463. * @param world defines the world matrix to use to update the bounding info
  28464. * @returns the submesh
  28465. */
  28466. updateBoundingInfo(world: Matrix): SubMesh;
  28467. /**
  28468. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28469. * @param frustumPlanes defines the frustum planes
  28470. * @returns true if the submesh is intersecting with the frustum
  28471. */
  28472. isInFrustum(frustumPlanes: Plane[]): boolean;
  28473. /**
  28474. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28475. * @param frustumPlanes defines the frustum planes
  28476. * @returns true if the submesh is inside the frustum
  28477. */
  28478. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28479. /**
  28480. * Renders the submesh
  28481. * @param enableAlphaMode defines if alpha needs to be used
  28482. * @returns the submesh
  28483. */
  28484. render(enableAlphaMode: boolean): SubMesh;
  28485. /**
  28486. * @hidden
  28487. */
  28488. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  28489. /**
  28490. * Checks if the submesh intersects with a ray
  28491. * @param ray defines the ray to test
  28492. * @returns true is the passed ray intersects the submesh bounding box
  28493. */
  28494. canIntersects(ray: Ray): boolean;
  28495. /**
  28496. * Intersects current submesh with a ray
  28497. * @param ray defines the ray to test
  28498. * @param positions defines mesh's positions array
  28499. * @param indices defines mesh's indices array
  28500. * @param fastCheck defines if only bounding info should be used
  28501. * @returns intersection info or null if no intersection
  28502. */
  28503. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  28504. /** @hidden */
  28505. private _intersectLines;
  28506. /** @hidden */
  28507. private _intersectTriangles;
  28508. /** @hidden */
  28509. _rebuild(): void;
  28510. /**
  28511. * Creates a new submesh from the passed mesh
  28512. * @param newMesh defines the new hosting mesh
  28513. * @param newRenderingMesh defines an optional rendering mesh
  28514. * @returns the new submesh
  28515. */
  28516. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  28517. /**
  28518. * Release associated resources
  28519. */
  28520. dispose(): void;
  28521. /**
  28522. * Creates a new submesh from indices data
  28523. * @param materialIndex the index of the main mesh material
  28524. * @param startIndex the index where to start the copy in the mesh indices array
  28525. * @param indexCount the number of indices to copy then from the startIndex
  28526. * @param mesh the main mesh to create the submesh from
  28527. * @param renderingMesh the optional rendering mesh
  28528. * @returns a new submesh
  28529. */
  28530. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  28531. }
  28532. }
  28533. declare module BABYLON {
  28534. /**
  28535. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  28536. * @see https://doc.babylonjs.com/how_to/transformnode
  28537. */
  28538. class TransformNode extends Node {
  28539. /**
  28540. * Object will not rotate to face the camera
  28541. */
  28542. static BILLBOARDMODE_NONE: number;
  28543. /**
  28544. * Object will rotate to face the camera but only on the x axis
  28545. */
  28546. static BILLBOARDMODE_X: number;
  28547. /**
  28548. * Object will rotate to face the camera but only on the y axis
  28549. */
  28550. static BILLBOARDMODE_Y: number;
  28551. /**
  28552. * Object will rotate to face the camera but only on the z axis
  28553. */
  28554. static BILLBOARDMODE_Z: number;
  28555. /**
  28556. * Object will rotate to face the camera
  28557. */
  28558. static BILLBOARDMODE_ALL: number;
  28559. private _forward;
  28560. private _forwardInverted;
  28561. private _up;
  28562. private _right;
  28563. private _rightInverted;
  28564. private _position;
  28565. private _rotation;
  28566. private _rotationQuaternion;
  28567. protected _scaling: Vector3;
  28568. protected _isDirty: boolean;
  28569. private _transformToBoneReferal;
  28570. /**
  28571. * Set the billboard mode. Default is 0.
  28572. *
  28573. * | Value | Type | Description |
  28574. * | --- | --- | --- |
  28575. * | 0 | BILLBOARDMODE_NONE | |
  28576. * | 1 | BILLBOARDMODE_X | |
  28577. * | 2 | BILLBOARDMODE_Y | |
  28578. * | 4 | BILLBOARDMODE_Z | |
  28579. * | 7 | BILLBOARDMODE_ALL | |
  28580. *
  28581. */
  28582. billboardMode: number;
  28583. /**
  28584. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  28585. */
  28586. scalingDeterminant: number;
  28587. /**
  28588. * Sets the distance of the object to max, often used by skybox
  28589. */
  28590. infiniteDistance: boolean;
  28591. /**
  28592. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  28593. * By default the system will update normals to compensate
  28594. */
  28595. ignoreNonUniformScaling: boolean;
  28596. /** @hidden */
  28597. _poseMatrix: Matrix;
  28598. private _localWorld;
  28599. private _absolutePosition;
  28600. private _pivotMatrix;
  28601. private _pivotMatrixInverse;
  28602. private _postMultiplyPivotMatrix;
  28603. protected _isWorldMatrixFrozen: boolean;
  28604. /**
  28605. * An event triggered after the world matrix is updated
  28606. */
  28607. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  28608. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  28609. /**
  28610. * Gets a string identifying the name of the class
  28611. * @returns "TransformNode" string
  28612. */
  28613. getClassName(): string;
  28614. /**
  28615. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  28616. */
  28617. position: Vector3;
  28618. /**
  28619. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  28620. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  28621. */
  28622. rotation: Vector3;
  28623. /**
  28624. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  28625. */
  28626. scaling: Vector3;
  28627. /**
  28628. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  28629. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  28630. */
  28631. rotationQuaternion: Nullable<Quaternion>;
  28632. /**
  28633. * The forward direction of that transform in world space.
  28634. */
  28635. readonly forward: Vector3;
  28636. /**
  28637. * The up direction of that transform in world space.
  28638. */
  28639. readonly up: Vector3;
  28640. /**
  28641. * The right direction of that transform in world space.
  28642. */
  28643. readonly right: Vector3;
  28644. /**
  28645. * Copies the parameter passed Matrix into the mesh Pose matrix.
  28646. * @param matrix the matrix to copy the pose from
  28647. * @returns this TransformNode.
  28648. */
  28649. updatePoseMatrix(matrix: Matrix): TransformNode;
  28650. /**
  28651. * Returns the mesh Pose matrix.
  28652. * @returns the pose matrix
  28653. */
  28654. getPoseMatrix(): Matrix;
  28655. /** @hidden */
  28656. _isSynchronized(): boolean;
  28657. /** @hidden */
  28658. _initCache(): void;
  28659. /**
  28660. * Flag the transform node as dirty (Forcing it to update everything)
  28661. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  28662. * @returns this transform node
  28663. */
  28664. markAsDirty(property: string): TransformNode;
  28665. /**
  28666. * Returns the current mesh absolute position.
  28667. * Returns a Vector3.
  28668. */
  28669. readonly absolutePosition: Vector3;
  28670. /**
  28671. * Sets a new matrix to apply before all other transformation
  28672. * @param matrix defines the transform matrix
  28673. * @returns the current TransformNode
  28674. */
  28675. setPreTransformMatrix(matrix: Matrix): TransformNode;
  28676. /**
  28677. * Sets a new pivot matrix to the current node
  28678. * @param matrix defines the new pivot matrix to use
  28679. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  28680. * @returns the current TransformNode
  28681. */
  28682. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  28683. /**
  28684. * Returns the mesh pivot matrix.
  28685. * Default : Identity.
  28686. * @returns the matrix
  28687. */
  28688. getPivotMatrix(): Matrix;
  28689. /**
  28690. * Prevents the World matrix to be computed any longer.
  28691. * @returns the TransformNode.
  28692. */
  28693. freezeWorldMatrix(): TransformNode;
  28694. /**
  28695. * Allows back the World matrix computation.
  28696. * @returns the TransformNode.
  28697. */
  28698. unfreezeWorldMatrix(): this;
  28699. /**
  28700. * True if the World matrix has been frozen.
  28701. */
  28702. readonly isWorldMatrixFrozen: boolean;
  28703. /**
  28704. * Retuns the mesh absolute position in the World.
  28705. * @returns a Vector3.
  28706. */
  28707. getAbsolutePosition(): Vector3;
  28708. /**
  28709. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  28710. * @param absolutePosition the absolute position to set
  28711. * @returns the TransformNode.
  28712. */
  28713. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28714. /**
  28715. * Sets the mesh position in its local space.
  28716. * @param vector3 the position to set in localspace
  28717. * @returns the TransformNode.
  28718. */
  28719. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  28720. /**
  28721. * Returns the mesh position in the local space from the current World matrix values.
  28722. * @returns a new Vector3.
  28723. */
  28724. getPositionExpressedInLocalSpace(): Vector3;
  28725. /**
  28726. * Translates the mesh along the passed Vector3 in its local space.
  28727. * @param vector3 the distance to translate in localspace
  28728. * @returns the TransformNode.
  28729. */
  28730. locallyTranslate(vector3: Vector3): TransformNode;
  28731. private static _lookAtVectorCache;
  28732. /**
  28733. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  28734. * @param targetPoint the position (must be in same space as current mesh) to look at
  28735. * @param yawCor optional yaw (y-axis) correction in radians
  28736. * @param pitchCor optional pitch (x-axis) correction in radians
  28737. * @param rollCor optional roll (z-axis) correction in radians
  28738. * @param space the choosen space of the target
  28739. * @returns the TransformNode.
  28740. */
  28741. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  28742. /**
  28743. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28744. * This Vector3 is expressed in the World space.
  28745. * @param localAxis axis to rotate
  28746. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28747. */
  28748. getDirection(localAxis: Vector3): Vector3;
  28749. /**
  28750. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  28751. * localAxis is expressed in the mesh local space.
  28752. * result is computed in the Wordl space from the mesh World matrix.
  28753. * @param localAxis axis to rotate
  28754. * @param result the resulting transformnode
  28755. * @returns this TransformNode.
  28756. */
  28757. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  28758. /**
  28759. * Sets a new pivot point to the current node
  28760. * @param point defines the new pivot point to use
  28761. * @param space defines if the point is in world or local space (local by default)
  28762. * @returns the current TransformNode
  28763. */
  28764. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  28765. /**
  28766. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  28767. * @returns the pivot point
  28768. */
  28769. getPivotPoint(): Vector3;
  28770. /**
  28771. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  28772. * @param result the vector3 to store the result
  28773. * @returns this TransformNode.
  28774. */
  28775. getPivotPointToRef(result: Vector3): TransformNode;
  28776. /**
  28777. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  28778. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  28779. */
  28780. getAbsolutePivotPoint(): Vector3;
  28781. /**
  28782. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  28783. * @param result vector3 to store the result
  28784. * @returns this TransformNode.
  28785. */
  28786. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  28787. /**
  28788. * Defines the passed node as the parent of the current node.
  28789. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  28790. * @param node the node ot set as the parent
  28791. * @returns this TransformNode.
  28792. */
  28793. setParent(node: Nullable<Node>): TransformNode;
  28794. private _nonUniformScaling;
  28795. /**
  28796. * True if the scaling property of this object is non uniform eg. (1,2,1)
  28797. */
  28798. readonly nonUniformScaling: boolean;
  28799. /** @hidden */
  28800. _updateNonUniformScalingState(value: boolean): boolean;
  28801. /**
  28802. * Attach the current TransformNode to another TransformNode associated with a bone
  28803. * @param bone Bone affecting the TransformNode
  28804. * @param affectedTransformNode TransformNode associated with the bone
  28805. * @returns this object
  28806. */
  28807. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  28808. /**
  28809. * Detach the transform node if its associated with a bone
  28810. * @returns this object
  28811. */
  28812. detachFromBone(): TransformNode;
  28813. private static _rotationAxisCache;
  28814. /**
  28815. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  28816. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  28817. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28818. * The passed axis is also normalized.
  28819. * @param axis the axis to rotate around
  28820. * @param amount the amount to rotate in radians
  28821. * @param space Space to rotate in (Default: local)
  28822. * @returns the TransformNode.
  28823. */
  28824. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28825. /**
  28826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  28827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28828. * The passed axis is also normalized. .
  28829. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  28830. * @param point the point to rotate around
  28831. * @param axis the axis to rotate around
  28832. * @param amount the amount to rotate in radians
  28833. * @returns the TransformNode
  28834. */
  28835. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  28836. /**
  28837. * Translates the mesh along the axis vector for the passed distance in the given space.
  28838. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  28839. * @param axis the axis to translate in
  28840. * @param distance the distance to translate
  28841. * @param space Space to rotate in (Default: local)
  28842. * @returns the TransformNode.
  28843. */
  28844. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28845. /**
  28846. * Adds a rotation step to the mesh current rotation.
  28847. * x, y, z are Euler angles expressed in radians.
  28848. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  28849. * This means this rotation is made in the mesh local space only.
  28850. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  28851. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  28852. * ```javascript
  28853. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  28854. * ```
  28855. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  28856. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  28857. * @param x Rotation to add
  28858. * @param y Rotation to add
  28859. * @param z Rotation to add
  28860. * @returns the TransformNode.
  28861. */
  28862. addRotation(x: number, y: number, z: number): TransformNode;
  28863. /**
  28864. * Computes the world matrix of the node
  28865. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28866. * @returns the world matrix
  28867. */
  28868. computeWorldMatrix(force?: boolean): Matrix;
  28869. protected _afterComputeWorldMatrix(): void;
  28870. /**
  28871. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  28872. * @param func callback function to add
  28873. *
  28874. * @returns the TransformNode.
  28875. */
  28876. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28877. /**
  28878. * Removes a registered callback function.
  28879. * @param func callback function to remove
  28880. * @returns the TransformNode.
  28881. */
  28882. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28883. /**
  28884. * Clone the current transform node
  28885. * @param name Name of the new clone
  28886. * @param newParent New parent for the clone
  28887. * @param doNotCloneChildren Do not clone children hierarchy
  28888. * @returns the new transform node
  28889. */
  28890. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  28891. /**
  28892. * Serializes the objects information.
  28893. * @param currentSerializationObject defines the object to serialize in
  28894. * @returns the serialized object
  28895. */
  28896. serialize(currentSerializationObject?: any): any;
  28897. /**
  28898. * Returns a new TransformNode object parsed from the source provided.
  28899. * @param parsedTransformNode is the source.
  28900. * @param scene the scne the object belongs to
  28901. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  28902. * @returns a new TransformNode object parsed from the source provided.
  28903. */
  28904. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  28905. /**
  28906. * Releases resources associated with this transform node.
  28907. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28908. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28909. */
  28910. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28911. }
  28912. }
  28913. declare module BABYLON {
  28914. /**
  28915. * Specialized buffer used to store vertex data
  28916. */
  28917. class VertexBuffer {
  28918. /** @hidden */
  28919. _buffer: Buffer;
  28920. private _kind;
  28921. private _size;
  28922. private _ownsBuffer;
  28923. private _instanced;
  28924. private _instanceDivisor;
  28925. /**
  28926. * The byte type.
  28927. */
  28928. static readonly BYTE: number;
  28929. /**
  28930. * The unsigned byte type.
  28931. */
  28932. static readonly UNSIGNED_BYTE: number;
  28933. /**
  28934. * The short type.
  28935. */
  28936. static readonly SHORT: number;
  28937. /**
  28938. * The unsigned short type.
  28939. */
  28940. static readonly UNSIGNED_SHORT: number;
  28941. /**
  28942. * The integer type.
  28943. */
  28944. static readonly INT: number;
  28945. /**
  28946. * The unsigned integer type.
  28947. */
  28948. static readonly UNSIGNED_INT: number;
  28949. /**
  28950. * The float type.
  28951. */
  28952. static readonly FLOAT: number;
  28953. /**
  28954. * Gets or sets the instance divisor when in instanced mode
  28955. */
  28956. instanceDivisor: number;
  28957. /**
  28958. * Gets the byte stride.
  28959. */
  28960. readonly byteStride: number;
  28961. /**
  28962. * Gets the byte offset.
  28963. */
  28964. readonly byteOffset: number;
  28965. /**
  28966. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  28967. */
  28968. readonly normalized: boolean;
  28969. /**
  28970. * Gets the data type of each component in the array.
  28971. */
  28972. readonly type: number;
  28973. /**
  28974. * Constructor
  28975. * @param engine the engine
  28976. * @param data the data to use for this vertex buffer
  28977. * @param kind the vertex buffer kind
  28978. * @param updatable whether the data is updatable
  28979. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  28980. * @param stride the stride (optional)
  28981. * @param instanced whether the buffer is instanced (optional)
  28982. * @param offset the offset of the data (optional)
  28983. * @param size the number of components (optional)
  28984. * @param type the type of the component (optional)
  28985. * @param normalized whether the data contains normalized data (optional)
  28986. * @param useBytes set to true if stride and offset are in bytes (optional)
  28987. */
  28988. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  28989. /** @hidden */
  28990. _rebuild(): void;
  28991. /**
  28992. * Returns the kind of the VertexBuffer (string)
  28993. * @returns a string
  28994. */
  28995. getKind(): string;
  28996. /**
  28997. * Gets a boolean indicating if the VertexBuffer is updatable?
  28998. * @returns true if the buffer is updatable
  28999. */
  29000. isUpdatable(): boolean;
  29001. /**
  29002. * Gets current buffer's data
  29003. * @returns a DataArray or null
  29004. */
  29005. getData(): Nullable<DataArray>;
  29006. /**
  29007. * Gets underlying native buffer
  29008. * @returns underlying native buffer
  29009. */
  29010. getBuffer(): Nullable<WebGLBuffer>;
  29011. /**
  29012. * Gets the stride in float32 units (i.e. byte stride / 4).
  29013. * May not be an integer if the byte stride is not divisible by 4.
  29014. * DEPRECATED. Use byteStride instead.
  29015. * @returns the stride in float32 units
  29016. */
  29017. getStrideSize(): number;
  29018. /**
  29019. * Returns the offset as a multiple of the type byte length.
  29020. * DEPRECATED. Use byteOffset instead.
  29021. * @returns the offset in bytes
  29022. */
  29023. getOffset(): number;
  29024. /**
  29025. * Returns the number of components per vertex attribute (integer)
  29026. * @returns the size in float
  29027. */
  29028. getSize(): number;
  29029. /**
  29030. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29031. * @returns true if this buffer is instanced
  29032. */
  29033. getIsInstanced(): boolean;
  29034. /**
  29035. * Returns the instancing divisor, zero for non-instanced (integer).
  29036. * @returns a number
  29037. */
  29038. getInstanceDivisor(): number;
  29039. /**
  29040. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29041. * @param data defines the data to store
  29042. */
  29043. create(data?: DataArray): void;
  29044. /**
  29045. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29046. * This function will create a new buffer if the current one is not updatable
  29047. * @param data defines the data to store
  29048. */
  29049. update(data: DataArray): void;
  29050. /**
  29051. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29052. * Returns the directly updated WebGLBuffer.
  29053. * @param data the new data
  29054. * @param offset the new offset
  29055. * @param useBytes set to true if the offset is in bytes
  29056. */
  29057. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29058. /**
  29059. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29060. */
  29061. dispose(): void;
  29062. /**
  29063. * Enumerates each value of this vertex buffer as numbers.
  29064. * @param count the number of values to enumerate
  29065. * @param callback the callback function called for each value
  29066. */
  29067. forEach(count: number, callback: (value: number, index: number) => void): void;
  29068. /**
  29069. * Positions
  29070. */
  29071. static readonly PositionKind: string;
  29072. /**
  29073. * Normals
  29074. */
  29075. static readonly NormalKind: string;
  29076. /**
  29077. * Tangents
  29078. */
  29079. static readonly TangentKind: string;
  29080. /**
  29081. * Texture coordinates
  29082. */
  29083. static readonly UVKind: string;
  29084. /**
  29085. * Texture coordinates 2
  29086. */
  29087. static readonly UV2Kind: string;
  29088. /**
  29089. * Texture coordinates 3
  29090. */
  29091. static readonly UV3Kind: string;
  29092. /**
  29093. * Texture coordinates 4
  29094. */
  29095. static readonly UV4Kind: string;
  29096. /**
  29097. * Texture coordinates 5
  29098. */
  29099. static readonly UV5Kind: string;
  29100. /**
  29101. * Texture coordinates 6
  29102. */
  29103. static readonly UV6Kind: string;
  29104. /**
  29105. * Colors
  29106. */
  29107. static readonly ColorKind: string;
  29108. /**
  29109. * Matrix indices (for bones)
  29110. */
  29111. static readonly MatricesIndicesKind: string;
  29112. /**
  29113. * Matrix weights (for bones)
  29114. */
  29115. static readonly MatricesWeightsKind: string;
  29116. /**
  29117. * Additional matrix indices (for bones)
  29118. */
  29119. static readonly MatricesIndicesExtraKind: string;
  29120. /**
  29121. * Additional matrix weights (for bones)
  29122. */
  29123. static readonly MatricesWeightsExtraKind: string;
  29124. /**
  29125. * Deduces the stride given a kind.
  29126. * @param kind The kind string to deduce
  29127. * @returns The deduced stride
  29128. */
  29129. static DeduceStride(kind: string): number;
  29130. /**
  29131. * Gets the byte length of the given type.
  29132. * @param type the type
  29133. * @returns the number of bytes
  29134. */
  29135. static GetTypeByteLength(type: number): number;
  29136. /**
  29137. * Enumerates each value of the given parameters as numbers.
  29138. * @param data the data to enumerate
  29139. * @param byteOffset the byte offset of the data
  29140. * @param byteStride the byte stride of the data
  29141. * @param componentCount the number of components per element
  29142. * @param componentType the type of the component
  29143. * @param count the total number of components
  29144. * @param normalized whether the data is normalized
  29145. * @param callback the callback function called for each value
  29146. */
  29147. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29148. private static _GetFloatValue;
  29149. }
  29150. }
  29151. declare module BABYLON {
  29152. /**
  29153. * Defines a target to use with MorphTargetManager
  29154. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29155. */
  29156. class MorphTarget implements IAnimatable {
  29157. /** defines the name of the target */
  29158. name: string;
  29159. /**
  29160. * Gets or sets the list of animations
  29161. */
  29162. animations: Animation[];
  29163. private _scene;
  29164. private _positions;
  29165. private _normals;
  29166. private _tangents;
  29167. private _influence;
  29168. /**
  29169. * Observable raised when the influence changes
  29170. */
  29171. onInfluenceChanged: Observable<boolean>;
  29172. /** @hidden */
  29173. _onDataLayoutChanged: Observable<void>;
  29174. /**
  29175. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29176. */
  29177. influence: number;
  29178. private _animationPropertiesOverride;
  29179. /**
  29180. * Gets or sets the animation properties override
  29181. */
  29182. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29183. /**
  29184. * Creates a new MorphTarget
  29185. * @param name defines the name of the target
  29186. * @param influence defines the influence to use
  29187. */
  29188. constructor(
  29189. /** defines the name of the target */
  29190. name: string, influence?: number, scene?: Nullable<Scene>);
  29191. /**
  29192. * Gets a boolean defining if the target contains position data
  29193. */
  29194. readonly hasPositions: boolean;
  29195. /**
  29196. * Gets a boolean defining if the target contains normal data
  29197. */
  29198. readonly hasNormals: boolean;
  29199. /**
  29200. * Gets a boolean defining if the target contains tangent data
  29201. */
  29202. readonly hasTangents: boolean;
  29203. /**
  29204. * Affects position data to this target
  29205. * @param data defines the position data to use
  29206. */
  29207. setPositions(data: Nullable<FloatArray>): void;
  29208. /**
  29209. * Gets the position data stored in this target
  29210. * @returns a FloatArray containing the position data (or null if not present)
  29211. */
  29212. getPositions(): Nullable<FloatArray>;
  29213. /**
  29214. * Affects normal data to this target
  29215. * @param data defines the normal data to use
  29216. */
  29217. setNormals(data: Nullable<FloatArray>): void;
  29218. /**
  29219. * Gets the normal data stored in this target
  29220. * @returns a FloatArray containing the normal data (or null if not present)
  29221. */
  29222. getNormals(): Nullable<FloatArray>;
  29223. /**
  29224. * Affects tangent data to this target
  29225. * @param data defines the tangent data to use
  29226. */
  29227. setTangents(data: Nullable<FloatArray>): void;
  29228. /**
  29229. * Gets the tangent data stored in this target
  29230. * @returns a FloatArray containing the tangent data (or null if not present)
  29231. */
  29232. getTangents(): Nullable<FloatArray>;
  29233. /**
  29234. * Serializes the current target into a Serialization object
  29235. * @returns the serialized object
  29236. */
  29237. serialize(): any;
  29238. /**
  29239. * Creates a new target from serialized data
  29240. * @param serializationObject defines the serialized data to use
  29241. * @returns a new MorphTarget
  29242. */
  29243. static Parse(serializationObject: any): MorphTarget;
  29244. /**
  29245. * Creates a MorphTarget from mesh data
  29246. * @param mesh defines the source mesh
  29247. * @param name defines the name to use for the new target
  29248. * @param influence defines the influence to attach to the target
  29249. * @returns a new MorphTarget
  29250. */
  29251. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29252. }
  29253. }
  29254. declare module BABYLON {
  29255. /**
  29256. * This class is used to deform meshes using morphing between different targets
  29257. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29258. */
  29259. class MorphTargetManager {
  29260. private _targets;
  29261. private _targetInfluenceChangedObservers;
  29262. private _targetDataLayoutChangedObservers;
  29263. private _activeTargets;
  29264. private _scene;
  29265. private _influences;
  29266. private _supportsNormals;
  29267. private _supportsTangents;
  29268. private _vertexCount;
  29269. private _uniqueId;
  29270. private _tempInfluences;
  29271. /**
  29272. * Creates a new MorphTargetManager
  29273. * @param scene defines the current scene
  29274. */
  29275. constructor(scene?: Nullable<Scene>);
  29276. /**
  29277. * Gets the unique ID of this manager
  29278. */
  29279. readonly uniqueId: number;
  29280. /**
  29281. * Gets the number of vertices handled by this manager
  29282. */
  29283. readonly vertexCount: number;
  29284. /**
  29285. * Gets a boolean indicating if this manager supports morphing of normals
  29286. */
  29287. readonly supportsNormals: boolean;
  29288. /**
  29289. * Gets a boolean indicating if this manager supports morphing of tangents
  29290. */
  29291. readonly supportsTangents: boolean;
  29292. /**
  29293. * Gets the number of targets stored in this manager
  29294. */
  29295. readonly numTargets: number;
  29296. /**
  29297. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29298. */
  29299. readonly numInfluencers: number;
  29300. /**
  29301. * Gets the list of influences (one per target)
  29302. */
  29303. readonly influences: Float32Array;
  29304. /**
  29305. * Gets the active target at specified index. An active target is a target with an influence > 0
  29306. * @param index defines the index to check
  29307. * @returns the requested target
  29308. */
  29309. getActiveTarget(index: number): MorphTarget;
  29310. /**
  29311. * Gets the target at specified index
  29312. * @param index defines the index to check
  29313. * @returns the requested target
  29314. */
  29315. getTarget(index: number): MorphTarget;
  29316. /**
  29317. * Add a new target to this manager
  29318. * @param target defines the target to add
  29319. */
  29320. addTarget(target: MorphTarget): void;
  29321. /**
  29322. * Removes a target from the manager
  29323. * @param target defines the target to remove
  29324. */
  29325. removeTarget(target: MorphTarget): void;
  29326. /**
  29327. * Serializes the current manager into a Serialization object
  29328. * @returns the serialized object
  29329. */
  29330. serialize(): any;
  29331. private _syncActiveTargets;
  29332. /**
  29333. * Syncrhonize the targets with all the meshes using this morph target manager
  29334. */
  29335. synchronize(): void;
  29336. /**
  29337. * Creates a new MorphTargetManager from serialized data
  29338. * @param serializationObject defines the serialized data
  29339. * @param scene defines the hosting scene
  29340. * @returns the new MorphTargetManager
  29341. */
  29342. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29343. }
  29344. }
  29345. declare module BABYLON {
  29346. /**
  29347. * This represents the base class for particle system in Babylon.
  29348. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  29349. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  29350. * @example https://doc.babylonjs.com/babylon101/particles
  29351. */
  29352. class BaseParticleSystem {
  29353. /**
  29354. * Source color is added to the destination color without alpha affecting the result
  29355. */
  29356. static BLENDMODE_ONEONE: number;
  29357. /**
  29358. * Blend current color and particle color using particle’s alpha
  29359. */
  29360. static BLENDMODE_STANDARD: number;
  29361. /**
  29362. * Add current color and particle color multiplied by particle’s alpha
  29363. */
  29364. static BLENDMODE_ADD: number;
  29365. /**
  29366. * Multiply current color with particle color
  29367. */
  29368. static BLENDMODE_MULTIPLY: number;
  29369. /**
  29370. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  29371. */
  29372. static BLENDMODE_MULTIPLYADD: number;
  29373. /**
  29374. * List of animations used by the particle system.
  29375. */
  29376. animations: Animation[];
  29377. /**
  29378. * The id of the Particle system.
  29379. */
  29380. id: string;
  29381. /**
  29382. * The friendly name of the Particle system.
  29383. */
  29384. name: string;
  29385. /**
  29386. * The rendering group used by the Particle system to chose when to render.
  29387. */
  29388. renderingGroupId: number;
  29389. /**
  29390. * The emitter represents the Mesh or position we are attaching the particle system to.
  29391. */
  29392. emitter: Nullable<AbstractMesh | Vector3>;
  29393. /**
  29394. * The maximum number of particles to emit per frame
  29395. */
  29396. emitRate: number;
  29397. /**
  29398. * If you want to launch only a few particles at once, that can be done, as well.
  29399. */
  29400. manualEmitCount: number;
  29401. /**
  29402. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  29403. */
  29404. updateSpeed: number;
  29405. /**
  29406. * The amount of time the particle system is running (depends of the overall update speed).
  29407. */
  29408. targetStopDuration: number;
  29409. /**
  29410. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  29411. */
  29412. disposeOnStop: boolean;
  29413. /**
  29414. * Minimum power of emitting particles.
  29415. */
  29416. minEmitPower: number;
  29417. /**
  29418. * Maximum power of emitting particles.
  29419. */
  29420. maxEmitPower: number;
  29421. /**
  29422. * Minimum life time of emitting particles.
  29423. */
  29424. minLifeTime: number;
  29425. /**
  29426. * Maximum life time of emitting particles.
  29427. */
  29428. maxLifeTime: number;
  29429. /**
  29430. * Minimum Size of emitting particles.
  29431. */
  29432. minSize: number;
  29433. /**
  29434. * Maximum Size of emitting particles.
  29435. */
  29436. maxSize: number;
  29437. /**
  29438. * Minimum scale of emitting particles on X axis.
  29439. */
  29440. minScaleX: number;
  29441. /**
  29442. * Maximum scale of emitting particles on X axis.
  29443. */
  29444. maxScaleX: number;
  29445. /**
  29446. * Minimum scale of emitting particles on Y axis.
  29447. */
  29448. minScaleY: number;
  29449. /**
  29450. * Maximum scale of emitting particles on Y axis.
  29451. */
  29452. maxScaleY: number;
  29453. /**
  29454. * Gets or sets the minimal initial rotation in radians.
  29455. */
  29456. minInitialRotation: number;
  29457. /**
  29458. * Gets or sets the maximal initial rotation in radians.
  29459. */
  29460. maxInitialRotation: number;
  29461. /**
  29462. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  29463. */
  29464. minAngularSpeed: number;
  29465. /**
  29466. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  29467. */
  29468. maxAngularSpeed: number;
  29469. /**
  29470. * The texture used to render each particle. (this can be a spritesheet)
  29471. */
  29472. particleTexture: Nullable<Texture>;
  29473. /**
  29474. * The layer mask we are rendering the particles through.
  29475. */
  29476. layerMask: number;
  29477. /**
  29478. * This can help using your own shader to render the particle system.
  29479. * The according effect will be created
  29480. */
  29481. customShader: any;
  29482. /**
  29483. * By default particle system starts as soon as they are created. This prevents the
  29484. * automatic start to happen and let you decide when to start emitting particles.
  29485. */
  29486. preventAutoStart: boolean;
  29487. /**
  29488. * Gets or sets a texture used to add random noise to particle positions
  29489. */
  29490. noiseTexture: Nullable<ProceduralTexture>;
  29491. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  29492. noiseStrength: Vector3;
  29493. /**
  29494. * Callback triggered when the particle animation is ending.
  29495. */
  29496. onAnimationEnd: Nullable<() => void>;
  29497. /**
  29498. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  29499. */
  29500. blendMode: number;
  29501. /**
  29502. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29503. * to override the particles.
  29504. */
  29505. forceDepthWrite: boolean;
  29506. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  29507. preWarmCycles: number;
  29508. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  29509. preWarmStepOffset: number;
  29510. /**
  29511. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  29512. */
  29513. spriteCellChangeSpeed: number;
  29514. /**
  29515. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  29516. */
  29517. startSpriteCellID: number;
  29518. /**
  29519. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  29520. */
  29521. endSpriteCellID: number;
  29522. /**
  29523. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  29524. */
  29525. spriteCellWidth: number;
  29526. /**
  29527. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  29528. */
  29529. spriteCellHeight: number;
  29530. /**
  29531. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  29532. */
  29533. spriteRandomStartCell: boolean;
  29534. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  29535. translationPivot: Vector2;
  29536. /** @hidden */
  29537. protected _isAnimationSheetEnabled: boolean;
  29538. /**
  29539. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  29540. */
  29541. beginAnimationOnStart: boolean;
  29542. /**
  29543. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  29544. */
  29545. beginAnimationFrom: number;
  29546. /**
  29547. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  29548. */
  29549. beginAnimationTo: number;
  29550. /**
  29551. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  29552. */
  29553. beginAnimationLoop: boolean;
  29554. /**
  29555. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  29556. */
  29557. isAnimationSheetEnabled: boolean;
  29558. /**
  29559. * Get hosting scene
  29560. * @returns the scene
  29561. */
  29562. getScene(): Scene;
  29563. /**
  29564. * You can use gravity if you want to give an orientation to your particles.
  29565. */
  29566. gravity: Vector3;
  29567. protected _colorGradients: Nullable<Array<ColorGradient>>;
  29568. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  29569. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  29570. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  29571. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  29572. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  29573. protected _dragGradients: Nullable<Array<FactorGradient>>;
  29574. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  29575. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  29576. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  29577. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  29578. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  29579. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  29580. /**
  29581. * Defines the delay in milliseconds before starting the system (0 by default)
  29582. */
  29583. startDelay: number;
  29584. /**
  29585. * Gets the current list of drag gradients.
  29586. * You must use addDragGradient and removeDragGradient to udpate this list
  29587. * @returns the list of drag gradients
  29588. */
  29589. getDragGradients(): Nullable<Array<FactorGradient>>;
  29590. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  29591. limitVelocityDamping: number;
  29592. /**
  29593. * Gets the current list of limit velocity gradients.
  29594. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  29595. * @returns the list of limit velocity gradients
  29596. */
  29597. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  29598. /**
  29599. * Gets the current list of color gradients.
  29600. * You must use addColorGradient and removeColorGradient to udpate this list
  29601. * @returns the list of color gradients
  29602. */
  29603. getColorGradients(): Nullable<Array<ColorGradient>>;
  29604. /**
  29605. * Gets the current list of size gradients.
  29606. * You must use addSizeGradient and removeSizeGradient to udpate this list
  29607. * @returns the list of size gradients
  29608. */
  29609. getSizeGradients(): Nullable<Array<FactorGradient>>;
  29610. /**
  29611. * Gets the current list of color remap gradients.
  29612. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  29613. * @returns the list of color remap gradients
  29614. */
  29615. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  29616. /**
  29617. * Gets the current list of alpha remap gradients.
  29618. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  29619. * @returns the list of alpha remap gradients
  29620. */
  29621. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  29622. /**
  29623. * Gets the current list of life time gradients.
  29624. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  29625. * @returns the list of life time gradients
  29626. */
  29627. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  29628. /**
  29629. * Gets the current list of angular speed gradients.
  29630. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  29631. * @returns the list of angular speed gradients
  29632. */
  29633. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  29634. /**
  29635. * Gets the current list of velocity gradients.
  29636. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  29637. * @returns the list of velocity gradients
  29638. */
  29639. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  29640. /**
  29641. * Gets the current list of start size gradients.
  29642. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  29643. * @returns the list of start size gradients
  29644. */
  29645. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  29646. /**
  29647. * Gets the current list of emit rate gradients.
  29648. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  29649. * @returns the list of emit rate gradients
  29650. */
  29651. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  29652. /**
  29653. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29654. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29655. */
  29656. direction1: Vector3;
  29657. /**
  29658. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29659. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29660. */
  29661. direction2: Vector3;
  29662. /**
  29663. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  29664. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29665. */
  29666. minEmitBox: Vector3;
  29667. /**
  29668. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  29669. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29670. */
  29671. maxEmitBox: Vector3;
  29672. /**
  29673. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  29674. */
  29675. color1: Color4;
  29676. /**
  29677. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  29678. */
  29679. color2: Color4;
  29680. /**
  29681. * Color the particle will have at the end of its lifetime
  29682. */
  29683. colorDead: Color4;
  29684. /**
  29685. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  29686. */
  29687. textureMask: Color4;
  29688. /**
  29689. * The particle emitter type defines the emitter used by the particle system.
  29690. * It can be for example box, sphere, or cone...
  29691. */
  29692. particleEmitterType: IParticleEmitterType;
  29693. /** @hidden */
  29694. _isSubEmitter: boolean;
  29695. /**
  29696. * Gets or sets the billboard mode to use when isBillboardBased = true.
  29697. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  29698. */
  29699. billboardMode: number;
  29700. protected _isBillboardBased: boolean;
  29701. /**
  29702. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  29703. */
  29704. isBillboardBased: boolean;
  29705. /**
  29706. * The scene the particle system belongs to.
  29707. */
  29708. protected _scene: Scene;
  29709. /**
  29710. * Local cache of defines for image processing.
  29711. */
  29712. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  29713. /**
  29714. * Default configuration related to image processing available in the standard Material.
  29715. */
  29716. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29717. /**
  29718. * Gets the image processing configuration used either in this material.
  29719. */
  29720. /**
  29721. * Sets the Default image processing configuration used either in the this material.
  29722. *
  29723. * If sets to null, the scene one is in use.
  29724. */
  29725. imageProcessingConfiguration: ImageProcessingConfiguration;
  29726. /**
  29727. * Attaches a new image processing configuration to the Standard Material.
  29728. * @param configuration
  29729. */
  29730. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29731. /** @hidden */
  29732. protected _reset(): void;
  29733. /** @hidden */
  29734. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  29735. /**
  29736. * Instantiates a particle system.
  29737. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  29738. * @param name The name of the particle system
  29739. */
  29740. constructor(name: string);
  29741. /**
  29742. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  29743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  29744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  29745. * @returns the emitter
  29746. */
  29747. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  29748. /**
  29749. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  29750. * @param radius The radius of the hemisphere to emit from
  29751. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  29752. * @returns the emitter
  29753. */
  29754. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  29755. /**
  29756. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  29757. * @param radius The radius of the sphere to emit from
  29758. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  29759. * @returns the emitter
  29760. */
  29761. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  29762. /**
  29763. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  29764. * @param radius The radius of the sphere to emit from
  29765. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  29766. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  29767. * @returns the emitter
  29768. */
  29769. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  29770. /**
  29771. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  29772. * @param radius The radius of the emission cylinder
  29773. * @param height The height of the emission cylinder
  29774. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  29775. * @param directionRandomizer How much to randomize the particle direction [0-1]
  29776. * @returns the emitter
  29777. */
  29778. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  29779. /**
  29780. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  29781. * @param radius The radius of the cylinder to emit from
  29782. * @param height The height of the emission cylinder
  29783. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  29784. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  29785. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  29786. * @returns the emitter
  29787. */
  29788. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  29789. /**
  29790. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  29791. * @param radius The radius of the cone to emit from
  29792. * @param angle The base angle of the cone
  29793. * @returns the emitter
  29794. */
  29795. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  29796. /**
  29797. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  29798. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  29799. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  29800. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  29801. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  29802. * @returns the emitter
  29803. */
  29804. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  29805. }
  29806. }
  29807. declare module BABYLON {
  29808. /**
  29809. * This represents a GPU particle system in Babylon
  29810. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  29811. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  29812. */
  29813. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  29814. /**
  29815. * The layer mask we are rendering the particles through.
  29816. */
  29817. layerMask: number;
  29818. private _capacity;
  29819. private _activeCount;
  29820. private _currentActiveCount;
  29821. private _accumulatedCount;
  29822. private _renderEffect;
  29823. private _updateEffect;
  29824. private _buffer0;
  29825. private _buffer1;
  29826. private _spriteBuffer;
  29827. private _updateVAO;
  29828. private _renderVAO;
  29829. private _targetIndex;
  29830. private _sourceBuffer;
  29831. private _targetBuffer;
  29832. private _engine;
  29833. private _currentRenderId;
  29834. private _started;
  29835. private _stopped;
  29836. private _timeDelta;
  29837. private _randomTexture;
  29838. private _randomTexture2;
  29839. private _attributesStrideSize;
  29840. private _updateEffectOptions;
  29841. private _randomTextureSize;
  29842. private _actualFrame;
  29843. private readonly _rawTextureWidth;
  29844. /**
  29845. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  29846. */
  29847. static readonly IsSupported: boolean;
  29848. /**
  29849. * An event triggered when the system is disposed.
  29850. */
  29851. onDisposeObservable: Observable<GPUParticleSystem>;
  29852. /**
  29853. * Gets the maximum number of particles active at the same time.
  29854. * @returns The max number of active particles.
  29855. */
  29856. getCapacity(): number;
  29857. /**
  29858. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29859. * to override the particles.
  29860. */
  29861. forceDepthWrite: boolean;
  29862. /**
  29863. * Gets or set the number of active particles
  29864. */
  29865. activeParticleCount: number;
  29866. private _preWarmDone;
  29867. /**
  29868. * Is this system ready to be used/rendered
  29869. * @return true if the system is ready
  29870. */
  29871. isReady(): boolean;
  29872. /**
  29873. * Gets if the system has been started. (Note: this will still be true after stop is called)
  29874. * @returns True if it has been started, otherwise false.
  29875. */
  29876. isStarted(): boolean;
  29877. /**
  29878. * Starts the particle system and begins to emit
  29879. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  29880. */
  29881. start(delay?: number): void;
  29882. /**
  29883. * Stops the particle system.
  29884. */
  29885. stop(): void;
  29886. /**
  29887. * Remove all active particles
  29888. */
  29889. reset(): void;
  29890. /**
  29891. * Returns the string "GPUParticleSystem"
  29892. * @returns a string containing the class name
  29893. */
  29894. getClassName(): string;
  29895. private _colorGradientsTexture;
  29896. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  29897. /**
  29898. * Adds a new color gradient
  29899. * @param gradient defines the gradient to use (between 0 and 1)
  29900. * @param color1 defines the color to affect to the specified gradient
  29901. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  29902. * @returns the current particle system
  29903. */
  29904. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  29905. /**
  29906. * Remove a specific color gradient
  29907. * @param gradient defines the gradient to remove
  29908. * @returns the current particle system
  29909. */
  29910. removeColorGradient(gradient: number): GPUParticleSystem;
  29911. private _angularSpeedGradientsTexture;
  29912. private _sizeGradientsTexture;
  29913. private _velocityGradientsTexture;
  29914. private _limitVelocityGradientsTexture;
  29915. private _dragGradientsTexture;
  29916. private _addFactorGradient;
  29917. /**
  29918. * Adds a new size gradient
  29919. * @param gradient defines the gradient to use (between 0 and 1)
  29920. * @param factor defines the size factor to affect to the specified gradient
  29921. * @returns the current particle system
  29922. */
  29923. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  29924. /**
  29925. * Remove a specific size gradient
  29926. * @param gradient defines the gradient to remove
  29927. * @returns the current particle system
  29928. */
  29929. removeSizeGradient(gradient: number): GPUParticleSystem;
  29930. /**
  29931. * Adds a new angular speed gradient
  29932. * @param gradient defines the gradient to use (between 0 and 1)
  29933. * @param factor defines the angular speed to affect to the specified gradient
  29934. * @returns the current particle system
  29935. */
  29936. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  29937. /**
  29938. * Remove a specific angular speed gradient
  29939. * @param gradient defines the gradient to remove
  29940. * @returns the current particle system
  29941. */
  29942. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  29943. /**
  29944. * Adds a new velocity gradient
  29945. * @param gradient defines the gradient to use (between 0 and 1)
  29946. * @param factor defines the velocity to affect to the specified gradient
  29947. * @returns the current particle system
  29948. */
  29949. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  29950. /**
  29951. * Remove a specific velocity gradient
  29952. * @param gradient defines the gradient to remove
  29953. * @returns the current particle system
  29954. */
  29955. removeVelocityGradient(gradient: number): GPUParticleSystem;
  29956. /**
  29957. * Adds a new limit velocity gradient
  29958. * @param gradient defines the gradient to use (between 0 and 1)
  29959. * @param factor defines the limit velocity value to affect to the specified gradient
  29960. * @returns the current particle system
  29961. */
  29962. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  29963. /**
  29964. * Remove a specific limit velocity gradient
  29965. * @param gradient defines the gradient to remove
  29966. * @returns the current particle system
  29967. */
  29968. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  29969. /**
  29970. * Adds a new drag gradient
  29971. * @param gradient defines the gradient to use (between 0 and 1)
  29972. * @param factor defines the drag value to affect to the specified gradient
  29973. * @returns the current particle system
  29974. */
  29975. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  29976. /**
  29977. * Remove a specific drag gradient
  29978. * @param gradient defines the gradient to remove
  29979. * @returns the current particle system
  29980. */
  29981. removeDragGradient(gradient: number): GPUParticleSystem;
  29982. /**
  29983. * Not supported by GPUParticleSystem
  29984. * @param gradient defines the gradient to use (between 0 and 1)
  29985. * @param factor defines the emit rate value to affect to the specified gradient
  29986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29987. * @returns the current particle system
  29988. */
  29989. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29990. /**
  29991. * Not supported by GPUParticleSystem
  29992. * @param gradient defines the gradient to remove
  29993. * @returns the current particle system
  29994. */
  29995. removeEmitRateGradient(gradient: number): IParticleSystem;
  29996. /**
  29997. * Not supported by GPUParticleSystem
  29998. * @param gradient defines the gradient to use (between 0 and 1)
  29999. * @param factor defines the start size value to affect to the specified gradient
  30000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30001. * @returns the current particle system
  30002. */
  30003. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30004. /**
  30005. * Not supported by GPUParticleSystem
  30006. * @param gradient defines the gradient to remove
  30007. * @returns the current particle system
  30008. */
  30009. removeStartSizeGradient(gradient: number): IParticleSystem;
  30010. /**
  30011. * Not supported by GPUParticleSystem
  30012. * @param gradient defines the gradient to use (between 0 and 1)
  30013. * @param min defines the color remap minimal range
  30014. * @param max defines the color remap maximal range
  30015. * @returns the current particle system
  30016. */
  30017. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30018. /**
  30019. * Not supported by GPUParticleSystem
  30020. * @param gradient defines the gradient to remove
  30021. * @returns the current particle system
  30022. */
  30023. removeColorRemapGradient(gradient: number): IParticleSystem;
  30024. /**
  30025. * Not supported by GPUParticleSystem
  30026. * @param gradient defines the gradient to use (between 0 and 1)
  30027. * @param min defines the alpha remap minimal range
  30028. * @param max defines the alpha remap maximal range
  30029. * @returns the current particle system
  30030. */
  30031. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30032. /**
  30033. * Not supported by GPUParticleSystem
  30034. * @param gradient defines the gradient to remove
  30035. * @returns the current particle system
  30036. */
  30037. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30038. /**
  30039. * Not supported by GPUParticleSystem
  30040. * @param gradient defines the gradient to use (between 0 and 1)
  30041. * @param color defines the color to affect to the specified gradient
  30042. * @returns the current particle system
  30043. */
  30044. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30045. /**
  30046. * Not supported by GPUParticleSystem
  30047. * @param gradient defines the gradient to remove
  30048. * @returns the current particle system
  30049. */
  30050. removeRampGradient(gradient: number): IParticleSystem;
  30051. /**
  30052. * Not supported by GPUParticleSystem
  30053. * @returns the list of ramp gradients
  30054. */
  30055. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30056. /**
  30057. * Not supported by GPUParticleSystem
  30058. * Gets or sets a boolean indicating that ramp gradients must be used
  30059. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30060. */
  30061. useRampGradients: boolean;
  30062. /**
  30063. * Not supported by GPUParticleSystem
  30064. * @param gradient defines the gradient to use (between 0 and 1)
  30065. * @param factor defines the life time factor to affect to the specified gradient
  30066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30067. * @returns the current particle system
  30068. */
  30069. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30070. /**
  30071. * Not supported by GPUParticleSystem
  30072. * @param gradient defines the gradient to remove
  30073. * @returns the current particle system
  30074. */
  30075. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30076. /**
  30077. * Instantiates a GPU particle system.
  30078. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  30079. * @param name The name of the particle system
  30080. * @param options The options used to create the system
  30081. * @param scene The scene the particle system belongs to
  30082. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30083. */
  30084. constructor(name: string, options: Partial<{
  30085. capacity: number;
  30086. randomTextureSize: number;
  30087. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30088. protected _reset(): void;
  30089. private _createUpdateVAO;
  30090. private _createRenderVAO;
  30091. private _initialize;
  30092. /** @hidden */
  30093. _recreateUpdateEffect(): void;
  30094. /** @hidden */
  30095. _recreateRenderEffect(): void;
  30096. /**
  30097. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30098. * @param preWarm defines if we are in the pre-warmimg phase
  30099. */
  30100. animate(preWarm?: boolean): void;
  30101. private _createFactorGradientTexture;
  30102. private _createSizeGradientTexture;
  30103. private _createAngularSpeedGradientTexture;
  30104. private _createVelocityGradientTexture;
  30105. private _createLimitVelocityGradientTexture;
  30106. private _createDragGradientTexture;
  30107. private _createColorGradientTexture;
  30108. /**
  30109. * Renders the particle system in its current state
  30110. * @param preWarm defines if the system should only update the particles but not render them
  30111. * @returns the current number of particles
  30112. */
  30113. render(preWarm?: boolean): number;
  30114. /**
  30115. * Rebuilds the particle system
  30116. */
  30117. rebuild(): void;
  30118. private _releaseBuffers;
  30119. private _releaseVAOs;
  30120. /**
  30121. * Disposes the particle system and free the associated resources
  30122. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30123. */
  30124. dispose(disposeTexture?: boolean): void;
  30125. /**
  30126. * Clones the particle system.
  30127. * @param name The name of the cloned object
  30128. * @param newEmitter The new emitter to use
  30129. * @returns the cloned particle system
  30130. */
  30131. clone(name: string, newEmitter: any): GPUParticleSystem;
  30132. /**
  30133. * Serializes the particle system to a JSON object.
  30134. * @returns the JSON object
  30135. */
  30136. serialize(): any;
  30137. /**
  30138. * Parses a JSON object to create a GPU particle system.
  30139. * @param parsedParticleSystem The JSON object to parse
  30140. * @param scene The scene to create the particle system in
  30141. * @param rootUrl The root url to use to load external dependencies like texture
  30142. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30143. * @returns the parsed GPU particle system
  30144. */
  30145. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30146. }
  30147. }
  30148. declare module BABYLON {
  30149. /**
  30150. * Interface representing a particle system in Babylon.js.
  30151. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30152. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30153. */
  30154. interface IParticleSystem {
  30155. /**
  30156. * List of animations used by the particle system.
  30157. */
  30158. animations: Animation[];
  30159. /**
  30160. * The id of the Particle system.
  30161. */
  30162. id: string;
  30163. /**
  30164. * The name of the Particle system.
  30165. */
  30166. name: string;
  30167. /**
  30168. * The emitter represents the Mesh or position we are attaching the particle system to.
  30169. */
  30170. emitter: Nullable<AbstractMesh | Vector3>;
  30171. /**
  30172. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30173. */
  30174. isBillboardBased: boolean;
  30175. /**
  30176. * The rendering group used by the Particle system to chose when to render.
  30177. */
  30178. renderingGroupId: number;
  30179. /**
  30180. * The layer mask we are rendering the particles through.
  30181. */
  30182. layerMask: number;
  30183. /**
  30184. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30185. */
  30186. updateSpeed: number;
  30187. /**
  30188. * The amount of time the particle system is running (depends of the overall update speed).
  30189. */
  30190. targetStopDuration: number;
  30191. /**
  30192. * The texture used to render each particle. (this can be a spritesheet)
  30193. */
  30194. particleTexture: Nullable<Texture>;
  30195. /**
  30196. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  30197. */
  30198. blendMode: number;
  30199. /**
  30200. * Minimum life time of emitting particles.
  30201. */
  30202. minLifeTime: number;
  30203. /**
  30204. * Maximum life time of emitting particles.
  30205. */
  30206. maxLifeTime: number;
  30207. /**
  30208. * Minimum Size of emitting particles.
  30209. */
  30210. minSize: number;
  30211. /**
  30212. * Maximum Size of emitting particles.
  30213. */
  30214. maxSize: number;
  30215. /**
  30216. * Minimum scale of emitting particles on X axis.
  30217. */
  30218. minScaleX: number;
  30219. /**
  30220. * Maximum scale of emitting particles on X axis.
  30221. */
  30222. maxScaleX: number;
  30223. /**
  30224. * Minimum scale of emitting particles on Y axis.
  30225. */
  30226. minScaleY: number;
  30227. /**
  30228. * Maximum scale of emitting particles on Y axis.
  30229. */
  30230. maxScaleY: number;
  30231. /**
  30232. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30233. */
  30234. color1: Color4;
  30235. /**
  30236. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30237. */
  30238. color2: Color4;
  30239. /**
  30240. * Color the particle will have at the end of its lifetime.
  30241. */
  30242. colorDead: Color4;
  30243. /**
  30244. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  30245. */
  30246. emitRate: number;
  30247. /**
  30248. * You can use gravity if you want to give an orientation to your particles.
  30249. */
  30250. gravity: Vector3;
  30251. /**
  30252. * Minimum power of emitting particles.
  30253. */
  30254. minEmitPower: number;
  30255. /**
  30256. * Maximum power of emitting particles.
  30257. */
  30258. maxEmitPower: number;
  30259. /**
  30260. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30261. */
  30262. minAngularSpeed: number;
  30263. /**
  30264. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30265. */
  30266. maxAngularSpeed: number;
  30267. /**
  30268. * Gets or sets the minimal initial rotation in radians.
  30269. */
  30270. minInitialRotation: number;
  30271. /**
  30272. * Gets or sets the maximal initial rotation in radians.
  30273. */
  30274. maxInitialRotation: number;
  30275. /**
  30276. * The particle emitter type defines the emitter used by the particle system.
  30277. * It can be for example box, sphere, or cone...
  30278. */
  30279. particleEmitterType: Nullable<IParticleEmitterType>;
  30280. /**
  30281. * Defines the delay in milliseconds before starting the system (0 by default)
  30282. */
  30283. startDelay: number;
  30284. /**
  30285. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  30286. */
  30287. preWarmCycles: number;
  30288. /**
  30289. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  30290. */
  30291. preWarmStepOffset: number;
  30292. /**
  30293. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  30294. */
  30295. spriteCellChangeSpeed: number;
  30296. /**
  30297. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30298. */
  30299. startSpriteCellID: number;
  30300. /**
  30301. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30302. */
  30303. endSpriteCellID: number;
  30304. /**
  30305. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30306. */
  30307. spriteCellWidth: number;
  30308. /**
  30309. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30310. */
  30311. spriteCellHeight: number;
  30312. /**
  30313. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30314. */
  30315. spriteRandomStartCell: boolean;
  30316. /**
  30317. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  30318. */
  30319. isAnimationSheetEnabled: boolean;
  30320. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30321. translationPivot: Vector2;
  30322. /**
  30323. * Gets or sets a texture used to add random noise to particle positions
  30324. */
  30325. noiseTexture: Nullable<BaseTexture>;
  30326. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30327. noiseStrength: Vector3;
  30328. /**
  30329. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30330. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30331. */
  30332. billboardMode: number;
  30333. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30334. limitVelocityDamping: number;
  30335. /**
  30336. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30337. */
  30338. beginAnimationOnStart: boolean;
  30339. /**
  30340. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30341. */
  30342. beginAnimationFrom: number;
  30343. /**
  30344. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30345. */
  30346. beginAnimationTo: number;
  30347. /**
  30348. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30349. */
  30350. beginAnimationLoop: boolean;
  30351. /**
  30352. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30353. */
  30354. disposeOnStop: boolean;
  30355. /**
  30356. * Gets the maximum number of particles active at the same time.
  30357. * @returns The max number of active particles.
  30358. */
  30359. getCapacity(): number;
  30360. /**
  30361. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30362. * @returns True if it has been started, otherwise false.
  30363. */
  30364. isStarted(): boolean;
  30365. /**
  30366. * Animates the particle system for this frame.
  30367. */
  30368. animate(): void;
  30369. /**
  30370. * Renders the particle system in its current state.
  30371. * @returns the current number of particles
  30372. */
  30373. render(): number;
  30374. /**
  30375. * Dispose the particle system and frees its associated resources.
  30376. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30377. */
  30378. dispose(disposeTexture?: boolean): void;
  30379. /**
  30380. * Clones the particle system.
  30381. * @param name The name of the cloned object
  30382. * @param newEmitter The new emitter to use
  30383. * @returns the cloned particle system
  30384. */
  30385. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  30386. /**
  30387. * Serializes the particle system to a JSON object.
  30388. * @returns the JSON object
  30389. */
  30390. serialize(): any;
  30391. /**
  30392. * Rebuild the particle system
  30393. */
  30394. rebuild(): void;
  30395. /**
  30396. * Starts the particle system and begins to emit
  30397. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  30398. */
  30399. start(delay?: number): void;
  30400. /**
  30401. * Stops the particle system.
  30402. */
  30403. stop(): void;
  30404. /**
  30405. * Remove all active particles
  30406. */
  30407. reset(): void;
  30408. /**
  30409. * Is this system ready to be used/rendered
  30410. * @return true if the system is ready
  30411. */
  30412. isReady(): boolean;
  30413. /**
  30414. * Adds a new color gradient
  30415. * @param gradient defines the gradient to use (between 0 and 1)
  30416. * @param color1 defines the color to affect to the specified gradient
  30417. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30418. * @returns the current particle system
  30419. */
  30420. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  30421. /**
  30422. * Remove a specific color gradient
  30423. * @param gradient defines the gradient to remove
  30424. * @returns the current particle system
  30425. */
  30426. removeColorGradient(gradient: number): IParticleSystem;
  30427. /**
  30428. * Adds a new size gradient
  30429. * @param gradient defines the gradient to use (between 0 and 1)
  30430. * @param factor defines the size factor to affect to the specified gradient
  30431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30432. * @returns the current particle system
  30433. */
  30434. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30435. /**
  30436. * Remove a specific size gradient
  30437. * @param gradient defines the gradient to remove
  30438. * @returns the current particle system
  30439. */
  30440. removeSizeGradient(gradient: number): IParticleSystem;
  30441. /**
  30442. * Gets the current list of color gradients.
  30443. * You must use addColorGradient and removeColorGradient to udpate this list
  30444. * @returns the list of color gradients
  30445. */
  30446. getColorGradients(): Nullable<Array<ColorGradient>>;
  30447. /**
  30448. * Gets the current list of size gradients.
  30449. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30450. * @returns the list of size gradients
  30451. */
  30452. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30453. /**
  30454. * Gets the current list of angular speed gradients.
  30455. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30456. * @returns the list of angular speed gradients
  30457. */
  30458. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30459. /**
  30460. * Adds a new angular speed gradient
  30461. * @param gradient defines the gradient to use (between 0 and 1)
  30462. * @param factor defines the angular speed to affect to the specified gradient
  30463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30464. * @returns the current particle system
  30465. */
  30466. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30467. /**
  30468. * Remove a specific angular speed gradient
  30469. * @param gradient defines the gradient to remove
  30470. * @returns the current particle system
  30471. */
  30472. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  30473. /**
  30474. * Gets the current list of velocity gradients.
  30475. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30476. * @returns the list of velocity gradients
  30477. */
  30478. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30479. /**
  30480. * Adds a new velocity gradient
  30481. * @param gradient defines the gradient to use (between 0 and 1)
  30482. * @param factor defines the velocity to affect to the specified gradient
  30483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30484. * @returns the current particle system
  30485. */
  30486. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30487. /**
  30488. * Remove a specific velocity gradient
  30489. * @param gradient defines the gradient to remove
  30490. * @returns the current particle system
  30491. */
  30492. removeVelocityGradient(gradient: number): IParticleSystem;
  30493. /**
  30494. * Gets the current list of limit velocity gradients.
  30495. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30496. * @returns the list of limit velocity gradients
  30497. */
  30498. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30499. /**
  30500. * Adds a new limit velocity gradient
  30501. * @param gradient defines the gradient to use (between 0 and 1)
  30502. * @param factor defines the limit velocity to affect to the specified gradient
  30503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30504. * @returns the current particle system
  30505. */
  30506. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30507. /**
  30508. * Remove a specific limit velocity gradient
  30509. * @param gradient defines the gradient to remove
  30510. * @returns the current particle system
  30511. */
  30512. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  30513. /**
  30514. * Adds a new drag gradient
  30515. * @param gradient defines the gradient to use (between 0 and 1)
  30516. * @param factor defines the drag to affect to the specified gradient
  30517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30518. * @returns the current particle system
  30519. */
  30520. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30521. /**
  30522. * Remove a specific drag gradient
  30523. * @param gradient defines the gradient to remove
  30524. * @returns the current particle system
  30525. */
  30526. removeDragGradient(gradient: number): IParticleSystem;
  30527. /**
  30528. * Gets the current list of drag gradients.
  30529. * You must use addDragGradient and removeDragGradient to udpate this list
  30530. * @returns the list of drag gradients
  30531. */
  30532. getDragGradients(): Nullable<Array<FactorGradient>>;
  30533. /**
  30534. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  30535. * @param gradient defines the gradient to use (between 0 and 1)
  30536. * @param factor defines the emit rate to affect to the specified gradient
  30537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30538. * @returns the current particle system
  30539. */
  30540. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30541. /**
  30542. * Remove a specific emit rate gradient
  30543. * @param gradient defines the gradient to remove
  30544. * @returns the current particle system
  30545. */
  30546. removeEmitRateGradient(gradient: number): IParticleSystem;
  30547. /**
  30548. * Gets the current list of emit rate gradients.
  30549. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30550. * @returns the list of emit rate gradients
  30551. */
  30552. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30553. /**
  30554. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  30555. * @param gradient defines the gradient to use (between 0 and 1)
  30556. * @param factor defines the start size to affect to the specified gradient
  30557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30558. * @returns the current particle system
  30559. */
  30560. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30561. /**
  30562. * Remove a specific start size gradient
  30563. * @param gradient defines the gradient to remove
  30564. * @returns the current particle system
  30565. */
  30566. removeStartSizeGradient(gradient: number): IParticleSystem;
  30567. /**
  30568. * Gets the current list of start size gradients.
  30569. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30570. * @returns the list of start size gradients
  30571. */
  30572. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30573. /**
  30574. * Adds a new life time gradient
  30575. * @param gradient defines the gradient to use (between 0 and 1)
  30576. * @param factor defines the life time factor to affect to the specified gradient
  30577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30578. * @returns the current particle system
  30579. */
  30580. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30581. /**
  30582. * Remove a specific life time gradient
  30583. * @param gradient defines the gradient to remove
  30584. * @returns the current particle system
  30585. */
  30586. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30587. /**
  30588. * Gets the current list of life time gradients.
  30589. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30590. * @returns the list of life time gradients
  30591. */
  30592. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30593. /**
  30594. * Gets the current list of color gradients.
  30595. * You must use addColorGradient and removeColorGradient to udpate this list
  30596. * @returns the list of color gradients
  30597. */
  30598. getColorGradients(): Nullable<Array<ColorGradient>>;
  30599. /**
  30600. * Adds a new ramp gradient used to remap particle colors
  30601. * @param gradient defines the gradient to use (between 0 and 1)
  30602. * @param color defines the color to affect to the specified gradient
  30603. * @returns the current particle system
  30604. */
  30605. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30606. /**
  30607. * Gets the current list of ramp gradients.
  30608. * You must use addRampGradient and removeRampGradient to udpate this list
  30609. * @returns the list of ramp gradients
  30610. */
  30611. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30612. /** Gets or sets a boolean indicating that ramp gradients must be used
  30613. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30614. */
  30615. useRampGradients: boolean;
  30616. /**
  30617. * Adds a new color remap gradient
  30618. * @param gradient defines the gradient to use (between 0 and 1)
  30619. * @param min defines the color remap minimal range
  30620. * @param max defines the color remap maximal range
  30621. * @returns the current particle system
  30622. */
  30623. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30624. /**
  30625. * Gets the current list of color remap gradients.
  30626. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30627. * @returns the list of color remap gradients
  30628. */
  30629. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30630. /**
  30631. * Adds a new alpha remap gradient
  30632. * @param gradient defines the gradient to use (between 0 and 1)
  30633. * @param min defines the alpha remap minimal range
  30634. * @param max defines the alpha remap maximal range
  30635. * @returns the current particle system
  30636. */
  30637. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30638. /**
  30639. * Gets the current list of alpha remap gradients.
  30640. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30641. * @returns the list of alpha remap gradients
  30642. */
  30643. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30644. /**
  30645. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30646. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30647. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30648. * @returns the emitter
  30649. */
  30650. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30651. /**
  30652. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30653. * @param radius The radius of the hemisphere to emit from
  30654. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30655. * @returns the emitter
  30656. */
  30657. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  30658. /**
  30659. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30660. * @param radius The radius of the sphere to emit from
  30661. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30662. * @returns the emitter
  30663. */
  30664. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  30665. /**
  30666. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30667. * @param radius The radius of the sphere to emit from
  30668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30670. * @returns the emitter
  30671. */
  30672. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  30673. /**
  30674. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30675. * @param radius The radius of the emission cylinder
  30676. * @param height The height of the emission cylinder
  30677. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30678. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30679. * @returns the emitter
  30680. */
  30681. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  30682. /**
  30683. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30684. * @param radius The radius of the cylinder to emit from
  30685. * @param height The height of the emission cylinder
  30686. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30689. * @returns the emitter
  30690. */
  30691. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  30692. /**
  30693. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30694. * @param radius The radius of the cone to emit from
  30695. * @param angle The base angle of the cone
  30696. * @returns the emitter
  30697. */
  30698. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  30699. /**
  30700. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30701. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30702. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30703. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30704. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30705. * @returns the emitter
  30706. */
  30707. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30708. /**
  30709. * Get hosting scene
  30710. * @returns the scene
  30711. */
  30712. getScene(): Scene;
  30713. }
  30714. }
  30715. declare module BABYLON {
  30716. /**
  30717. * A particle represents one of the element emitted by a particle system.
  30718. * This is mainly define by its coordinates, direction, velocity and age.
  30719. */
  30720. class Particle {
  30721. /**
  30722. * The particle system the particle belongs to.
  30723. */
  30724. particleSystem: ParticleSystem;
  30725. private static _Count;
  30726. /**
  30727. * Unique ID of the particle
  30728. */
  30729. id: number;
  30730. /**
  30731. * The world position of the particle in the scene.
  30732. */
  30733. position: Vector3;
  30734. /**
  30735. * The world direction of the particle in the scene.
  30736. */
  30737. direction: Vector3;
  30738. /**
  30739. * The color of the particle.
  30740. */
  30741. color: Color4;
  30742. /**
  30743. * The color change of the particle per step.
  30744. */
  30745. colorStep: Color4;
  30746. /**
  30747. * Defines how long will the life of the particle be.
  30748. */
  30749. lifeTime: number;
  30750. /**
  30751. * The current age of the particle.
  30752. */
  30753. age: number;
  30754. /**
  30755. * The current size of the particle.
  30756. */
  30757. size: number;
  30758. /**
  30759. * The current scale of the particle.
  30760. */
  30761. scale: Vector2;
  30762. /**
  30763. * The current angle of the particle.
  30764. */
  30765. angle: number;
  30766. /**
  30767. * Defines how fast is the angle changing.
  30768. */
  30769. angularSpeed: number;
  30770. /**
  30771. * Defines the cell index used by the particle to be rendered from a sprite.
  30772. */
  30773. cellIndex: number;
  30774. /**
  30775. * The information required to support color remapping
  30776. */
  30777. remapData: Vector4;
  30778. /** @hidden */
  30779. _randomCellOffset?: number;
  30780. /** @hidden */
  30781. _initialDirection: Nullable<Vector3>;
  30782. /** @hidden */
  30783. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  30784. /** @hidden */
  30785. _initialStartSpriteCellID: number;
  30786. /** @hidden */
  30787. _initialEndSpriteCellID: number;
  30788. /** @hidden */
  30789. _currentColorGradient: Nullable<ColorGradient>;
  30790. /** @hidden */
  30791. _currentColor1: Color4;
  30792. /** @hidden */
  30793. _currentColor2: Color4;
  30794. /** @hidden */
  30795. _currentSizeGradient: Nullable<FactorGradient>;
  30796. /** @hidden */
  30797. _currentSize1: number;
  30798. /** @hidden */
  30799. _currentSize2: number;
  30800. /** @hidden */
  30801. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  30802. /** @hidden */
  30803. _currentAngularSpeed1: number;
  30804. /** @hidden */
  30805. _currentAngularSpeed2: number;
  30806. /** @hidden */
  30807. _currentVelocityGradient: Nullable<FactorGradient>;
  30808. /** @hidden */
  30809. _currentVelocity1: number;
  30810. /** @hidden */
  30811. _currentVelocity2: number;
  30812. /** @hidden */
  30813. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  30814. /** @hidden */
  30815. _currentLimitVelocity1: number;
  30816. /** @hidden */
  30817. _currentLimitVelocity2: number;
  30818. /** @hidden */
  30819. _currentDragGradient: Nullable<FactorGradient>;
  30820. /** @hidden */
  30821. _currentDrag1: number;
  30822. /** @hidden */
  30823. _currentDrag2: number;
  30824. /** @hidden */
  30825. _randomNoiseCoordinates1: Vector3;
  30826. /** @hidden */
  30827. _randomNoiseCoordinates2: Vector3;
  30828. /**
  30829. * Creates a new instance Particle
  30830. * @param particleSystem the particle system the particle belongs to
  30831. */
  30832. constructor(
  30833. /**
  30834. * The particle system the particle belongs to.
  30835. */
  30836. particleSystem: ParticleSystem);
  30837. private updateCellInfoFromSystem;
  30838. /**
  30839. * Defines how the sprite cell index is updated for the particle
  30840. */
  30841. updateCellIndex(): void;
  30842. /** @hidden */
  30843. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  30844. /** @hidden */
  30845. _inheritParticleInfoToSubEmitters(): void;
  30846. /** @hidden */
  30847. _reset(): void;
  30848. /**
  30849. * Copy the properties of particle to another one.
  30850. * @param other the particle to copy the information to.
  30851. */
  30852. copyTo(other: Particle): void;
  30853. }
  30854. }
  30855. declare module BABYLON {
  30856. /**
  30857. * This class is made for on one-liner static method to help creating particle system set.
  30858. */
  30859. class ParticleHelper {
  30860. /**
  30861. * Gets or sets base Assets URL
  30862. */
  30863. static BaseAssetsUrl: string;
  30864. /**
  30865. * Create a default particle system that you can tweak
  30866. * @param emitter defines the emitter to use
  30867. * @param capacity defines the system capacity (default is 500 particles)
  30868. * @param scene defines the hosting scene
  30869. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  30870. * @returns the new Particle system
  30871. */
  30872. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  30873. /**
  30874. * This is the main static method (one-liner) of this helper to create different particle systems
  30875. * @param type This string represents the type to the particle system to create
  30876. * @param scene The scene where the particle system should live
  30877. * @param gpu If the system will use gpu
  30878. * @returns the ParticleSystemSet created
  30879. */
  30880. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  30881. /**
  30882. * Static function used to export a particle system to a ParticleSystemSet variable.
  30883. * Please note that the emitter shape is not exported
  30884. * @param systems defines the particle systems to export
  30885. * @returns the created particle system set
  30886. */
  30887. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  30888. }
  30889. }
  30890. declare module BABYLON {
  30891. /**
  30892. * This represents a particle system in Babylon.
  30893. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  30894. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30895. * @example https://doc.babylonjs.com/babylon101/particles
  30896. */
  30897. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  30898. /**
  30899. * Billboard mode will only apply to Y axis
  30900. */
  30901. static readonly BILLBOARDMODE_Y: number;
  30902. /**
  30903. * Billboard mode will apply to all axes
  30904. */
  30905. static readonly BILLBOARDMODE_ALL: number;
  30906. /**
  30907. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  30908. */
  30909. static readonly BILLBOARDMODE_STRETCHED: number;
  30910. /**
  30911. * This function can be defined to provide custom update for active particles.
  30912. * This function will be called instead of regular update (age, position, color, etc.).
  30913. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  30914. */
  30915. updateFunction: (particles: Particle[]) => void;
  30916. private _emitterWorldMatrix;
  30917. /**
  30918. * This function can be defined to specify initial direction for every new particle.
  30919. * It by default use the emitterType defined function
  30920. */
  30921. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  30922. /**
  30923. * This function can be defined to specify initial position for every new particle.
  30924. * It by default use the emitterType defined function
  30925. */
  30926. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  30927. /**
  30928. * @hidden
  30929. */
  30930. _inheritedVelocityOffset: Vector3;
  30931. /**
  30932. * An event triggered when the system is disposed
  30933. */
  30934. onDisposeObservable: Observable<ParticleSystem>;
  30935. private _onDisposeObserver;
  30936. /**
  30937. * Sets a callback that will be triggered when the system is disposed
  30938. */
  30939. onDispose: () => void;
  30940. private _particles;
  30941. private _epsilon;
  30942. private _capacity;
  30943. private _stockParticles;
  30944. private _newPartsExcess;
  30945. private _vertexData;
  30946. private _vertexBuffer;
  30947. private _vertexBuffers;
  30948. private _spriteBuffer;
  30949. private _indexBuffer;
  30950. private _effect;
  30951. private _customEffect;
  30952. private _cachedDefines;
  30953. private _scaledColorStep;
  30954. private _colorDiff;
  30955. private _scaledDirection;
  30956. private _scaledGravity;
  30957. private _currentRenderId;
  30958. private _alive;
  30959. private _useInstancing;
  30960. private _started;
  30961. private _stopped;
  30962. private _actualFrame;
  30963. private _scaledUpdateSpeed;
  30964. private _vertexBufferSize;
  30965. /** @hidden */
  30966. _currentEmitRateGradient: Nullable<FactorGradient>;
  30967. /** @hidden */
  30968. _currentEmitRate1: number;
  30969. /** @hidden */
  30970. _currentEmitRate2: number;
  30971. /** @hidden */
  30972. _currentStartSizeGradient: Nullable<FactorGradient>;
  30973. /** @hidden */
  30974. _currentStartSize1: number;
  30975. /** @hidden */
  30976. _currentStartSize2: number;
  30977. private readonly _rawTextureWidth;
  30978. private _rampGradientsTexture;
  30979. private _useRampGradients;
  30980. /** Gets or sets a boolean indicating that ramp gradients must be used
  30981. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30982. */
  30983. useRampGradients: boolean;
  30984. /**
  30985. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  30986. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  30987. */
  30988. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  30989. private _subEmitters;
  30990. /**
  30991. * @hidden
  30992. * If the particle systems emitter should be disposed when the particle system is disposed
  30993. */
  30994. _disposeEmitterOnDispose: boolean;
  30995. /**
  30996. * The current active Sub-systems, this property is used by the root particle system only.
  30997. */
  30998. activeSubSystems: Array<ParticleSystem>;
  30999. private _rootParticleSystem;
  31000. /**
  31001. * Gets the current list of active particles
  31002. */
  31003. readonly particles: Particle[];
  31004. /**
  31005. * Returns the string "ParticleSystem"
  31006. * @returns a string containing the class name
  31007. */
  31008. getClassName(): string;
  31009. /**
  31010. * Instantiates a particle system.
  31011. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  31012. * @param name The name of the particle system
  31013. * @param capacity The max number of particles alive at the same time
  31014. * @param scene The scene the particle system belongs to
  31015. * @param customEffect a custom effect used to change the way particles are rendered by default
  31016. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31017. * @param epsilon Offset used to render the particles
  31018. */
  31019. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31020. private _addFactorGradient;
  31021. private _removeFactorGradient;
  31022. /**
  31023. * Adds a new life time gradient
  31024. * @param gradient defines the gradient to use (between 0 and 1)
  31025. * @param factor defines the life time factor to affect to the specified gradient
  31026. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31027. * @returns the current particle system
  31028. */
  31029. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31030. /**
  31031. * Remove a specific life time gradient
  31032. * @param gradient defines the gradient to remove
  31033. * @returns the current particle system
  31034. */
  31035. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31036. /**
  31037. * Adds a new size gradient
  31038. * @param gradient defines the gradient to use (between 0 and 1)
  31039. * @param factor defines the size factor to affect to the specified gradient
  31040. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31041. * @returns the current particle system
  31042. */
  31043. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31044. /**
  31045. * Remove a specific size gradient
  31046. * @param gradient defines the gradient to remove
  31047. * @returns the current particle system
  31048. */
  31049. removeSizeGradient(gradient: number): IParticleSystem;
  31050. /**
  31051. * Adds a new color remap gradient
  31052. * @param gradient defines the gradient to use (between 0 and 1)
  31053. * @param min defines the color remap minimal range
  31054. * @param max defines the color remap maximal range
  31055. * @returns the current particle system
  31056. */
  31057. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31058. /**
  31059. * Remove a specific color remap gradient
  31060. * @param gradient defines the gradient to remove
  31061. * @returns the current particle system
  31062. */
  31063. removeColorRemapGradient(gradient: number): IParticleSystem;
  31064. /**
  31065. * Adds a new alpha remap gradient
  31066. * @param gradient defines the gradient to use (between 0 and 1)
  31067. * @param min defines the alpha remap minimal range
  31068. * @param max defines the alpha remap maximal range
  31069. * @returns the current particle system
  31070. */
  31071. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31072. /**
  31073. * Remove a specific alpha remap gradient
  31074. * @param gradient defines the gradient to remove
  31075. * @returns the current particle system
  31076. */
  31077. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31078. /**
  31079. * Adds a new angular speed gradient
  31080. * @param gradient defines the gradient to use (between 0 and 1)
  31081. * @param factor defines the angular speed to affect to the specified gradient
  31082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31083. * @returns the current particle system
  31084. */
  31085. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31086. /**
  31087. * Remove a specific angular speed gradient
  31088. * @param gradient defines the gradient to remove
  31089. * @returns the current particle system
  31090. */
  31091. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31092. /**
  31093. * Adds a new velocity gradient
  31094. * @param gradient defines the gradient to use (between 0 and 1)
  31095. * @param factor defines the velocity to affect to the specified gradient
  31096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31097. * @returns the current particle system
  31098. */
  31099. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31100. /**
  31101. * Remove a specific velocity gradient
  31102. * @param gradient defines the gradient to remove
  31103. * @returns the current particle system
  31104. */
  31105. removeVelocityGradient(gradient: number): IParticleSystem;
  31106. /**
  31107. * Adds a new limit velocity gradient
  31108. * @param gradient defines the gradient to use (between 0 and 1)
  31109. * @param factor defines the limit velocity value to affect to the specified gradient
  31110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31111. * @returns the current particle system
  31112. */
  31113. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31114. /**
  31115. * Remove a specific limit velocity gradient
  31116. * @param gradient defines the gradient to remove
  31117. * @returns the current particle system
  31118. */
  31119. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31120. /**
  31121. * Adds a new drag gradient
  31122. * @param gradient defines the gradient to use (between 0 and 1)
  31123. * @param factor defines the drag value to affect to the specified gradient
  31124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31125. * @returns the current particle system
  31126. */
  31127. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31128. /**
  31129. * Remove a specific drag gradient
  31130. * @param gradient defines the gradient to remove
  31131. * @returns the current particle system
  31132. */
  31133. removeDragGradient(gradient: number): IParticleSystem;
  31134. /**
  31135. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31136. * @param gradient defines the gradient to use (between 0 and 1)
  31137. * @param factor defines the emit rate value to affect to the specified gradient
  31138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31139. * @returns the current particle system
  31140. */
  31141. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31142. /**
  31143. * Remove a specific emit rate gradient
  31144. * @param gradient defines the gradient to remove
  31145. * @returns the current particle system
  31146. */
  31147. removeEmitRateGradient(gradient: number): IParticleSystem;
  31148. /**
  31149. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31150. * @param gradient defines the gradient to use (between 0 and 1)
  31151. * @param factor defines the start size value to affect to the specified gradient
  31152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31153. * @returns the current particle system
  31154. */
  31155. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31156. /**
  31157. * Remove a specific start size gradient
  31158. * @param gradient defines the gradient to remove
  31159. * @returns the current particle system
  31160. */
  31161. removeStartSizeGradient(gradient: number): IParticleSystem;
  31162. private _createRampGradientTexture;
  31163. /**
  31164. * Gets the current list of ramp gradients.
  31165. * You must use addRampGradient and removeRampGradient to udpate this list
  31166. * @returns the list of ramp gradients
  31167. */
  31168. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31169. /**
  31170. * Adds a new ramp gradient used to remap particle colors
  31171. * @param gradient defines the gradient to use (between 0 and 1)
  31172. * @param color defines the color to affect to the specified gradient
  31173. * @returns the current particle system
  31174. */
  31175. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  31176. /**
  31177. * Remove a specific ramp gradient
  31178. * @param gradient defines the gradient to remove
  31179. * @returns the current particle system
  31180. */
  31181. removeRampGradient(gradient: number): ParticleSystem;
  31182. /**
  31183. * Adds a new color gradient
  31184. * @param gradient defines the gradient to use (between 0 and 1)
  31185. * @param color1 defines the color to affect to the specified gradient
  31186. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31187. * @returns this particle system
  31188. */
  31189. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31190. /**
  31191. * Remove a specific color gradient
  31192. * @param gradient defines the gradient to remove
  31193. * @returns this particle system
  31194. */
  31195. removeColorGradient(gradient: number): IParticleSystem;
  31196. private _fetchR;
  31197. protected _reset(): void;
  31198. private _resetEffect;
  31199. private _createVertexBuffers;
  31200. private _createIndexBuffer;
  31201. /**
  31202. * Gets the maximum number of particles active at the same time.
  31203. * @returns The max number of active particles.
  31204. */
  31205. getCapacity(): number;
  31206. /**
  31207. * Gets whether there are still active particles in the system.
  31208. * @returns True if it is alive, otherwise false.
  31209. */
  31210. isAlive(): boolean;
  31211. /**
  31212. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31213. * @returns True if it has been started, otherwise false.
  31214. */
  31215. isStarted(): boolean;
  31216. private _prepareSubEmitterInternalArray;
  31217. /**
  31218. * Starts the particle system and begins to emit
  31219. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31220. */
  31221. start(delay?: number): void;
  31222. /**
  31223. * Stops the particle system.
  31224. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  31225. */
  31226. stop(stopSubEmitters?: boolean): void;
  31227. /**
  31228. * Remove all active particles
  31229. */
  31230. reset(): void;
  31231. /**
  31232. * @hidden (for internal use only)
  31233. */
  31234. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  31235. /**
  31236. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  31237. * Its lifetime will start back at 0.
  31238. */
  31239. recycleParticle: (particle: Particle) => void;
  31240. private _stopSubEmitters;
  31241. private _createParticle;
  31242. private _removeFromRoot;
  31243. private _emitFromParticle;
  31244. private _update;
  31245. /** @hidden */
  31246. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  31247. /** @hidden */
  31248. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  31249. /** @hidden */
  31250. private _getEffect;
  31251. /**
  31252. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31253. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  31254. */
  31255. animate(preWarmOnly?: boolean): void;
  31256. private _appendParticleVertices;
  31257. /**
  31258. * Rebuilds the particle system.
  31259. */
  31260. rebuild(): void;
  31261. /**
  31262. * Is this system ready to be used/rendered
  31263. * @return true if the system is ready
  31264. */
  31265. isReady(): boolean;
  31266. private _render;
  31267. /**
  31268. * Renders the particle system in its current state.
  31269. * @returns the current number of particles
  31270. */
  31271. render(): number;
  31272. /**
  31273. * Disposes the particle system and free the associated resources
  31274. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31275. */
  31276. dispose(disposeTexture?: boolean): void;
  31277. /**
  31278. * Clones the particle system.
  31279. * @param name The name of the cloned object
  31280. * @param newEmitter The new emitter to use
  31281. * @returns the cloned particle system
  31282. */
  31283. clone(name: string, newEmitter: any): ParticleSystem;
  31284. /**
  31285. * Serializes the particle system to a JSON object.
  31286. * @returns the JSON object
  31287. */
  31288. serialize(): any;
  31289. /** @hidden */
  31290. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  31291. /** @hidden */
  31292. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  31293. /**
  31294. * Parses a JSON object to create a particle system.
  31295. * @param parsedParticleSystem The JSON object to parse
  31296. * @param scene The scene to create the particle system in
  31297. * @param rootUrl The root url to use to load external dependencies like texture
  31298. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31299. * @returns the Parsed particle system
  31300. */
  31301. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  31302. }
  31303. }
  31304. declare module BABYLON {
  31305. interface Engine {
  31306. /**
  31307. * Create an effect to use with particle systems.
  31308. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  31309. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  31310. * @param uniformsNames defines a list of attribute names
  31311. * @param samplers defines an array of string used to represent textures
  31312. * @param defines defines the string containing the defines to use to compile the shaders
  31313. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31314. * @param onCompiled defines a function to call when the effect creation is successful
  31315. * @param onError defines a function to call when the effect creation has failed
  31316. * @returns the new Effect
  31317. */
  31318. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  31319. }
  31320. interface Mesh {
  31321. /**
  31322. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  31323. * @returns an array of IParticleSystem
  31324. */
  31325. getEmittedParticleSystems(): IParticleSystem[];
  31326. /**
  31327. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  31328. * @returns an array of IParticleSystem
  31329. */
  31330. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  31331. }
  31332. }
  31333. declare module BABYLON {
  31334. /**
  31335. * Represents a set of particle systems working together to create a specific effect
  31336. */
  31337. class ParticleSystemSet implements IDisposable {
  31338. private _emitterCreationOptions;
  31339. private _emitterNode;
  31340. /**
  31341. * Gets the particle system list
  31342. */
  31343. systems: IParticleSystem[];
  31344. /**
  31345. * Gets the emitter node used with this set
  31346. */
  31347. readonly emitterNode: Nullable<TransformNode>;
  31348. /**
  31349. * Creates a new emitter mesh as a sphere
  31350. * @param options defines the options used to create the sphere
  31351. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  31352. * @param scene defines the hosting scene
  31353. */
  31354. setEmitterAsSphere(options: {
  31355. diameter: number;
  31356. segments: number;
  31357. color: Color3;
  31358. }, renderingGroupId: number, scene: Scene): void;
  31359. /**
  31360. * Starts all particle systems of the set
  31361. * @param emitter defines an optional mesh to use as emitter for the particle systems
  31362. */
  31363. start(emitter?: AbstractMesh): void;
  31364. /**
  31365. * Release all associated resources
  31366. */
  31367. dispose(): void;
  31368. /**
  31369. * Serialize the set into a JSON compatible object
  31370. * @returns a JSON compatible representation of the set
  31371. */
  31372. serialize(): any;
  31373. /**
  31374. * Parse a new ParticleSystemSet from a serialized source
  31375. * @param data defines a JSON compatible representation of the set
  31376. * @param scene defines the hosting scene
  31377. * @param gpu defines if we want GPU particles or CPU particles
  31378. * @returns a new ParticleSystemSet
  31379. */
  31380. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  31381. }
  31382. }
  31383. declare module BABYLON {
  31384. /**
  31385. * Represents one particle of a solid particle system.
  31386. */
  31387. class SolidParticle {
  31388. /**
  31389. * particle global index
  31390. */
  31391. idx: number;
  31392. /**
  31393. * The color of the particle
  31394. */
  31395. color: Nullable<Color4>;
  31396. /**
  31397. * The world space position of the particle.
  31398. */
  31399. position: Vector3;
  31400. /**
  31401. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31402. */
  31403. rotation: Vector3;
  31404. /**
  31405. * The world space rotation quaternion of the particle.
  31406. */
  31407. rotationQuaternion: Nullable<Quaternion>;
  31408. /**
  31409. * The scaling of the particle.
  31410. */
  31411. scaling: Vector3;
  31412. /**
  31413. * The uvs of the particle.
  31414. */
  31415. uvs: Vector4;
  31416. /**
  31417. * The current speed of the particle.
  31418. */
  31419. velocity: Vector3;
  31420. /**
  31421. * The pivot point in the particle local space.
  31422. */
  31423. pivot: Vector3;
  31424. /**
  31425. * Must the particle be translated from its pivot point in its local space ?
  31426. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31427. * Default : false
  31428. */
  31429. translateFromPivot: boolean;
  31430. /**
  31431. * Is the particle active or not ?
  31432. */
  31433. alive: boolean;
  31434. /**
  31435. * Is the particle visible or not ?
  31436. */
  31437. isVisible: boolean;
  31438. /**
  31439. * Index of this particle in the global "positions" array (Internal use)
  31440. * @hidden
  31441. */
  31442. _pos: number;
  31443. /**
  31444. * @hidden Index of this particle in the global "indices" array (Internal use)
  31445. */
  31446. _ind: number;
  31447. /**
  31448. * @hidden ModelShape of this particle (Internal use)
  31449. */
  31450. _model: ModelShape;
  31451. /**
  31452. * ModelShape id of this particle
  31453. */
  31454. shapeId: number;
  31455. /**
  31456. * Index of the particle in its shape id (Internal use)
  31457. */
  31458. idxInShape: number;
  31459. /**
  31460. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31461. */
  31462. _modelBoundingInfo: BoundingInfo;
  31463. /**
  31464. * @hidden Particle BoundingInfo object (Internal use)
  31465. */
  31466. _boundingInfo: BoundingInfo;
  31467. /**
  31468. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31469. */
  31470. _sps: SolidParticleSystem;
  31471. /**
  31472. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31473. */
  31474. _stillInvisible: boolean;
  31475. /**
  31476. * @hidden Last computed particle rotation matrix
  31477. */
  31478. _rotationMatrix: number[];
  31479. /**
  31480. * Parent particle Id, if any.
  31481. * Default null.
  31482. */
  31483. parentId: Nullable<number>;
  31484. /**
  31485. * @hidden Internal global position in the SPS.
  31486. */
  31487. _globalPosition: Vector3;
  31488. /**
  31489. * Creates a Solid Particle object.
  31490. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31491. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  31492. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31493. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31494. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31495. * @param shapeId (integer) is the model shape identifier in the SPS.
  31496. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31497. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31498. */
  31499. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  31500. /**
  31501. * Legacy support, changed scale to scaling
  31502. */
  31503. /**
  31504. * Legacy support, changed scale to scaling
  31505. */
  31506. scale: Vector3;
  31507. /**
  31508. * Legacy support, changed quaternion to rotationQuaternion
  31509. */
  31510. /**
  31511. * Legacy support, changed quaternion to rotationQuaternion
  31512. */
  31513. quaternion: Nullable<Quaternion>;
  31514. /**
  31515. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31516. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31517. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31518. * @returns true if it intersects
  31519. */
  31520. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31521. }
  31522. /**
  31523. * Represents the shape of the model used by one particle of a solid particle system.
  31524. * SPS internal tool, don't use it manually.
  31525. */
  31526. class ModelShape {
  31527. /**
  31528. * The shape id
  31529. * @hidden
  31530. */
  31531. shapeID: number;
  31532. /**
  31533. * flat array of model positions (internal use)
  31534. * @hidden
  31535. */
  31536. _shape: Vector3[];
  31537. /**
  31538. * flat array of model UVs (internal use)
  31539. * @hidden
  31540. */
  31541. _shapeUV: number[];
  31542. /**
  31543. * length of the shape in the model indices array (internal use)
  31544. * @hidden
  31545. */
  31546. _indicesLength: number;
  31547. /**
  31548. * Custom position function (internal use)
  31549. * @hidden
  31550. */
  31551. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31552. /**
  31553. * Custom vertex function (internal use)
  31554. * @hidden
  31555. */
  31556. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31557. /**
  31558. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  31559. * SPS internal tool, don't use it manually.
  31560. * @hidden
  31561. */
  31562. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  31563. }
  31564. /**
  31565. * Represents a Depth Sorted Particle in the solid particle system.
  31566. */
  31567. class DepthSortedParticle {
  31568. /**
  31569. * Index of the particle in the "indices" array
  31570. */
  31571. ind: number;
  31572. /**
  31573. * Length of the particle shape in the "indices" array
  31574. */
  31575. indicesLength: number;
  31576. /**
  31577. * Squared distance from the particle to the camera
  31578. */
  31579. sqDistance: number;
  31580. }
  31581. }
  31582. declare module BABYLON {
  31583. /**
  31584. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31585. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  31586. * The SPS is also a particle system. It provides some methods to manage the particles.
  31587. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31588. *
  31589. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  31590. */
  31591. class SolidParticleSystem implements IDisposable {
  31592. /**
  31593. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31594. * Example : var p = SPS.particles[i];
  31595. */
  31596. particles: SolidParticle[];
  31597. /**
  31598. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31599. */
  31600. nbParticles: number;
  31601. /**
  31602. * If the particles must ever face the camera (default false). Useful for planar particles.
  31603. */
  31604. billboard: boolean;
  31605. /**
  31606. * Recompute normals when adding a shape
  31607. */
  31608. recomputeNormals: boolean;
  31609. /**
  31610. * This a counter ofr your own usage. It's not set by any SPS functions.
  31611. */
  31612. counter: number;
  31613. /**
  31614. * The SPS name. This name is also given to the underlying mesh.
  31615. */
  31616. name: string;
  31617. /**
  31618. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31619. */
  31620. mesh: Mesh;
  31621. /**
  31622. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31623. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  31624. */
  31625. vars: any;
  31626. /**
  31627. * This array is populated when the SPS is set as 'pickable'.
  31628. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31629. * Each element of this array is an object `{idx: int, faceId: int}`.
  31630. * `idx` is the picked particle index in the `SPS.particles` array
  31631. * `faceId` is the picked face index counted within this particle.
  31632. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  31633. */
  31634. pickedParticles: {
  31635. idx: number;
  31636. faceId: number;
  31637. }[];
  31638. /**
  31639. * This array is populated when `enableDepthSort` is set to true.
  31640. * Each element of this array is an instance of the class DepthSortedParticle.
  31641. */
  31642. depthSortedParticles: DepthSortedParticle[];
  31643. /**
  31644. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31645. * @hidden
  31646. */
  31647. _bSphereOnly: boolean;
  31648. /**
  31649. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31650. * @hidden
  31651. */
  31652. _bSphereRadiusFactor: number;
  31653. private _scene;
  31654. private _positions;
  31655. private _indices;
  31656. private _normals;
  31657. private _colors;
  31658. private _uvs;
  31659. private _indices32;
  31660. private _positions32;
  31661. private _normals32;
  31662. private _fixedNormal32;
  31663. private _colors32;
  31664. private _uvs32;
  31665. private _index;
  31666. private _updatable;
  31667. private _pickable;
  31668. private _isVisibilityBoxLocked;
  31669. private _alwaysVisible;
  31670. private _depthSort;
  31671. private _shapeCounter;
  31672. private _copy;
  31673. private _shape;
  31674. private _shapeUV;
  31675. private _color;
  31676. private _computeParticleColor;
  31677. private _computeParticleTexture;
  31678. private _computeParticleRotation;
  31679. private _computeParticleVertex;
  31680. private _computeBoundingBox;
  31681. private _depthSortParticles;
  31682. private _cam_axisZ;
  31683. private _cam_axisY;
  31684. private _cam_axisX;
  31685. private _axisZ;
  31686. private _camera;
  31687. private _particle;
  31688. private _camDir;
  31689. private _camInvertedPosition;
  31690. private _rotMatrix;
  31691. private _invertMatrix;
  31692. private _rotated;
  31693. private _quaternion;
  31694. private _vertex;
  31695. private _normal;
  31696. private _yaw;
  31697. private _pitch;
  31698. private _roll;
  31699. private _halfroll;
  31700. private _halfpitch;
  31701. private _halfyaw;
  31702. private _sinRoll;
  31703. private _cosRoll;
  31704. private _sinPitch;
  31705. private _cosPitch;
  31706. private _sinYaw;
  31707. private _cosYaw;
  31708. private _mustUnrotateFixedNormals;
  31709. private _minimum;
  31710. private _maximum;
  31711. private _minBbox;
  31712. private _maxBbox;
  31713. private _particlesIntersect;
  31714. private _depthSortFunction;
  31715. private _needs32Bits;
  31716. private _pivotBackTranslation;
  31717. private _scaledPivot;
  31718. private _particleHasParent;
  31719. private _parent;
  31720. /**
  31721. * Creates a SPS (Solid Particle System) object.
  31722. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31723. * @param scene (Scene) is the scene in which the SPS is added.
  31724. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31725. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31726. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31727. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31728. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31729. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31730. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31731. */
  31732. constructor(name: string, scene: Scene, options?: {
  31733. updatable?: boolean;
  31734. isPickable?: boolean;
  31735. enableDepthSort?: boolean;
  31736. particleIntersection?: boolean;
  31737. boundingSphereOnly?: boolean;
  31738. bSphereRadiusFactor?: number;
  31739. });
  31740. /**
  31741. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31742. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31743. * @returns the created mesh
  31744. */
  31745. buildMesh(): Mesh;
  31746. /**
  31747. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31748. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31749. * Thus the particles generated from `digest()` have their property `position` set yet.
  31750. * @param mesh ( Mesh ) is the mesh to be digested
  31751. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  31752. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31753. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31754. * @returns the current SPS
  31755. */
  31756. digest(mesh: Mesh, options?: {
  31757. facetNb?: number;
  31758. number?: number;
  31759. delta?: number;
  31760. }): SolidParticleSystem;
  31761. private _unrotateFixedNormals;
  31762. private _resetCopy;
  31763. private _meshBuilder;
  31764. private _posToShape;
  31765. private _uvsToShapeUV;
  31766. private _addParticle;
  31767. /**
  31768. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31769. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  31770. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31771. * @param nb (positive integer) the number of particles to be created from this model
  31772. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31773. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31774. * @returns the number of shapes in the system
  31775. */
  31776. addShape(mesh: Mesh, nb: number, options?: {
  31777. positionFunction?: any;
  31778. vertexFunction?: any;
  31779. }): number;
  31780. private _rebuildParticle;
  31781. /**
  31782. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31783. * @returns the SPS.
  31784. */
  31785. rebuildMesh(): SolidParticleSystem;
  31786. /**
  31787. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31788. * This method calls `updateParticle()` for each particle of the SPS.
  31789. * For an animated SPS, it is usually called within the render loop.
  31790. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31791. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31792. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31793. * @returns the SPS.
  31794. */
  31795. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31796. private _quaternionRotationYPR;
  31797. private _quaternionToRotationMatrix;
  31798. /**
  31799. * Disposes the SPS.
  31800. */
  31801. dispose(): void;
  31802. /**
  31803. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31805. * @returns the SPS.
  31806. */
  31807. refreshVisibleSize(): SolidParticleSystem;
  31808. /**
  31809. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31810. * @param size the size (float) of the visibility box
  31811. * note : this doesn't lock the SPS mesh bounding box.
  31812. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31813. */
  31814. setVisibilityBox(size: number): void;
  31815. /**
  31816. * Gets whether the SPS as always visible or not
  31817. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31818. */
  31819. /**
  31820. * Sets the SPS as always visible or not
  31821. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31822. */
  31823. isAlwaysVisible: boolean;
  31824. /**
  31825. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31826. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31827. */
  31828. /**
  31829. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31830. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31831. */
  31832. isVisibilityBoxLocked: boolean;
  31833. /**
  31834. * Tells to `setParticles()` to compute the particle rotations or not.
  31835. * Default value : true. The SPS is faster when it's set to false.
  31836. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31837. */
  31838. /**
  31839. * Gets if `setParticles()` computes the particle rotations or not.
  31840. * Default value : true. The SPS is faster when it's set to false.
  31841. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31842. */
  31843. computeParticleRotation: boolean;
  31844. /**
  31845. * Tells to `setParticles()` to compute the particle colors or not.
  31846. * Default value : true. The SPS is faster when it's set to false.
  31847. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31848. */
  31849. /**
  31850. * Gets if `setParticles()` computes the particle colors or not.
  31851. * Default value : true. The SPS is faster when it's set to false.
  31852. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31853. */
  31854. computeParticleColor: boolean;
  31855. /**
  31856. * Gets if `setParticles()` computes the particle textures or not.
  31857. * Default value : true. The SPS is faster when it's set to false.
  31858. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31859. */
  31860. computeParticleTexture: boolean;
  31861. /**
  31862. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31863. * Default value : false. The SPS is faster when it's set to false.
  31864. * Note : the particle custom vertex positions aren't stored values.
  31865. */
  31866. /**
  31867. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31868. * Default value : false. The SPS is faster when it's set to false.
  31869. * Note : the particle custom vertex positions aren't stored values.
  31870. */
  31871. computeParticleVertex: boolean;
  31872. /**
  31873. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31874. */
  31875. /**
  31876. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31877. */
  31878. computeBoundingBox: boolean;
  31879. /**
  31880. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31881. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31882. * Default : `true`
  31883. */
  31884. /**
  31885. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31886. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31887. * Default : `true`
  31888. */
  31889. depthSortParticles: boolean;
  31890. /**
  31891. * This function does nothing. It may be overwritten to set all the particle first values.
  31892. * The SPS doesn't call this function, you may have to call it by your own.
  31893. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31894. */
  31895. initParticles(): void;
  31896. /**
  31897. * This function does nothing. It may be overwritten to recycle a particle.
  31898. * The SPS doesn't call this function, you may have to call it by your own.
  31899. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31900. * @param particle The particle to recycle
  31901. * @returns the recycled particle
  31902. */
  31903. recycleParticle(particle: SolidParticle): SolidParticle;
  31904. /**
  31905. * Updates a particle : this function should be overwritten by the user.
  31906. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31907. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31908. * @example : just set a particle position or velocity and recycle conditions
  31909. * @param particle The particle to update
  31910. * @returns the updated particle
  31911. */
  31912. updateParticle(particle: SolidParticle): SolidParticle;
  31913. /**
  31914. * Updates a vertex of a particle : it can be overwritten by the user.
  31915. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31916. * @param particle the current particle
  31917. * @param vertex the current index of the current particle
  31918. * @param pt the index of the current vertex in the particle shape
  31919. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  31920. * @example : just set a vertex particle position
  31921. * @returns the updated vertex
  31922. */
  31923. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  31924. /**
  31925. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31926. * This does nothing and may be overwritten by the user.
  31927. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31928. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31929. * @param update the boolean update value actually passed to setParticles()
  31930. */
  31931. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31932. /**
  31933. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31934. * This will be passed three parameters.
  31935. * This does nothing and may be overwritten by the user.
  31936. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31937. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31938. * @param update the boolean update value actually passed to setParticles()
  31939. */
  31940. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31941. }
  31942. }
  31943. declare module BABYLON {
  31944. /**
  31945. * Type of sub emitter
  31946. */
  31947. enum SubEmitterType {
  31948. /**
  31949. * Attached to the particle over it's lifetime
  31950. */
  31951. ATTACHED = 0,
  31952. /**
  31953. * Created when the particle dies
  31954. */
  31955. END = 1
  31956. }
  31957. /**
  31958. * Sub emitter class used to emit particles from an existing particle
  31959. */
  31960. class SubEmitter {
  31961. /**
  31962. * the particle system to be used by the sub emitter
  31963. */
  31964. particleSystem: ParticleSystem;
  31965. /**
  31966. * Type of the submitter (Default: END)
  31967. */
  31968. type: SubEmitterType;
  31969. /**
  31970. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  31971. * Note: This only is supported when using an emitter of type Mesh
  31972. */
  31973. inheritDirection: boolean;
  31974. /**
  31975. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  31976. */
  31977. inheritedVelocityAmount: number;
  31978. /**
  31979. * Creates a sub emitter
  31980. * @param particleSystem the particle system to be used by the sub emitter
  31981. */
  31982. constructor(
  31983. /**
  31984. * the particle system to be used by the sub emitter
  31985. */
  31986. particleSystem: ParticleSystem);
  31987. /**
  31988. * Clones the sub emitter
  31989. * @returns the cloned sub emitter
  31990. */
  31991. clone(): SubEmitter;
  31992. /**
  31993. * Serialize current object to a JSON object
  31994. * @returns the serialized object
  31995. */
  31996. serialize(): any;
  31997. /**
  31998. * Creates a new SubEmitter from a serialized JSON version
  31999. * @param serializationObject defines the JSON object to read from
  32000. * @param scene defines the hosting scene
  32001. * @param rootUrl defines the rootUrl for data loading
  32002. * @returns a new SubEmitter
  32003. */
  32004. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32005. /** Release associated resources */
  32006. dispose(): void;
  32007. }
  32008. }
  32009. declare module BABYLON {
  32010. /**
  32011. * Interface used to describe a physics joint
  32012. */
  32013. interface PhysicsImpostorJoint {
  32014. /** Defines the main impostor to which the joint is linked */
  32015. mainImpostor: PhysicsImpostor;
  32016. /** Defines the impostor that is connected to the main impostor using this joint */
  32017. connectedImpostor: PhysicsImpostor;
  32018. /** Defines the joint itself */
  32019. joint: PhysicsJoint;
  32020. }
  32021. /** @hidden */
  32022. interface IPhysicsEnginePlugin {
  32023. world: any;
  32024. name: string;
  32025. setGravity(gravity: Vector3): void;
  32026. setTimeStep(timeStep: number): void;
  32027. getTimeStep(): number;
  32028. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32029. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32030. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32031. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32032. removePhysicsBody(impostor: PhysicsImpostor): void;
  32033. generateJoint(joint: PhysicsImpostorJoint): void;
  32034. removeJoint(joint: PhysicsImpostorJoint): void;
  32035. isSupported(): boolean;
  32036. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32037. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32038. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32039. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32040. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32041. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32042. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32043. getBodyMass(impostor: PhysicsImpostor): number;
  32044. getBodyFriction(impostor: PhysicsImpostor): number;
  32045. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32046. getBodyRestitution(impostor: PhysicsImpostor): number;
  32047. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32048. sleepBody(impostor: PhysicsImpostor): void;
  32049. wakeUpBody(impostor: PhysicsImpostor): void;
  32050. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32051. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32052. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32053. getRadius(impostor: PhysicsImpostor): number;
  32054. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32055. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32056. dispose(): void;
  32057. }
  32058. /**
  32059. * Interface used to define a physics engine
  32060. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32061. */
  32062. interface IPhysicsEngine {
  32063. /**
  32064. * Gets the gravity vector used by the simulation
  32065. */
  32066. gravity: Vector3;
  32067. /**
  32068. * Sets the gravity vector used by the simulation
  32069. * @param gravity defines the gravity vector to use
  32070. */
  32071. setGravity(gravity: Vector3): void;
  32072. /**
  32073. * Set the time step of the physics engine.
  32074. * Default is 1/60.
  32075. * To slow it down, enter 1/600 for example.
  32076. * To speed it up, 1/30
  32077. * @param newTimeStep the new timestep to apply to this world.
  32078. */
  32079. setTimeStep(newTimeStep: number): void;
  32080. /**
  32081. * Get the time step of the physics engine.
  32082. * @returns the current time step
  32083. */
  32084. getTimeStep(): number;
  32085. /**
  32086. * Release all resources
  32087. */
  32088. dispose(): void;
  32089. /**
  32090. * Gets the name of the current physics plugin
  32091. * @returns the name of the plugin
  32092. */
  32093. getPhysicsPluginName(): string;
  32094. /**
  32095. * Adding a new impostor for the impostor tracking.
  32096. * This will be done by the impostor itself.
  32097. * @param impostor the impostor to add
  32098. */
  32099. addImpostor(impostor: PhysicsImpostor): void;
  32100. /**
  32101. * Remove an impostor from the engine.
  32102. * This impostor and its mesh will not longer be updated by the physics engine.
  32103. * @param impostor the impostor to remove
  32104. */
  32105. removeImpostor(impostor: PhysicsImpostor): void;
  32106. /**
  32107. * Add a joint to the physics engine
  32108. * @param mainImpostor defines the main impostor to which the joint is added.
  32109. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32110. * @param joint defines the joint that will connect both impostors.
  32111. */
  32112. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32113. /**
  32114. * Removes a joint from the simulation
  32115. * @param mainImpostor defines the impostor used with the joint
  32116. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32117. * @param joint defines the joint to remove
  32118. */
  32119. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32120. /**
  32121. * Gets the current plugin used to run the simulation
  32122. * @returns current plugin
  32123. */
  32124. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32125. /**
  32126. * Gets the list of physic impostors
  32127. * @returns an array of PhysicsImpostor
  32128. */
  32129. getImpostors(): Array<PhysicsImpostor>;
  32130. /**
  32131. * Gets the impostor for a physics enabled object
  32132. * @param object defines the object impersonated by the impostor
  32133. * @returns the PhysicsImpostor or null if not found
  32134. */
  32135. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32136. /**
  32137. * Gets the impostor for a physics body object
  32138. * @param body defines physics body used by the impostor
  32139. * @returns the PhysicsImpostor or null if not found
  32140. */
  32141. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32142. /**
  32143. * Called by the scene. No need to call it.
  32144. * @param delta defines the timespam between frames
  32145. */
  32146. _step(delta: number): void;
  32147. }
  32148. }
  32149. declare module BABYLON {
  32150. /**
  32151. * Class used to control physics engine
  32152. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32153. */
  32154. class PhysicsEngine implements IPhysicsEngine {
  32155. private _physicsPlugin;
  32156. /**
  32157. * Global value used to control the smallest number supported by the simulation
  32158. */
  32159. static Epsilon: number;
  32160. private _impostors;
  32161. private _joints;
  32162. /**
  32163. * Gets the gravity vector used by the simulation
  32164. */
  32165. gravity: Vector3;
  32166. /**
  32167. * Creates a new Physics Engine
  32168. * @param gravity defines the gravity vector used by the simulation
  32169. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32170. */
  32171. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32172. /**
  32173. * Sets the gravity vector used by the simulation
  32174. * @param gravity defines the gravity vector to use
  32175. */
  32176. setGravity(gravity: Vector3): void;
  32177. /**
  32178. * Set the time step of the physics engine.
  32179. * Default is 1/60.
  32180. * To slow it down, enter 1/600 for example.
  32181. * To speed it up, 1/30
  32182. * @param newTimeStep defines the new timestep to apply to this world.
  32183. */
  32184. setTimeStep(newTimeStep?: number): void;
  32185. /**
  32186. * Get the time step of the physics engine.
  32187. * @returns the current time step
  32188. */
  32189. getTimeStep(): number;
  32190. /**
  32191. * Release all resources
  32192. */
  32193. dispose(): void;
  32194. /**
  32195. * Gets the name of the current physics plugin
  32196. * @returns the name of the plugin
  32197. */
  32198. getPhysicsPluginName(): string;
  32199. /**
  32200. * Adding a new impostor for the impostor tracking.
  32201. * This will be done by the impostor itself.
  32202. * @param impostor the impostor to add
  32203. */
  32204. addImpostor(impostor: PhysicsImpostor): void;
  32205. /**
  32206. * Remove an impostor from the engine.
  32207. * This impostor and its mesh will not longer be updated by the physics engine.
  32208. * @param impostor the impostor to remove
  32209. */
  32210. removeImpostor(impostor: PhysicsImpostor): void;
  32211. /**
  32212. * Add a joint to the physics engine
  32213. * @param mainImpostor defines the main impostor to which the joint is added.
  32214. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32215. * @param joint defines the joint that will connect both impostors.
  32216. */
  32217. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32218. /**
  32219. * Removes a joint from the simulation
  32220. * @param mainImpostor defines the impostor used with the joint
  32221. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32222. * @param joint defines the joint to remove
  32223. */
  32224. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32225. /**
  32226. * Called by the scene. No need to call it.
  32227. * @param delta defines the timespam between frames
  32228. */
  32229. _step(delta: number): void;
  32230. /**
  32231. * Gets the current plugin used to run the simulation
  32232. * @returns current plugin
  32233. */
  32234. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32235. /**
  32236. * Gets the list of physic impostors
  32237. * @returns an array of PhysicsImpostor
  32238. */
  32239. getImpostors(): Array<PhysicsImpostor>;
  32240. /**
  32241. * Gets the impostor for a physics enabled object
  32242. * @param object defines the object impersonated by the impostor
  32243. * @returns the PhysicsImpostor or null if not found
  32244. */
  32245. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32246. /**
  32247. * Gets the impostor for a physics body object
  32248. * @param body defines physics body used by the impostor
  32249. * @returns the PhysicsImpostor or null if not found
  32250. */
  32251. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32252. }
  32253. }
  32254. declare module BABYLON {
  32255. interface Scene {
  32256. /** @hidden (Backing field) */
  32257. _physicsEngine: Nullable<IPhysicsEngine>;
  32258. /**
  32259. * Gets the current physics engine
  32260. * @returns a IPhysicsEngine or null if none attached
  32261. */
  32262. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  32263. /**
  32264. * Enables physics to the current scene
  32265. * @param gravity defines the scene's gravity for the physics engine
  32266. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  32267. * @return a boolean indicating if the physics engine was initialized
  32268. */
  32269. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  32270. /**
  32271. * Disables and disposes the physics engine associated with the scene
  32272. */
  32273. disablePhysicsEngine(): void;
  32274. /**
  32275. * Gets a boolean indicating if there is an active physics engine
  32276. * @returns a boolean indicating if there is an active physics engine
  32277. */
  32278. isPhysicsEnabled(): boolean;
  32279. /**
  32280. * Deletes a physics compound impostor
  32281. * @param compound defines the compound to delete
  32282. */
  32283. deleteCompoundImpostor(compound: any): void;
  32284. /**
  32285. * An event triggered when physic simulation is about to be run
  32286. */
  32287. onBeforePhysicsObservable: Observable<Scene>;
  32288. /**
  32289. * An event triggered when physic simulation has been done
  32290. */
  32291. onAfterPhysicsObservable: Observable<Scene>;
  32292. }
  32293. interface AbstractMesh {
  32294. /** @hidden */
  32295. _physicsImpostor: Nullable<PhysicsImpostor>;
  32296. /**
  32297. * Gets or sets impostor used for physic simulation
  32298. * @see http://doc.babylonjs.com/features/physics_engine
  32299. */
  32300. physicsImpostor: Nullable<PhysicsImpostor>;
  32301. /**
  32302. * Gets the current physics impostor
  32303. * @see http://doc.babylonjs.com/features/physics_engine
  32304. * @returns a physics impostor or null
  32305. */
  32306. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  32307. /** Apply a physic impulse to the mesh
  32308. * @param force defines the force to apply
  32309. * @param contactPoint defines where to apply the force
  32310. * @returns the current mesh
  32311. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32312. */
  32313. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  32314. /**
  32315. * Creates a physic joint between two meshes
  32316. * @param otherMesh defines the other mesh to use
  32317. * @param pivot1 defines the pivot to use on this mesh
  32318. * @param pivot2 defines the pivot to use on the other mesh
  32319. * @param options defines additional options (can be plugin dependent)
  32320. * @returns the current mesh
  32321. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  32322. */
  32323. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  32324. /** @hidden */
  32325. _disposePhysicsObserver: Nullable<Observer<Node>>;
  32326. }
  32327. /**
  32328. * Defines the physics engine scene component responsible to manage a physics engine
  32329. */
  32330. class PhysicsEngineSceneComponent implements ISceneComponent {
  32331. /**
  32332. * The component name helpful to identify the component in the list of scene components.
  32333. */
  32334. readonly name: string;
  32335. /**
  32336. * The scene the component belongs to.
  32337. */
  32338. scene: Scene;
  32339. /**
  32340. * Creates a new instance of the component for the given scene
  32341. * @param scene Defines the scene to register the component in
  32342. */
  32343. constructor(scene: Scene);
  32344. /**
  32345. * Registers the component in a given scene
  32346. */
  32347. register(): void;
  32348. /**
  32349. * Rebuilds the elements related to this component in case of
  32350. * context lost for instance.
  32351. */
  32352. rebuild(): void;
  32353. /**
  32354. * Disposes the component and the associated ressources
  32355. */
  32356. dispose(): void;
  32357. }
  32358. }
  32359. declare module BABYLON {
  32360. /**
  32361. * A helper for physics simulations
  32362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32363. */
  32364. class PhysicsHelper {
  32365. private _scene;
  32366. private _physicsEngine;
  32367. /**
  32368. * Initializes the Physics helper
  32369. * @param scene Babylon.js scene
  32370. */
  32371. constructor(scene: Scene);
  32372. /**
  32373. * Applies a radial explosion impulse
  32374. * @param origin the origin of the explosion
  32375. * @param radius the explosion radius
  32376. * @param strength the explosion strength
  32377. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32378. * @returns A physics radial explosion event, or null
  32379. */
  32380. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32381. /**
  32382. * Applies a radial explosion force
  32383. * @param origin the origin of the explosion
  32384. * @param radius the explosion radius
  32385. * @param strength the explosion strength
  32386. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32387. * @returns A physics radial explosion event, or null
  32388. */
  32389. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32390. /**
  32391. * Creates a gravitational field
  32392. * @param origin the origin of the explosion
  32393. * @param radius the explosion radius
  32394. * @param strength the explosion strength
  32395. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32396. * @returns A physics gravitational field event, or null
  32397. */
  32398. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  32399. /**
  32400. * Creates a physics updraft event
  32401. * @param origin the origin of the updraft
  32402. * @param radius the radius of the updraft
  32403. * @param strength the strength of the updraft
  32404. * @param height the height of the updraft
  32405. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  32406. * @returns A physics updraft event, or null
  32407. */
  32408. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  32409. /**
  32410. * Creates a physics vortex event
  32411. * @param origin the of the vortex
  32412. * @param radius the radius of the vortex
  32413. * @param strength the strength of the vortex
  32414. * @param height the height of the vortex
  32415. * @returns a Physics vortex event, or null
  32416. * A physics vortex event or null
  32417. */
  32418. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  32419. }
  32420. /**
  32421. * Represents a physics radial explosion event
  32422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32423. */
  32424. class PhysicsRadialExplosionEvent {
  32425. private _scene;
  32426. private _sphere;
  32427. private _sphereOptions;
  32428. private _rays;
  32429. private _dataFetched;
  32430. /**
  32431. * Initializes a radial explosioin event
  32432. * @param scene BabylonJS scene
  32433. */
  32434. constructor(scene: Scene);
  32435. /**
  32436. * Returns the data related to the radial explosion event (sphere & rays).
  32437. * @returns The radial explosion event data
  32438. */
  32439. getData(): PhysicsRadialExplosionEventData;
  32440. /**
  32441. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  32442. * @param impostor A physics imposter
  32443. * @param origin the origin of the explosion
  32444. * @param radius the explosion radius
  32445. * @param strength the explosion strength
  32446. * @param falloff possible options: Constant & Linear
  32447. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  32448. */
  32449. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  32450. /**
  32451. * Disposes the sphere.
  32452. * @param force Specifies if the sphere should be disposed by force
  32453. */
  32454. dispose(force?: boolean): void;
  32455. /*** Helpers ***/
  32456. private _prepareSphere;
  32457. private _intersectsWithSphere;
  32458. }
  32459. /**
  32460. * Represents a gravitational field event
  32461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32462. */
  32463. class PhysicsGravitationalFieldEvent {
  32464. private _physicsHelper;
  32465. private _scene;
  32466. private _origin;
  32467. private _radius;
  32468. private _strength;
  32469. private _falloff;
  32470. private _tickCallback;
  32471. private _sphere;
  32472. private _dataFetched;
  32473. /**
  32474. * Initializes the physics gravitational field event
  32475. * @param physicsHelper A physics helper
  32476. * @param scene BabylonJS scene
  32477. * @param origin The origin position of the gravitational field event
  32478. * @param radius The radius of the gravitational field event
  32479. * @param strength The strength of the gravitational field event
  32480. * @param falloff The falloff for the gravitational field event
  32481. */
  32482. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  32483. /**
  32484. * Returns the data related to the gravitational field event (sphere).
  32485. * @returns A gravitational field event
  32486. */
  32487. getData(): PhysicsGravitationalFieldEventData;
  32488. /**
  32489. * Enables the gravitational field.
  32490. */
  32491. enable(): void;
  32492. /**
  32493. * Disables the gravitational field.
  32494. */
  32495. disable(): void;
  32496. /**
  32497. * Disposes the sphere.
  32498. * @param force The force to dispose from the gravitational field event
  32499. */
  32500. dispose(force?: boolean): void;
  32501. private _tick;
  32502. }
  32503. /**
  32504. * Represents a physics updraft event
  32505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32506. */
  32507. class PhysicsUpdraftEvent {
  32508. private _scene;
  32509. private _origin;
  32510. private _radius;
  32511. private _strength;
  32512. private _height;
  32513. private _updraftMode;
  32514. private _physicsEngine;
  32515. private _originTop;
  32516. private _originDirection;
  32517. private _tickCallback;
  32518. private _cylinder;
  32519. private _cylinderPosition;
  32520. private _dataFetched;
  32521. /**
  32522. * Initializes the physics updraft event
  32523. * @param _scene BabylonJS scene
  32524. * @param _origin The origin position of the updraft
  32525. * @param _radius The radius of the updraft
  32526. * @param _strength The strength of the updraft
  32527. * @param _height The height of the updraft
  32528. * @param _updraftMode The mode of the updraft
  32529. */
  32530. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  32531. /**
  32532. * Returns the data related to the updraft event (cylinder).
  32533. * @returns A physics updraft event
  32534. */
  32535. getData(): PhysicsUpdraftEventData;
  32536. /**
  32537. * Enables the updraft.
  32538. */
  32539. enable(): void;
  32540. /**
  32541. * Disables the cortex.
  32542. */
  32543. disable(): void;
  32544. /**
  32545. * Disposes the sphere.
  32546. * @param force Specifies if the updraft should be disposed by force
  32547. */
  32548. dispose(force?: boolean): void;
  32549. private getImpostorForceAndContactPoint;
  32550. private _tick;
  32551. /*** Helpers ***/
  32552. private _prepareCylinder;
  32553. private _intersectsWithCylinder;
  32554. }
  32555. /**
  32556. * Represents a physics vortex event
  32557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32558. */
  32559. class PhysicsVortexEvent {
  32560. private _scene;
  32561. private _origin;
  32562. private _radius;
  32563. private _strength;
  32564. private _height;
  32565. private _physicsEngine;
  32566. private _originTop;
  32567. private _centripetalForceThreshold;
  32568. private _updraftMultiplier;
  32569. private _tickCallback;
  32570. private _cylinder;
  32571. private _cylinderPosition;
  32572. private _dataFetched;
  32573. /**
  32574. * Initializes the physics vortex event
  32575. * @param _scene The BabylonJS scene
  32576. * @param _origin The origin position of the vortex
  32577. * @param _radius The radius of the vortex
  32578. * @param _strength The strength of the vortex
  32579. * @param _height The height of the vortex
  32580. */
  32581. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  32582. /**
  32583. * Returns the data related to the vortex event (cylinder).
  32584. * @returns The physics vortex event data
  32585. */
  32586. getData(): PhysicsVortexEventData;
  32587. /**
  32588. * Enables the vortex.
  32589. */
  32590. enable(): void;
  32591. /**
  32592. * Disables the cortex.
  32593. */
  32594. disable(): void;
  32595. /**
  32596. * Disposes the sphere.
  32597. * @param force
  32598. */
  32599. dispose(force?: boolean): void;
  32600. private getImpostorForceAndContactPoint;
  32601. private _tick;
  32602. /*** Helpers ***/
  32603. private _prepareCylinder;
  32604. private _intersectsWithCylinder;
  32605. }
  32606. /**
  32607. * The strenght of the force in correspondence to the distance of the affected object
  32608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32609. */
  32610. enum PhysicsRadialImpulseFalloff {
  32611. /** Defines that impulse is constant in strength across it's whole radius */
  32612. Constant = 0,
  32613. /** DEfines that impulse gets weaker if it's further from the origin */
  32614. Linear = 1
  32615. }
  32616. /**
  32617. * The strength of the force in correspondence to the distance of the affected object
  32618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32619. */
  32620. enum PhysicsUpdraftMode {
  32621. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  32622. Center = 0,
  32623. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  32624. Perpendicular = 1
  32625. }
  32626. /**
  32627. * Interface for a physics force and contact point
  32628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32629. */
  32630. interface PhysicsForceAndContactPoint {
  32631. /**
  32632. * The force applied at the contact point
  32633. */
  32634. force: Vector3;
  32635. /**
  32636. * The contact point
  32637. */
  32638. contactPoint: Vector3;
  32639. }
  32640. /**
  32641. * Interface for radial explosion event data
  32642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32643. */
  32644. interface PhysicsRadialExplosionEventData {
  32645. /**
  32646. * A sphere used for the radial explosion event
  32647. */
  32648. sphere: Mesh;
  32649. /**
  32650. * An array of rays for the radial explosion event
  32651. */
  32652. rays: Array<Ray>;
  32653. }
  32654. /**
  32655. * Interface for gravitational field event data
  32656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32657. */
  32658. interface PhysicsGravitationalFieldEventData {
  32659. /**
  32660. * A sphere mesh used for the gravitational field event
  32661. */
  32662. sphere: Mesh;
  32663. }
  32664. /**
  32665. * Interface for updraft event data
  32666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32667. */
  32668. interface PhysicsUpdraftEventData {
  32669. /**
  32670. * A cylinder used for the updraft event
  32671. */
  32672. cylinder: Mesh;
  32673. }
  32674. /**
  32675. * Interface for vortex event data
  32676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32677. */
  32678. interface PhysicsVortexEventData {
  32679. /**
  32680. * A cylinder used for the vortex event
  32681. */
  32682. cylinder: Mesh;
  32683. }
  32684. }
  32685. declare module BABYLON {
  32686. /**
  32687. * The interface for the physics imposter parameters
  32688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32689. */
  32690. interface PhysicsImpostorParameters {
  32691. /**
  32692. * The mass of the physics imposter
  32693. */
  32694. mass: number;
  32695. /**
  32696. * The friction of the physics imposter
  32697. */
  32698. friction?: number;
  32699. /**
  32700. * The coefficient of restitution of the physics imposter
  32701. */
  32702. restitution?: number;
  32703. /**
  32704. * The native options of the physics imposter
  32705. */
  32706. nativeOptions?: any;
  32707. /**
  32708. * Specifies if the parent should be ignored
  32709. */
  32710. ignoreParent?: boolean;
  32711. /**
  32712. * Specifies if bi-directional transformations should be disabled
  32713. */
  32714. disableBidirectionalTransformation?: boolean;
  32715. }
  32716. /**
  32717. * Interface for a physics-enabled object
  32718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32719. */
  32720. interface IPhysicsEnabledObject {
  32721. /**
  32722. * The position of the physics-enabled object
  32723. */
  32724. position: Vector3;
  32725. /**
  32726. * The rotation of the physics-enabled object
  32727. */
  32728. rotationQuaternion: Nullable<Quaternion>;
  32729. /**
  32730. * The scale of the physics-enabled object
  32731. */
  32732. scaling: Vector3;
  32733. /**
  32734. * The rotation of the physics-enabled object
  32735. */
  32736. rotation?: Vector3;
  32737. /**
  32738. * The parent of the physics-enabled object
  32739. */
  32740. parent?: any;
  32741. /**
  32742. * The bounding info of the physics-enabled object
  32743. * @returns The bounding info of the physics-enabled object
  32744. */
  32745. getBoundingInfo(): BoundingInfo;
  32746. /**
  32747. * Computes the world matrix
  32748. * @param force Specifies if the world matrix should be computed by force
  32749. * @returns A world matrix
  32750. */
  32751. computeWorldMatrix(force: boolean): Matrix;
  32752. /**
  32753. * Gets the world matrix
  32754. * @returns A world matrix
  32755. */
  32756. getWorldMatrix?(): Matrix;
  32757. /**
  32758. * Gets the child meshes
  32759. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32760. * @returns An array of abstract meshes
  32761. */
  32762. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32763. /**
  32764. * Gets the vertex data
  32765. * @param kind The type of vertex data
  32766. * @returns A nullable array of numbers, or a float32 array
  32767. */
  32768. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32769. /**
  32770. * Gets the indices from the mesh
  32771. * @returns A nullable array of index arrays
  32772. */
  32773. getIndices?(): Nullable<IndicesArray>;
  32774. /**
  32775. * Gets the scene from the mesh
  32776. * @returns the indices array or null
  32777. */
  32778. getScene?(): Scene;
  32779. /**
  32780. * Gets the absolute position from the mesh
  32781. * @returns the absolute position
  32782. */
  32783. getAbsolutePosition(): Vector3;
  32784. /**
  32785. * Gets the absolute pivot point from the mesh
  32786. * @returns the absolute pivot point
  32787. */
  32788. getAbsolutePivotPoint(): Vector3;
  32789. /**
  32790. * Rotates the mesh
  32791. * @param axis The axis of rotation
  32792. * @param amount The amount of rotation
  32793. * @param space The space of the rotation
  32794. * @returns The rotation transform node
  32795. */
  32796. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32797. /**
  32798. * Translates the mesh
  32799. * @param axis The axis of translation
  32800. * @param distance The distance of translation
  32801. * @param space The space of the translation
  32802. * @returns The transform node
  32803. */
  32804. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32805. /**
  32806. * Sets the absolute position of the mesh
  32807. * @param absolutePosition The absolute position of the mesh
  32808. * @returns The transform node
  32809. */
  32810. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32811. /**
  32812. * Gets the class name of the mesh
  32813. * @returns The class name
  32814. */
  32815. getClassName(): string;
  32816. }
  32817. /**
  32818. * Represents a physics imposter
  32819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32820. */
  32821. class PhysicsImpostor {
  32822. /**
  32823. * The physics-enabled object used as the physics imposter
  32824. */
  32825. object: IPhysicsEnabledObject;
  32826. /**
  32827. * The type of the physics imposter
  32828. */
  32829. type: number;
  32830. private _options;
  32831. private _scene?;
  32832. /**
  32833. * The default object size of the imposter
  32834. */
  32835. static DEFAULT_OBJECT_SIZE: Vector3;
  32836. /**
  32837. * The identity quaternion of the imposter
  32838. */
  32839. static IDENTITY_QUATERNION: Quaternion;
  32840. private _physicsEngine;
  32841. private _physicsBody;
  32842. private _bodyUpdateRequired;
  32843. private _onBeforePhysicsStepCallbacks;
  32844. private _onAfterPhysicsStepCallbacks;
  32845. private _onPhysicsCollideCallbacks;
  32846. private _deltaPosition;
  32847. private _deltaRotation;
  32848. private _deltaRotationConjugated;
  32849. private _parent;
  32850. private _isDisposed;
  32851. private static _tmpVecs;
  32852. private static _tmpQuat;
  32853. /**
  32854. * Specifies if the physics imposter is disposed
  32855. */
  32856. readonly isDisposed: boolean;
  32857. /**
  32858. * Gets the mass of the physics imposter
  32859. */
  32860. mass: number;
  32861. /**
  32862. * Gets the coefficient of friction
  32863. */
  32864. /**
  32865. * Sets the coefficient of friction
  32866. */
  32867. friction: number;
  32868. /**
  32869. * Gets the coefficient of restitution
  32870. */
  32871. /**
  32872. * Sets the coefficient of restitution
  32873. */
  32874. restitution: number;
  32875. /**
  32876. * The unique id of the physics imposter
  32877. * set by the physics engine when adding this impostor to the array
  32878. */
  32879. uniqueId: number;
  32880. private _joints;
  32881. /**
  32882. * Initializes the physics imposter
  32883. * @param object The physics-enabled object used as the physics imposter
  32884. * @param type The type of the physics imposter
  32885. * @param _options The options for the physics imposter
  32886. * @param _scene The Babylon scene
  32887. */
  32888. constructor(
  32889. /**
  32890. * The physics-enabled object used as the physics imposter
  32891. */
  32892. object: IPhysicsEnabledObject,
  32893. /**
  32894. * The type of the physics imposter
  32895. */
  32896. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32897. /**
  32898. * This function will completly initialize this impostor.
  32899. * It will create a new body - but only if this mesh has no parent.
  32900. * If it has, this impostor will not be used other than to define the impostor
  32901. * of the child mesh.
  32902. * @hidden
  32903. */
  32904. _init(): void;
  32905. private _getPhysicsParent;
  32906. /**
  32907. * Should a new body be generated.
  32908. * @returns boolean specifying if body initialization is required
  32909. */
  32910. isBodyInitRequired(): boolean;
  32911. /**
  32912. * Sets the updated scaling
  32913. * @param updated Specifies if the scaling is updated
  32914. */
  32915. setScalingUpdated(updated: boolean): void;
  32916. /**
  32917. * Force a regeneration of this or the parent's impostor's body.
  32918. * Use under cautious - This will remove all joints already implemented.
  32919. */
  32920. forceUpdate(): void;
  32921. /**
  32922. * Gets the body that holds this impostor. Either its own, or its parent.
  32923. */
  32924. /**
  32925. * Set the physics body. Used mainly by the physics engine/plugin
  32926. */
  32927. physicsBody: any;
  32928. /**
  32929. * Get the parent of the physics imposter
  32930. * @returns Physics imposter or null
  32931. */
  32932. /**
  32933. * Sets the parent of the physics imposter
  32934. */
  32935. parent: Nullable<PhysicsImpostor>;
  32936. /**
  32937. * Resets the update flags
  32938. */
  32939. resetUpdateFlags(): void;
  32940. /**
  32941. * Gets the object extend size
  32942. * @returns the object extend size
  32943. */
  32944. getObjectExtendSize(): Vector3;
  32945. /**
  32946. * Gets the object center
  32947. * @returns The object center
  32948. */
  32949. getObjectCenter(): Vector3;
  32950. /**
  32951. * Get a specific parametes from the options parameter
  32952. * @param paramName The object parameter name
  32953. * @returns The object parameter
  32954. */
  32955. getParam(paramName: string): any;
  32956. /**
  32957. * Sets a specific parameter in the options given to the physics plugin
  32958. * @param paramName The parameter name
  32959. * @param value The value of the parameter
  32960. */
  32961. setParam(paramName: string, value: number): void;
  32962. /**
  32963. * Specifically change the body's mass option. Won't recreate the physics body object
  32964. * @param mass The mass of the physics imposter
  32965. */
  32966. setMass(mass: number): void;
  32967. /**
  32968. * Gets the linear velocity
  32969. * @returns linear velocity or null
  32970. */
  32971. getLinearVelocity(): Nullable<Vector3>;
  32972. /**
  32973. * Sets the linear velocity
  32974. * @param velocity linear velocity or null
  32975. */
  32976. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32977. /**
  32978. * Gets the angular velocity
  32979. * @returns angular velocity or null
  32980. */
  32981. getAngularVelocity(): Nullable<Vector3>;
  32982. /**
  32983. * Sets the angular velocity
  32984. * @param velocity The velocity or null
  32985. */
  32986. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32987. /**
  32988. * Execute a function with the physics plugin native code
  32989. * Provide a function the will have two variables - the world object and the physics body object
  32990. * @param func The function to execute with the physics plugin native code
  32991. */
  32992. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32993. /**
  32994. * Register a function that will be executed before the physics world is stepping forward
  32995. * @param func The function to execute before the physics world is stepped forward
  32996. */
  32997. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32998. /**
  32999. * Unregister a function that will be executed before the physics world is stepping forward
  33000. * @param func The function to execute before the physics world is stepped forward
  33001. */
  33002. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33003. /**
  33004. * Register a function that will be executed after the physics step
  33005. * @param func The function to execute after physics step
  33006. */
  33007. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33008. /**
  33009. * Unregisters a function that will be executed after the physics step
  33010. * @param func The function to execute after physics step
  33011. */
  33012. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33013. /**
  33014. * register a function that will be executed when this impostor collides against a different body
  33015. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33016. * @param func Callback that is executed on collision
  33017. */
  33018. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33019. /**
  33020. * Unregisters the physics imposter on contact
  33021. * @param collideAgainst The physics object to collide against
  33022. * @param func Callback to execute on collision
  33023. */
  33024. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33025. private _tmpQuat;
  33026. private _tmpQuat2;
  33027. /**
  33028. * Get the parent rotation
  33029. * @returns The parent rotation
  33030. */
  33031. getParentsRotation(): Quaternion;
  33032. /**
  33033. * this function is executed by the physics engine.
  33034. */
  33035. beforeStep: () => void;
  33036. /**
  33037. * this function is executed by the physics engine
  33038. */
  33039. afterStep: () => void;
  33040. /**
  33041. * Legacy collision detection event support
  33042. */
  33043. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33044. /**
  33045. * event and body object due to cannon's event-based architecture.
  33046. */
  33047. onCollide: (e: {
  33048. body: any;
  33049. }) => void;
  33050. /**
  33051. * Apply a force
  33052. * @param force The force to apply
  33053. * @param contactPoint The contact point for the force
  33054. * @returns The physics imposter
  33055. */
  33056. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33057. /**
  33058. * Apply an impulse
  33059. * @param force The impulse force
  33060. * @param contactPoint The contact point for the impulse force
  33061. * @returns The physics imposter
  33062. */
  33063. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33064. /**
  33065. * A help function to create a joint
  33066. * @param otherImpostor A physics imposter used to create a joint
  33067. * @param jointType The type of joint
  33068. * @param jointData The data for the joint
  33069. * @returns The physics imposter
  33070. */
  33071. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33072. /**
  33073. * Add a joint to this impostor with a different impostor
  33074. * @param otherImpostor A physics imposter used to add a joint
  33075. * @param joint The joint to add
  33076. * @returns The physics imposter
  33077. */
  33078. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33079. /**
  33080. * Will keep this body still, in a sleep mode.
  33081. * @returns the physics imposter
  33082. */
  33083. sleep(): PhysicsImpostor;
  33084. /**
  33085. * Wake the body up.
  33086. * @returns The physics imposter
  33087. */
  33088. wakeUp(): PhysicsImpostor;
  33089. /**
  33090. * Clones the physics imposter
  33091. * @param newObject The physics imposter clones to this physics-enabled object
  33092. * @returns A nullable physics imposter
  33093. */
  33094. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33095. /**
  33096. * Disposes the physics imposter
  33097. */
  33098. dispose(): void;
  33099. /**
  33100. * Sets the delta position
  33101. * @param position The delta position amount
  33102. */
  33103. setDeltaPosition(position: Vector3): void;
  33104. /**
  33105. * Sets the delta rotation
  33106. * @param rotation The delta rotation amount
  33107. */
  33108. setDeltaRotation(rotation: Quaternion): void;
  33109. /**
  33110. * Gets the box size of the physics imposter and stores the result in the input parameter
  33111. * @param result Stores the box size
  33112. * @returns The physics imposter
  33113. */
  33114. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33115. /**
  33116. * Gets the radius of the physics imposter
  33117. * @returns Radius of the physics imposter
  33118. */
  33119. getRadius(): number;
  33120. /**
  33121. * Sync a bone with this impostor
  33122. * @param bone The bone to sync to the impostor.
  33123. * @param boneMesh The mesh that the bone is influencing.
  33124. * @param jointPivot The pivot of the joint / bone in local space.
  33125. * @param distToJoint Optional distance from the impostor to the joint.
  33126. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33127. */
  33128. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33129. /**
  33130. * Sync impostor to a bone
  33131. * @param bone The bone that the impostor will be synced to.
  33132. * @param boneMesh The mesh that the bone is influencing.
  33133. * @param jointPivot The pivot of the joint / bone in local space.
  33134. * @param distToJoint Optional distance from the impostor to the joint.
  33135. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33136. * @param boneAxis Optional vector3 axis the bone is aligned with
  33137. */
  33138. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33139. /**
  33140. * No-Imposter type
  33141. */
  33142. static NoImpostor: number;
  33143. /**
  33144. * Sphere-Imposter type
  33145. */
  33146. static SphereImpostor: number;
  33147. /**
  33148. * Box-Imposter type
  33149. */
  33150. static BoxImpostor: number;
  33151. /**
  33152. * Plane-Imposter type
  33153. */
  33154. static PlaneImpostor: number;
  33155. /**
  33156. * Mesh-imposter type
  33157. */
  33158. static MeshImpostor: number;
  33159. /**
  33160. * Cylinder-Imposter type
  33161. */
  33162. static CylinderImpostor: number;
  33163. /**
  33164. * Particle-Imposter type
  33165. */
  33166. static ParticleImpostor: number;
  33167. /**
  33168. * Heightmap-Imposter type
  33169. */
  33170. static HeightmapImpostor: number;
  33171. }
  33172. }
  33173. declare module BABYLON {
  33174. /**
  33175. * Interface for Physics-Joint data
  33176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33177. */
  33178. interface PhysicsJointData {
  33179. /**
  33180. * The main pivot of the joint
  33181. */
  33182. mainPivot?: Vector3;
  33183. /**
  33184. * The connected pivot of the joint
  33185. */
  33186. connectedPivot?: Vector3;
  33187. /**
  33188. * The main axis of the joint
  33189. */
  33190. mainAxis?: Vector3;
  33191. /**
  33192. * The connected axis of the joint
  33193. */
  33194. connectedAxis?: Vector3;
  33195. /**
  33196. * The collision of the joint
  33197. */
  33198. collision?: boolean;
  33199. /**
  33200. * Native Oimo/Cannon/Energy data
  33201. */
  33202. nativeParams?: any;
  33203. }
  33204. /**
  33205. * This is a holder class for the physics joint created by the physics plugin
  33206. * It holds a set of functions to control the underlying joint
  33207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33208. */
  33209. class PhysicsJoint {
  33210. /**
  33211. * The type of the physics joint
  33212. */
  33213. type: number;
  33214. /**
  33215. * The data for the physics joint
  33216. */
  33217. jointData: PhysicsJointData;
  33218. private _physicsJoint;
  33219. protected _physicsPlugin: IPhysicsEnginePlugin;
  33220. /**
  33221. * Initializes the physics joint
  33222. * @param type The type of the physics joint
  33223. * @param jointData The data for the physics joint
  33224. */
  33225. constructor(
  33226. /**
  33227. * The type of the physics joint
  33228. */
  33229. type: number,
  33230. /**
  33231. * The data for the physics joint
  33232. */
  33233. jointData: PhysicsJointData);
  33234. /**
  33235. * Gets the physics joint
  33236. */
  33237. /**
  33238. * Sets the physics joint
  33239. */
  33240. physicsJoint: any;
  33241. /**
  33242. * Sets the physics plugin
  33243. */
  33244. physicsPlugin: IPhysicsEnginePlugin;
  33245. /**
  33246. * Execute a function that is physics-plugin specific.
  33247. * @param {Function} func the function that will be executed.
  33248. * It accepts two parameters: the physics world and the physics joint
  33249. */
  33250. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33251. /**
  33252. * Distance-Joint type
  33253. */
  33254. static DistanceJoint: number;
  33255. /**
  33256. * Hinge-Joint type
  33257. */
  33258. static HingeJoint: number;
  33259. /**
  33260. * Ball-and-Socket joint type
  33261. */
  33262. static BallAndSocketJoint: number;
  33263. /**
  33264. * Wheel-Joint type
  33265. */
  33266. static WheelJoint: number;
  33267. /**
  33268. * Slider-Joint type
  33269. */
  33270. static SliderJoint: number;
  33271. /**
  33272. * Prismatic-Joint type
  33273. */
  33274. static PrismaticJoint: number;
  33275. /**
  33276. * Universal-Joint type
  33277. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33278. */
  33279. static UniversalJoint: number;
  33280. /**
  33281. * Hinge-Joint 2 type
  33282. */
  33283. static Hinge2Joint: number;
  33284. /**
  33285. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33286. */
  33287. static PointToPointJoint: number;
  33288. /**
  33289. * Spring-Joint type
  33290. */
  33291. static SpringJoint: number;
  33292. /**
  33293. * Lock-Joint type
  33294. */
  33295. static LockJoint: number;
  33296. }
  33297. /**
  33298. * A class representing a physics distance joint
  33299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33300. */
  33301. class DistanceJoint extends PhysicsJoint {
  33302. /**
  33303. *
  33304. * @param jointData The data for the Distance-Joint
  33305. */
  33306. constructor(jointData: DistanceJointData);
  33307. /**
  33308. * Update the predefined distance.
  33309. * @param maxDistance The maximum preferred distance
  33310. * @param minDistance The minimum preferred distance
  33311. */
  33312. updateDistance(maxDistance: number, minDistance?: number): void;
  33313. }
  33314. /**
  33315. * Represents a Motor-Enabled Joint
  33316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33317. */
  33318. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33319. /**
  33320. * Initializes the Motor-Enabled Joint
  33321. * @param type The type of the joint
  33322. * @param jointData The physica joint data for the joint
  33323. */
  33324. constructor(type: number, jointData: PhysicsJointData);
  33325. /**
  33326. * Set the motor values.
  33327. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33328. * @param force the force to apply
  33329. * @param maxForce max force for this motor.
  33330. */
  33331. setMotor(force?: number, maxForce?: number): void;
  33332. /**
  33333. * Set the motor's limits.
  33334. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33335. * @param upperLimit The upper limit of the motor
  33336. * @param lowerLimit The lower limit of the motor
  33337. */
  33338. setLimit(upperLimit: number, lowerLimit?: number): void;
  33339. }
  33340. /**
  33341. * This class represents a single physics Hinge-Joint
  33342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33343. */
  33344. class HingeJoint extends MotorEnabledJoint {
  33345. /**
  33346. * Initializes the Hinge-Joint
  33347. * @param jointData The joint data for the Hinge-Joint
  33348. */
  33349. constructor(jointData: PhysicsJointData);
  33350. /**
  33351. * Set the motor values.
  33352. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33353. * @param {number} force the force to apply
  33354. * @param {number} maxForce max force for this motor.
  33355. */
  33356. setMotor(force?: number, maxForce?: number): void;
  33357. /**
  33358. * Set the motor's limits.
  33359. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33360. * @param upperLimit The upper limit of the motor
  33361. * @param lowerLimit The lower limit of the motor
  33362. */
  33363. setLimit(upperLimit: number, lowerLimit?: number): void;
  33364. }
  33365. /**
  33366. * This class represents a dual hinge physics joint (same as wheel joint)
  33367. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33368. */
  33369. class Hinge2Joint extends MotorEnabledJoint {
  33370. /**
  33371. * Initializes the Hinge2-Joint
  33372. * @param jointData The joint data for the Hinge2-Joint
  33373. */
  33374. constructor(jointData: PhysicsJointData);
  33375. /**
  33376. * Set the motor values.
  33377. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33378. * @param {number} force the force to apply
  33379. * @param {number} maxForce max force for this motor.
  33380. * @param {motorIndex} the motor's index, 0 or 1.
  33381. */
  33382. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33383. /**
  33384. * Set the motor limits.
  33385. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33386. * @param {number} upperLimit the upper limit
  33387. * @param {number} lowerLimit lower limit
  33388. * @param {motorIndex} the motor's index, 0 or 1.
  33389. */
  33390. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33391. }
  33392. /**
  33393. * Interface for a motor enabled joint
  33394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33395. */
  33396. interface IMotorEnabledJoint {
  33397. /**
  33398. * Physics joint
  33399. */
  33400. physicsJoint: any;
  33401. /**
  33402. * Sets the motor of the motor-enabled joint
  33403. * @param force The force of the motor
  33404. * @param maxForce The maximum force of the motor
  33405. * @param motorIndex The index of the motor
  33406. */
  33407. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33408. /**
  33409. * Sets the limit of the motor
  33410. * @param upperLimit The upper limit of the motor
  33411. * @param lowerLimit The lower limit of the motor
  33412. * @param motorIndex The index of the motor
  33413. */
  33414. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33415. }
  33416. /**
  33417. * Joint data for a Distance-Joint
  33418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33419. */
  33420. interface DistanceJointData extends PhysicsJointData {
  33421. /**
  33422. * Max distance the 2 joint objects can be apart
  33423. */
  33424. maxDistance: number;
  33425. }
  33426. /**
  33427. * Joint data from a spring joint
  33428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33429. */
  33430. interface SpringJointData extends PhysicsJointData {
  33431. /**
  33432. * Length of the spring
  33433. */
  33434. length: number;
  33435. /**
  33436. * Stiffness of the spring
  33437. */
  33438. stiffness: number;
  33439. /**
  33440. * Damping of the spring
  33441. */
  33442. damping: number;
  33443. /** this callback will be called when applying the force to the impostors. */
  33444. forceApplicationCallback: () => void;
  33445. }
  33446. }
  33447. declare module BABYLON {
  33448. interface Scene {
  33449. /**
  33450. * The list of reflection probes added to the scene
  33451. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33452. */
  33453. reflectionProbes: Array<ReflectionProbe>;
  33454. }
  33455. /**
  33456. * Class used to generate realtime reflection / refraction cube textures
  33457. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33458. */
  33459. class ReflectionProbe {
  33460. /** defines the name of the probe */
  33461. name: string;
  33462. private _scene;
  33463. private _renderTargetTexture;
  33464. private _projectionMatrix;
  33465. private _viewMatrix;
  33466. private _target;
  33467. private _add;
  33468. private _attachedMesh;
  33469. private _invertYAxis;
  33470. /** Gets or sets probe position (center of the cube map) */
  33471. position: Vector3;
  33472. /**
  33473. * Creates a new reflection probe
  33474. * @param name defines the name of the probe
  33475. * @param size defines the texture resolution (for each face)
  33476. * @param scene defines the hosting scene
  33477. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  33478. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  33479. */
  33480. constructor(
  33481. /** defines the name of the probe */
  33482. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  33483. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  33484. samples: number;
  33485. /** Gets or sets the refresh rate to use (on every frame by default) */
  33486. refreshRate: number;
  33487. /**
  33488. * Gets the hosting scene
  33489. * @returns a Scene
  33490. */
  33491. getScene(): Scene;
  33492. /** Gets the internal CubeTexture used to render to */
  33493. readonly cubeTexture: RenderTargetTexture;
  33494. /** Gets the list of meshes to render */
  33495. readonly renderList: Nullable<AbstractMesh[]>;
  33496. /**
  33497. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  33498. * @param mesh defines the mesh to attach to
  33499. */
  33500. attachToMesh(mesh: AbstractMesh): void;
  33501. /**
  33502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  33503. * @param renderingGroupId The rendering group id corresponding to its index
  33504. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33505. */
  33506. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33507. /**
  33508. * Clean all associated resources
  33509. */
  33510. dispose(): void;
  33511. }
  33512. }
  33513. declare module BABYLON {
  33514. interface Scene {
  33515. /** @hidden (Backing field) */
  33516. _boundingBoxRenderer: BoundingBoxRenderer;
  33517. /** @hidden (Backing field) */
  33518. _forceShowBoundingBoxes: boolean;
  33519. /**
  33520. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  33521. */
  33522. forceShowBoundingBoxes: boolean;
  33523. /**
  33524. * Gets the bounding box renderer associated with the scene
  33525. * @returns a BoundingBoxRenderer
  33526. */
  33527. getBoundingBoxRenderer(): BoundingBoxRenderer;
  33528. }
  33529. interface AbstractMesh {
  33530. /** @hidden (Backing field) */
  33531. _showBoundingBox: boolean;
  33532. /**
  33533. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  33534. */
  33535. showBoundingBox: boolean;
  33536. }
  33537. /**
  33538. * Component responsible of rendering the bounding box of the meshes in a scene.
  33539. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  33540. */
  33541. class BoundingBoxRenderer implements ISceneComponent {
  33542. /**
  33543. * The component name helpfull to identify the component in the list of scene components.
  33544. */
  33545. readonly name: string;
  33546. /**
  33547. * The scene the component belongs to.
  33548. */
  33549. scene: Scene;
  33550. /**
  33551. * Color of the bounding box lines placed in front of an object
  33552. */
  33553. frontColor: Color3;
  33554. /**
  33555. * Color of the bounding box lines placed behind an object
  33556. */
  33557. backColor: Color3;
  33558. /**
  33559. * Defines if the renderer should show the back lines or not
  33560. */
  33561. showBackLines: boolean;
  33562. /**
  33563. * @hidden
  33564. */
  33565. renderList: SmartArray<BoundingBox>;
  33566. private _colorShader;
  33567. private _vertexBuffers;
  33568. private _indexBuffer;
  33569. /**
  33570. * Instantiates a new bounding box renderer in a scene.
  33571. * @param scene the scene the renderer renders in
  33572. */
  33573. constructor(scene: Scene);
  33574. /**
  33575. * Registers the component in a given scene
  33576. */
  33577. register(): void;
  33578. private _evaluateSubMesh;
  33579. private _activeMesh;
  33580. private _prepareRessources;
  33581. private _createIndexBuffer;
  33582. /**
  33583. * Rebuilds the elements related to this component in case of
  33584. * context lost for instance.
  33585. */
  33586. rebuild(): void;
  33587. /**
  33588. * @hidden
  33589. */
  33590. reset(): void;
  33591. /**
  33592. * Render the bounding boxes of a specific rendering group
  33593. * @param renderingGroupId defines the rendering group to render
  33594. */
  33595. render(renderingGroupId: number): void;
  33596. /**
  33597. * In case of occlusion queries, we can render the occlusion bounding box through this method
  33598. * @param mesh Define the mesh to render the occlusion bounding box for
  33599. */
  33600. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  33601. /**
  33602. * Dispose and release the resources attached to this renderer.
  33603. */
  33604. dispose(): void;
  33605. }
  33606. }
  33607. declare module BABYLON {
  33608. /**
  33609. * This represents a depth renderer in Babylon.
  33610. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  33611. */
  33612. class DepthRenderer {
  33613. private _scene;
  33614. private _depthMap;
  33615. private _effect;
  33616. private _cachedDefines;
  33617. private _camera;
  33618. /**
  33619. * Specifiess that the depth renderer will only be used within
  33620. * the camera it is created for.
  33621. * This can help forcing its rendering during the camera processing.
  33622. */
  33623. useOnlyInActiveCamera: boolean;
  33624. /**
  33625. * Instantiates a depth renderer
  33626. * @param scene The scene the renderer belongs to
  33627. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  33628. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  33629. */
  33630. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  33631. /**
  33632. * Creates the depth rendering effect and checks if the effect is ready.
  33633. * @param subMesh The submesh to be used to render the depth map of
  33634. * @param useInstances If multiple world instances should be used
  33635. * @returns if the depth renderer is ready to render the depth map
  33636. */
  33637. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33638. /**
  33639. * Gets the texture which the depth map will be written to.
  33640. * @returns The depth map texture
  33641. */
  33642. getDepthMap(): RenderTargetTexture;
  33643. /**
  33644. * Disposes of the depth renderer.
  33645. */
  33646. dispose(): void;
  33647. }
  33648. }
  33649. declare module BABYLON {
  33650. interface Scene {
  33651. /** @hidden (Backing field) */
  33652. _depthRenderer: {
  33653. [id: string]: DepthRenderer;
  33654. };
  33655. /**
  33656. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  33657. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  33658. * @returns the created depth renderer
  33659. */
  33660. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  33661. /**
  33662. * Disables a depth renderer for a given camera
  33663. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  33664. */
  33665. disableDepthRenderer(camera?: Nullable<Camera>): void;
  33666. }
  33667. /**
  33668. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  33669. * in several rendering techniques.
  33670. */
  33671. class DepthRendererSceneComponent implements ISceneComponent {
  33672. /**
  33673. * The component name helpfull to identify the component in the list of scene components.
  33674. */
  33675. readonly name: string;
  33676. /**
  33677. * The scene the component belongs to.
  33678. */
  33679. scene: Scene;
  33680. /**
  33681. * Creates a new instance of the component for the given scene
  33682. * @param scene Defines the scene to register the component in
  33683. */
  33684. constructor(scene: Scene);
  33685. /**
  33686. * Registers the component in a given scene
  33687. */
  33688. register(): void;
  33689. /**
  33690. * Rebuilds the elements related to this component in case of
  33691. * context lost for instance.
  33692. */
  33693. rebuild(): void;
  33694. /**
  33695. * Disposes the component and the associated ressources
  33696. */
  33697. dispose(): void;
  33698. private _gatherRenderTargets;
  33699. private _gatherActiveCameraRenderTargets;
  33700. }
  33701. }
  33702. declare module BABYLON {
  33703. interface AbstractMesh {
  33704. /**
  33705. * Disables the mesh edge rendering mode
  33706. * @returns the currentAbstractMesh
  33707. */
  33708. disableEdgesRendering(): AbstractMesh;
  33709. /**
  33710. * Enables the edge rendering mode on the mesh.
  33711. * This mode makes the mesh edges visible
  33712. * @param epsilon defines the maximal distance between two angles to detect a face
  33713. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33714. * @returns the currentAbstractMesh
  33715. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33716. */
  33717. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33718. /**
  33719. * Gets the edgesRenderer associated with the mesh
  33720. */
  33721. edgesRenderer: Nullable<EdgesRenderer>;
  33722. }
  33723. interface LinesMesh {
  33724. /**
  33725. * Enables the edge rendering mode on the mesh.
  33726. * This mode makes the mesh edges visible
  33727. * @param epsilon defines the maximal distance between two angles to detect a face
  33728. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33729. * @returns the currentAbstractMesh
  33730. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33731. */
  33732. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33733. }
  33734. /**
  33735. * Defines the minimum contract an Edges renderer should follow.
  33736. */
  33737. interface IEdgesRenderer extends IDisposable {
  33738. /**
  33739. * Gets or sets a boolean indicating if the edgesRenderer is active
  33740. */
  33741. isEnabled: boolean;
  33742. /**
  33743. * Renders the edges of the attached mesh,
  33744. */
  33745. render(): void;
  33746. /**
  33747. * Checks wether or not the edges renderer is ready to render.
  33748. * @return true if ready, otherwise false.
  33749. */
  33750. isReady(): boolean;
  33751. }
  33752. /**
  33753. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  33754. */
  33755. class EdgesRenderer implements IEdgesRenderer {
  33756. /**
  33757. * Define the size of the edges with an orthographic camera
  33758. */
  33759. edgesWidthScalerForOrthographic: number;
  33760. /**
  33761. * Define the size of the edges with a perspective camera
  33762. */
  33763. edgesWidthScalerForPerspective: number;
  33764. protected _source: AbstractMesh;
  33765. protected _linesPositions: number[];
  33766. protected _linesNormals: number[];
  33767. protected _linesIndices: number[];
  33768. protected _epsilon: number;
  33769. protected _indicesCount: number;
  33770. protected _lineShader: ShaderMaterial;
  33771. protected _ib: WebGLBuffer;
  33772. protected _buffers: {
  33773. [key: string]: Nullable<VertexBuffer>;
  33774. };
  33775. protected _checkVerticesInsteadOfIndices: boolean;
  33776. private _meshRebuildObserver;
  33777. private _meshDisposeObserver;
  33778. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  33779. isEnabled: boolean;
  33780. /**
  33781. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  33782. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  33783. * @param source Mesh used to create edges
  33784. * @param epsilon sum of angles in adjacency to check for edge
  33785. * @param checkVerticesInsteadOfIndices
  33786. * @param generateEdgesLines - should generate Lines or only prepare resources.
  33787. */
  33788. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  33789. protected _prepareRessources(): void;
  33790. /** @hidden */
  33791. _rebuild(): void;
  33792. /**
  33793. * Releases the required resources for the edges renderer
  33794. */
  33795. dispose(): void;
  33796. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  33797. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  33798. /**
  33799. * Checks if the pair of p0 and p1 is en edge
  33800. * @param faceIndex
  33801. * @param edge
  33802. * @param faceNormals
  33803. * @param p0
  33804. * @param p1
  33805. * @private
  33806. */
  33807. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  33808. /**
  33809. * Generates lines edges from adjacencjes
  33810. * @private
  33811. */
  33812. _generateEdgesLines(): void;
  33813. /**
  33814. * Checks wether or not the edges renderer is ready to render.
  33815. * @return true if ready, otherwise false.
  33816. */
  33817. isReady(): boolean;
  33818. /**
  33819. * Renders the edges of the attached mesh,
  33820. */
  33821. render(): void;
  33822. }
  33823. }
  33824. declare module BABYLON {
  33825. /**
  33826. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  33827. */
  33828. class GeometryBufferRenderer {
  33829. private _scene;
  33830. private _multiRenderTarget;
  33831. private _ratio;
  33832. private _enablePosition;
  33833. protected _effect: Effect;
  33834. protected _cachedDefines: string;
  33835. /**
  33836. * Set the render list (meshes to be rendered) used in the G buffer.
  33837. */
  33838. renderList: Mesh[];
  33839. /**
  33840. * Gets wether or not G buffer are supported by the running hardware.
  33841. * This requires draw buffer supports
  33842. */
  33843. readonly isSupported: boolean;
  33844. /**
  33845. * Gets wether or not position are enabled for the G buffer.
  33846. */
  33847. /**
  33848. * Sets wether or not position are enabled for the G buffer.
  33849. */
  33850. enablePosition: boolean;
  33851. /**
  33852. * Gets the scene associated with the buffer.
  33853. */
  33854. readonly scene: Scene;
  33855. /**
  33856. * Gets the ratio used by the buffer during its creation.
  33857. * How big is the buffer related to the main canvas.
  33858. */
  33859. readonly ratio: number;
  33860. /**
  33861. * Creates a new G Buffer for the scene
  33862. * @param scene The scene the buffer belongs to
  33863. * @param ratio How big is the buffer related to the main canvas.
  33864. */
  33865. constructor(scene: Scene, ratio?: number);
  33866. /**
  33867. * Checks wether everything is ready to render a submesh to the G buffer.
  33868. * @param subMesh the submesh to check readiness for
  33869. * @param useInstances is the mesh drawn using instance or not
  33870. * @returns true if ready otherwise false
  33871. */
  33872. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33873. /**
  33874. * Gets the current underlying G Buffer.
  33875. * @returns the buffer
  33876. */
  33877. getGBuffer(): MultiRenderTarget;
  33878. /**
  33879. * Gets the number of samples used to render the buffer (anti aliasing).
  33880. */
  33881. /**
  33882. * Sets the number of samples used to render the buffer (anti aliasing).
  33883. */
  33884. samples: number;
  33885. /**
  33886. * Disposes the renderer and frees up associated resources.
  33887. */
  33888. dispose(): void;
  33889. protected _createRenderTargets(): void;
  33890. }
  33891. }
  33892. declare module BABYLON {
  33893. interface Scene {
  33894. /** @hidden (Backing field) */
  33895. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  33896. /**
  33897. * Gets or Sets the current geometry buffer associated to the scene.
  33898. */
  33899. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  33900. /**
  33901. * Enables a GeometryBufferRender and associates it with the scene
  33902. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  33903. * @returns the GeometryBufferRenderer
  33904. */
  33905. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  33906. /**
  33907. * Disables the GeometryBufferRender associated with the scene
  33908. */
  33909. disableGeometryBufferRenderer(): void;
  33910. }
  33911. /**
  33912. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  33913. * in several rendering techniques.
  33914. */
  33915. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  33916. /**
  33917. * The component name helpful to identify the component in the list of scene components.
  33918. */
  33919. readonly name: string;
  33920. /**
  33921. * The scene the component belongs to.
  33922. */
  33923. scene: Scene;
  33924. /**
  33925. * Creates a new instance of the component for the given scene
  33926. * @param scene Defines the scene to register the component in
  33927. */
  33928. constructor(scene: Scene);
  33929. /**
  33930. * Registers the component in a given scene
  33931. */
  33932. register(): void;
  33933. /**
  33934. * Rebuilds the elements related to this component in case of
  33935. * context lost for instance.
  33936. */
  33937. rebuild(): void;
  33938. /**
  33939. * Disposes the component and the associated ressources
  33940. */
  33941. dispose(): void;
  33942. private _gatherRenderTargets;
  33943. }
  33944. }
  33945. declare module BABYLON {
  33946. /**
  33947. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  33948. */
  33949. class LineEdgesRenderer extends EdgesRenderer {
  33950. /**
  33951. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  33952. * @param source LineMesh used to generate edges
  33953. * @param epsilon not important (specified angle for edge detection)
  33954. * @param checkVerticesInsteadOfIndices not important for LineMesh
  33955. */
  33956. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  33957. /**
  33958. * Always create the edge since its a line so only important things are p0 and p1
  33959. * @param faceIndex not important for LineMesh
  33960. * @param edge not important for LineMesh
  33961. * @param faceNormals not important for LineMesh
  33962. * @param p0 beginnig of line
  33963. * @param p1 end of line
  33964. */
  33965. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  33966. /**
  33967. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  33968. */
  33969. _generateEdgesLines(): void;
  33970. }
  33971. }
  33972. declare module BABYLON {
  33973. interface Scene {
  33974. /** @hidden */
  33975. _outlineRenderer: OutlineRenderer;
  33976. /**
  33977. * Gets the outline renderer associated with the scene
  33978. * @returns a OutlineRenderer
  33979. */
  33980. getOutlineRenderer(): OutlineRenderer;
  33981. }
  33982. interface AbstractMesh {
  33983. /** @hidden (Backing field) */
  33984. _renderOutline: boolean;
  33985. /**
  33986. * Gets or sets a boolean indicating if the outline must be rendered as well
  33987. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  33988. */
  33989. renderOutline: boolean;
  33990. /** @hidden (Backing field) */
  33991. _renderOverlay: boolean;
  33992. /**
  33993. * Gets or sets a boolean indicating if the overlay must be rendered as well
  33994. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  33995. */
  33996. renderOverlay: boolean;
  33997. }
  33998. /**
  33999. * This class is responsible to draw bothe outline/overlay of meshes.
  34000. * It should not be used directly but through the available method on mesh.
  34001. */
  34002. class OutlineRenderer implements ISceneComponent {
  34003. /**
  34004. * The name of the component. Each component must have a unique name.
  34005. */
  34006. name: string;
  34007. /**
  34008. * The scene the component belongs to.
  34009. */
  34010. scene: Scene;
  34011. /**
  34012. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  34013. */
  34014. zOffset: number;
  34015. private _engine;
  34016. private _effect;
  34017. private _cachedDefines;
  34018. private _savedDepthWrite;
  34019. /**
  34020. * Instantiates a new outline renderer. (There could be only one per scene).
  34021. * @param scene Defines the scene it belongs to
  34022. */
  34023. constructor(scene: Scene);
  34024. /**
  34025. * Register the component to one instance of a scene.
  34026. */
  34027. register(): void;
  34028. /**
  34029. * Rebuilds the elements related to this component in case of
  34030. * context lost for instance.
  34031. */
  34032. rebuild(): void;
  34033. /**
  34034. * Disposes the component and the associated ressources.
  34035. */
  34036. dispose(): void;
  34037. /**
  34038. * Renders the outline in the canvas.
  34039. * @param subMesh Defines the sumesh to render
  34040. * @param batch Defines the batch of meshes in case of instances
  34041. * @param useOverlay Defines if the rendering is for the overlay or the outline
  34042. */
  34043. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  34044. /**
  34045. * Returns whether or not the outline renderer is ready for a given submesh.
  34046. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  34047. * @param subMesh Defines the submesh to check readyness for
  34048. * @param useInstances Defines wheter wee are trying to render instances or not
  34049. * @returns true if ready otherwise false
  34050. */
  34051. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34052. private _beforeRenderingMesh;
  34053. private _afterRenderingMesh;
  34054. }
  34055. }
  34056. declare module BABYLON {
  34057. /**
  34058. * This represents the object necessary to create a rendering group.
  34059. * This is exclusively used and created by the rendering manager.
  34060. * To modify the behavior, you use the available helpers in your scene or meshes.
  34061. * @hidden
  34062. */
  34063. class RenderingGroup {
  34064. index: number;
  34065. private _scene;
  34066. private _opaqueSubMeshes;
  34067. private _transparentSubMeshes;
  34068. private _alphaTestSubMeshes;
  34069. private _depthOnlySubMeshes;
  34070. private _particleSystems;
  34071. private _spriteManagers;
  34072. private _opaqueSortCompareFn;
  34073. private _alphaTestSortCompareFn;
  34074. private _transparentSortCompareFn;
  34075. private _renderOpaque;
  34076. private _renderAlphaTest;
  34077. private _renderTransparent;
  34078. private _edgesRenderers;
  34079. onBeforeTransparentRendering: () => void;
  34080. /**
  34081. * Set the opaque sort comparison function.
  34082. * If null the sub meshes will be render in the order they were created
  34083. */
  34084. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34085. /**
  34086. * Set the alpha test sort comparison function.
  34087. * If null the sub meshes will be render in the order they were created
  34088. */
  34089. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34090. /**
  34091. * Set the transparent sort comparison function.
  34092. * If null the sub meshes will be render in the order they were created
  34093. */
  34094. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34095. /**
  34096. * Creates a new rendering group.
  34097. * @param index The rendering group index
  34098. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  34099. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  34100. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  34101. */
  34102. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  34103. /**
  34104. * Render all the sub meshes contained in the group.
  34105. * @param customRenderFunction Used to override the default render behaviour of the group.
  34106. * @returns true if rendered some submeshes.
  34107. */
  34108. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  34109. /**
  34110. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  34111. * @param subMeshes The submeshes to render
  34112. */
  34113. private renderOpaqueSorted;
  34114. /**
  34115. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  34116. * @param subMeshes The submeshes to render
  34117. */
  34118. private renderAlphaTestSorted;
  34119. /**
  34120. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  34121. * @param subMeshes The submeshes to render
  34122. */
  34123. private renderTransparentSorted;
  34124. /**
  34125. * Renders the submeshes in a specified order.
  34126. * @param subMeshes The submeshes to sort before render
  34127. * @param sortCompareFn The comparison function use to sort
  34128. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  34129. * @param transparent Specifies to activate blending if true
  34130. */
  34131. private static renderSorted;
  34132. /**
  34133. * Renders the submeshes in the order they were dispatched (no sort applied).
  34134. * @param subMeshes The submeshes to render
  34135. */
  34136. private static renderUnsorted;
  34137. /**
  34138. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34139. * are rendered back to front if in the same alpha index.
  34140. *
  34141. * @param a The first submesh
  34142. * @param b The second submesh
  34143. * @returns The result of the comparison
  34144. */
  34145. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  34146. /**
  34147. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34148. * are rendered back to front.
  34149. *
  34150. * @param a The first submesh
  34151. * @param b The second submesh
  34152. * @returns The result of the comparison
  34153. */
  34154. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  34155. /**
  34156. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34157. * are rendered front to back (prevent overdraw).
  34158. *
  34159. * @param a The first submesh
  34160. * @param b The second submesh
  34161. * @returns The result of the comparison
  34162. */
  34163. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  34164. /**
  34165. * Resets the different lists of submeshes to prepare a new frame.
  34166. */
  34167. prepare(): void;
  34168. dispose(): void;
  34169. /**
  34170. * Inserts the submesh in its correct queue depending on its material.
  34171. * @param subMesh The submesh to dispatch
  34172. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  34173. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  34174. */
  34175. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  34176. dispatchSprites(spriteManager: ISpriteManager): void;
  34177. dispatchParticles(particleSystem: IParticleSystem): void;
  34178. private _renderParticles;
  34179. private _renderSprites;
  34180. }
  34181. }
  34182. declare module BABYLON {
  34183. /**
  34184. * Interface describing the different options available in the rendering manager
  34185. * regarding Auto Clear between groups.
  34186. */
  34187. interface IRenderingManagerAutoClearSetup {
  34188. /**
  34189. * Defines whether or not autoclear is enable.
  34190. */
  34191. autoClear: boolean;
  34192. /**
  34193. * Defines whether or not to autoclear the depth buffer.
  34194. */
  34195. depth: boolean;
  34196. /**
  34197. * Defines whether or not to autoclear the stencil buffer.
  34198. */
  34199. stencil: boolean;
  34200. }
  34201. /**
  34202. * This is the manager responsible of all the rendering for meshes sprites and particles.
  34203. * It is enable to manage the different groups as well as the different necessary sort functions.
  34204. * This should not be used directly aside of the few static configurations
  34205. */
  34206. class RenderingManager {
  34207. /**
  34208. * The max id used for rendering groups (not included)
  34209. */
  34210. static MAX_RENDERINGGROUPS: number;
  34211. /**
  34212. * The min id used for rendering groups (included)
  34213. */
  34214. static MIN_RENDERINGGROUPS: number;
  34215. /**
  34216. * Used to globally prevent autoclearing scenes.
  34217. */
  34218. static AUTOCLEAR: boolean;
  34219. /**
  34220. * @hidden
  34221. */
  34222. _useSceneAutoClearSetup: boolean;
  34223. private _scene;
  34224. private _renderingGroups;
  34225. private _depthStencilBufferAlreadyCleaned;
  34226. private _autoClearDepthStencil;
  34227. private _customOpaqueSortCompareFn;
  34228. private _customAlphaTestSortCompareFn;
  34229. private _customTransparentSortCompareFn;
  34230. private _renderingGroupInfo;
  34231. /**
  34232. * Instantiates a new rendering group for a particular scene
  34233. * @param scene Defines the scene the groups belongs to
  34234. */
  34235. constructor(scene: Scene);
  34236. private _clearDepthStencilBuffer;
  34237. /**
  34238. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  34239. * @hidden
  34240. */
  34241. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  34242. /**
  34243. * Resets the different information of the group to prepare a new frame
  34244. * @hidden
  34245. */
  34246. reset(): void;
  34247. /**
  34248. * Dispose and release the group and its associated resources.
  34249. * @hidden
  34250. */
  34251. dispose(): void;
  34252. /**
  34253. * Clear the info related to rendering groups preventing retention points during dispose.
  34254. */
  34255. freeRenderingGroups(): void;
  34256. private _prepareRenderingGroup;
  34257. /**
  34258. * Add a sprite manager to the rendering manager in order to render it this frame.
  34259. * @param spriteManager Define the sprite manager to render
  34260. */
  34261. dispatchSprites(spriteManager: ISpriteManager): void;
  34262. /**
  34263. * Add a particle system to the rendering manager in order to render it this frame.
  34264. * @param particleSystem Define the particle system to render
  34265. */
  34266. dispatchParticles(particleSystem: IParticleSystem): void;
  34267. /**
  34268. * Add a submesh to the manager in order to render it this frame
  34269. * @param subMesh The submesh to dispatch
  34270. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  34271. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  34272. */
  34273. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  34274. /**
  34275. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34276. * This allowed control for front to back rendering or reversly depending of the special needs.
  34277. *
  34278. * @param renderingGroupId The rendering group id corresponding to its index
  34279. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34280. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34281. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34282. */
  34283. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  34284. /**
  34285. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34286. *
  34287. * @param renderingGroupId The rendering group id corresponding to its index
  34288. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34289. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34290. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34291. */
  34292. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34293. /**
  34294. * Gets the current auto clear configuration for one rendering group of the rendering
  34295. * manager.
  34296. * @param index the rendering group index to get the information for
  34297. * @returns The auto clear setup for the requested rendering group
  34298. */
  34299. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34300. }
  34301. }
  34302. declare module BABYLON {
  34303. /**
  34304. * Renders a layer on top of an existing scene
  34305. */
  34306. class UtilityLayerRenderer implements IDisposable {
  34307. /** the original scene that will be rendered on top of */
  34308. originalScene: Scene;
  34309. private _pointerCaptures;
  34310. private _lastPointerEvents;
  34311. private static _DefaultUtilityLayer;
  34312. private static _DefaultKeepDepthUtilityLayer;
  34313. /**
  34314. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  34315. */
  34316. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  34317. /**
  34318. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  34319. */
  34320. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  34321. /**
  34322. * The scene that is rendered on top of the original scene
  34323. */
  34324. utilityLayerScene: Scene;
  34325. /**
  34326. * If the utility layer should automatically be rendered on top of existing scene
  34327. */
  34328. shouldRender: boolean;
  34329. /**
  34330. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  34331. */
  34332. onlyCheckPointerDownEvents: boolean;
  34333. /**
  34334. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  34335. */
  34336. processAllEvents: boolean;
  34337. /**
  34338. * Observable raised when the pointer move from the utility layer scene to the main scene
  34339. */
  34340. onPointerOutObservable: Observable<number>;
  34341. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  34342. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  34343. private _afterRenderObserver;
  34344. private _sceneDisposeObserver;
  34345. private _originalPointerObserver;
  34346. /**
  34347. * Instantiates a UtilityLayerRenderer
  34348. * @param originalScene the original scene that will be rendered on top of
  34349. */
  34350. constructor(
  34351. /** the original scene that will be rendered on top of */
  34352. originalScene: Scene);
  34353. private _notifyObservers;
  34354. /**
  34355. * Renders the utility layers scene on top of the original scene
  34356. */
  34357. render(): void;
  34358. /**
  34359. * Disposes of the renderer
  34360. */
  34361. dispose(): void;
  34362. private _updateCamera;
  34363. }
  34364. }
  34365. declare module BABYLON {
  34366. /**
  34367. * Postprocess used to generate anaglyphic rendering
  34368. */
  34369. class AnaglyphPostProcess extends PostProcess {
  34370. private _passedProcess;
  34371. /**
  34372. * Creates a new AnaglyphPostProcess
  34373. * @param name defines postprocess name
  34374. * @param options defines creation options or target ratio scale
  34375. * @param rigCameras defines cameras using this postprocess
  34376. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34377. * @param engine defines hosting engine
  34378. * @param reusable defines if the postprocess will be reused multiple times per frame
  34379. */
  34380. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34381. }
  34382. }
  34383. declare module BABYLON {
  34384. /**
  34385. * Post process used to render in black and white
  34386. */
  34387. class BlackAndWhitePostProcess extends PostProcess {
  34388. /**
  34389. * Linear about to convert he result to black and white (default: 1)
  34390. */
  34391. degree: number;
  34392. /**
  34393. * Creates a black and white post process
  34394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34395. * @param name The name of the effect.
  34396. * @param options The required width/height ratio to downsize to before computing the render pass.
  34397. * @param camera The camera to apply the render pass to.
  34398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34399. * @param engine The engine which the post process will be applied. (default: current engine)
  34400. * @param reusable If the post process can be reused on the same frame. (default: false)
  34401. */
  34402. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34403. }
  34404. }
  34405. declare module BABYLON {
  34406. /**
  34407. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34408. */
  34409. class BloomEffect extends PostProcessRenderEffect {
  34410. private bloomScale;
  34411. /**
  34412. * @hidden Internal
  34413. */
  34414. _effects: Array<PostProcess>;
  34415. /**
  34416. * @hidden Internal
  34417. */
  34418. _downscale: ExtractHighlightsPostProcess;
  34419. private _blurX;
  34420. private _blurY;
  34421. private _merge;
  34422. /**
  34423. * The luminance threshold to find bright areas of the image to bloom.
  34424. */
  34425. threshold: number;
  34426. /**
  34427. * The strength of the bloom.
  34428. */
  34429. weight: number;
  34430. /**
  34431. * Specifies the size of the bloom blur kernel, relative to the final output size
  34432. */
  34433. kernel: number;
  34434. /**
  34435. * Creates a new instance of @see BloomEffect
  34436. * @param scene The scene the effect belongs to.
  34437. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34438. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34439. * @param bloomWeight The the strength of bloom.
  34440. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34441. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34442. */
  34443. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34444. /**
  34445. * Disposes each of the internal effects for a given camera.
  34446. * @param camera The camera to dispose the effect on.
  34447. */
  34448. disposeEffects(camera: Camera): void;
  34449. /**
  34450. * @hidden Internal
  34451. */
  34452. _updateEffects(): void;
  34453. /**
  34454. * Internal
  34455. * @returns if all the contained post processes are ready.
  34456. * @hidden
  34457. */
  34458. _isReady(): boolean;
  34459. }
  34460. }
  34461. declare module BABYLON {
  34462. /**
  34463. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34464. */
  34465. class BloomMergePostProcess extends PostProcess {
  34466. /** Weight of the bloom to be added to the original input. */
  34467. weight: number;
  34468. /**
  34469. * Creates a new instance of @see BloomMergePostProcess
  34470. * @param name The name of the effect.
  34471. * @param originalFromInput Post process which's input will be used for the merge.
  34472. * @param blurred Blurred highlights post process which's output will be used.
  34473. * @param weight Weight of the bloom to be added to the original input.
  34474. * @param options The required width/height ratio to downsize to before computing the render pass.
  34475. * @param camera The camera to apply the render pass to.
  34476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34477. * @param engine The engine which the post process will be applied. (default: current engine)
  34478. * @param reusable If the post process can be reused on the same frame. (default: false)
  34479. * @param textureType Type of textures used when performing the post process. (default: 0)
  34480. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34481. */
  34482. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34483. /** Weight of the bloom to be added to the original input. */
  34484. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34485. }
  34486. }
  34487. declare module BABYLON {
  34488. /**
  34489. * The Blur Post Process which blurs an image based on a kernel and direction.
  34490. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34491. */
  34492. class BlurPostProcess extends PostProcess {
  34493. /** The direction in which to blur the image. */
  34494. direction: Vector2;
  34495. private blockCompilation;
  34496. protected _kernel: number;
  34497. protected _idealKernel: number;
  34498. protected _packedFloat: boolean;
  34499. private _staticDefines;
  34500. /**
  34501. * Sets the length in pixels of the blur sample region
  34502. */
  34503. /**
  34504. * Gets the length in pixels of the blur sample region
  34505. */
  34506. kernel: number;
  34507. /**
  34508. * Sets wether or not the blur needs to unpack/repack floats
  34509. */
  34510. /**
  34511. * Gets wether or not the blur is unpacking/repacking floats
  34512. */
  34513. packedFloat: boolean;
  34514. /**
  34515. * Creates a new instance BlurPostProcess
  34516. * @param name The name of the effect.
  34517. * @param direction The direction in which to blur the image.
  34518. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  34519. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34520. * @param camera The camera to apply the render pass to.
  34521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34522. * @param engine The engine which the post process will be applied. (default: current engine)
  34523. * @param reusable If the post process can be reused on the same frame. (default: false)
  34524. * @param textureType Type of textures used when performing the post process. (default: 0)
  34525. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34526. */
  34527. constructor(name: string,
  34528. /** The direction in which to blur the image. */
  34529. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34530. /**
  34531. * Updates the effect with the current post process compile time values and recompiles the shader.
  34532. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34533. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34534. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34535. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  34536. * @param onCompiled Called when the shader has been compiled.
  34537. * @param onError Called if there is an error when compiling a shader.
  34538. */
  34539. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34540. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34541. /**
  34542. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34543. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34544. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34545. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34546. * The gaps between physical kernels are compensated for in the weighting of the samples
  34547. * @param idealKernel Ideal blur kernel.
  34548. * @return Nearest best kernel.
  34549. */
  34550. protected _nearestBestKernel(idealKernel: number): number;
  34551. /**
  34552. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34553. * @param x The point on the Gaussian distribution to sample.
  34554. * @return the value of the Gaussian function at x.
  34555. */
  34556. protected _gaussianWeight(x: number): number;
  34557. /**
  34558. * Generates a string that can be used as a floating point number in GLSL.
  34559. * @param x Value to print.
  34560. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34561. * @return GLSL float string.
  34562. */
  34563. protected _glslFloat(x: number, decimalFigures?: number): string;
  34564. }
  34565. }
  34566. declare module BABYLON {
  34567. /**
  34568. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34569. */
  34570. class ChromaticAberrationPostProcess extends PostProcess {
  34571. /**
  34572. * The amount of seperation of rgb channels (default: 30)
  34573. */
  34574. aberrationAmount: number;
  34575. /**
  34576. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34577. */
  34578. radialIntensity: number;
  34579. /**
  34580. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  34581. */
  34582. direction: Vector2;
  34583. /**
  34584. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  34585. */
  34586. centerPosition: Vector2;
  34587. /**
  34588. * Creates a new instance ChromaticAberrationPostProcess
  34589. * @param name The name of the effect.
  34590. * @param screenWidth The width of the screen to apply the effect on.
  34591. * @param screenHeight The height of the screen to apply the effect on.
  34592. * @param options The required width/height ratio to downsize to before computing the render pass.
  34593. * @param camera The camera to apply the render pass to.
  34594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34595. * @param engine The engine which the post process will be applied. (default: current engine)
  34596. * @param reusable If the post process can be reused on the same frame. (default: false)
  34597. * @param textureType Type of textures used when performing the post process. (default: 0)
  34598. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34599. */
  34600. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34601. }
  34602. }
  34603. declare module BABYLON {
  34604. /**
  34605. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34606. */
  34607. class CircleOfConfusionPostProcess extends PostProcess {
  34608. /**
  34609. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  34610. */
  34611. lensSize: number;
  34612. /**
  34613. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34614. */
  34615. fStop: number;
  34616. /**
  34617. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34618. */
  34619. focusDistance: number;
  34620. /**
  34621. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34622. */
  34623. focalLength: number;
  34624. private _depthTexture;
  34625. /**
  34626. * Creates a new instance CircleOfConfusionPostProcess
  34627. * @param name The name of the effect.
  34628. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  34629. * @param options The required width/height ratio to downsize to before computing the render pass.
  34630. * @param camera The camera to apply the render pass to.
  34631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34632. * @param engine The engine which the post process will be applied. (default: current engine)
  34633. * @param reusable If the post process can be reused on the same frame. (default: false)
  34634. * @param textureType Type of textures used when performing the post process. (default: 0)
  34635. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34636. */
  34637. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34638. /**
  34639. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  34640. */
  34641. depthTexture: RenderTargetTexture;
  34642. }
  34643. }
  34644. declare module BABYLON {
  34645. /**
  34646. *
  34647. * This post-process allows the modification of rendered colors by using
  34648. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34649. *
  34650. * The object needs to be provided an url to a texture containing the color
  34651. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34652. * Use an image editing software to tweak the LUT to match your needs.
  34653. *
  34654. * For an example of a color LUT, see here:
  34655. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34656. * For explanations on color grading, see here:
  34657. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34658. *
  34659. */
  34660. class ColorCorrectionPostProcess extends PostProcess {
  34661. private _colorTableTexture;
  34662. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34663. }
  34664. }
  34665. declare module BABYLON {
  34666. /**
  34667. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34668. * input texture to perform effects such as edge detection or sharpening
  34669. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34670. */
  34671. class ConvolutionPostProcess extends PostProcess {
  34672. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34673. kernel: number[];
  34674. /**
  34675. * Creates a new instance ConvolutionPostProcess
  34676. * @param name The name of the effect.
  34677. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34678. * @param options The required width/height ratio to downsize to before computing the render pass.
  34679. * @param camera The camera to apply the render pass to.
  34680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34681. * @param engine The engine which the post process will be applied. (default: current engine)
  34682. * @param reusable If the post process can be reused on the same frame. (default: false)
  34683. * @param textureType Type of textures used when performing the post process. (default: 0)
  34684. */
  34685. constructor(name: string,
  34686. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34687. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34688. /**
  34689. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34690. */
  34691. static EdgeDetect0Kernel: number[];
  34692. /**
  34693. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34694. */
  34695. static EdgeDetect1Kernel: number[];
  34696. /**
  34697. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34698. */
  34699. static EdgeDetect2Kernel: number[];
  34700. /**
  34701. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34702. */
  34703. static SharpenKernel: number[];
  34704. /**
  34705. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34706. */
  34707. static EmbossKernel: number[];
  34708. /**
  34709. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34710. */
  34711. static GaussianKernel: number[];
  34712. }
  34713. }
  34714. declare module BABYLON {
  34715. /**
  34716. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34717. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34718. * based on samples that have a large difference in distance than the center pixel.
  34719. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34720. */
  34721. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34722. direction: Vector2;
  34723. /**
  34724. * Creates a new instance CircleOfConfusionPostProcess
  34725. * @param name The name of the effect.
  34726. * @param scene The scene the effect belongs to.
  34727. * @param direction The direction the blur should be applied.
  34728. * @param kernel The size of the kernel used to blur.
  34729. * @param options The required width/height ratio to downsize to before computing the render pass.
  34730. * @param camera The camera to apply the render pass to.
  34731. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34732. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34734. * @param engine The engine which the post process will be applied. (default: current engine)
  34735. * @param reusable If the post process can be reused on the same frame. (default: false)
  34736. * @param textureType Type of textures used when performing the post process. (default: 0)
  34737. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34738. */
  34739. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34740. }
  34741. }
  34742. declare module BABYLON {
  34743. /**
  34744. * Specifies the level of max blur that should be applied when using the depth of field effect
  34745. */
  34746. enum DepthOfFieldEffectBlurLevel {
  34747. /**
  34748. * Subtle blur
  34749. */
  34750. Low = 0,
  34751. /**
  34752. * Medium blur
  34753. */
  34754. Medium = 1,
  34755. /**
  34756. * Large blur
  34757. */
  34758. High = 2
  34759. }
  34760. /**
  34761. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34762. */
  34763. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34764. private _circleOfConfusion;
  34765. /**
  34766. * @hidden Internal, blurs from high to low
  34767. */
  34768. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34769. private _depthOfFieldBlurY;
  34770. private _dofMerge;
  34771. /**
  34772. * @hidden Internal post processes in depth of field effect
  34773. */
  34774. _effects: Array<PostProcess>;
  34775. /**
  34776. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34777. */
  34778. focalLength: number;
  34779. /**
  34780. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34781. */
  34782. fStop: number;
  34783. /**
  34784. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34785. */
  34786. focusDistance: number;
  34787. /**
  34788. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  34789. */
  34790. lensSize: number;
  34791. /**
  34792. * Creates a new instance DepthOfFieldEffect
  34793. * @param scene The scene the effect belongs to.
  34794. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  34795. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34796. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34797. */
  34798. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34799. /**
  34800. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  34801. */
  34802. depthTexture: RenderTargetTexture;
  34803. /**
  34804. * Disposes each of the internal effects for a given camera.
  34805. * @param camera The camera to dispose the effect on.
  34806. */
  34807. disposeEffects(camera: Camera): void;
  34808. /**
  34809. * @hidden Internal
  34810. */
  34811. _updateEffects(): void;
  34812. /**
  34813. * Internal
  34814. * @returns if all the contained post processes are ready.
  34815. * @hidden
  34816. */
  34817. _isReady(): boolean;
  34818. }
  34819. }
  34820. declare module BABYLON {
  34821. /**
  34822. * Options to be set when merging outputs from the default pipeline.
  34823. */
  34824. class DepthOfFieldMergePostProcessOptions {
  34825. /**
  34826. * The original image to merge on top of
  34827. */
  34828. originalFromInput: PostProcess;
  34829. /**
  34830. * Parameters to perform the merge of the depth of field effect
  34831. */
  34832. depthOfField?: {
  34833. circleOfConfusion: PostProcess;
  34834. blurSteps: Array<PostProcess>;
  34835. };
  34836. /**
  34837. * Parameters to perform the merge of bloom effect
  34838. */
  34839. bloom?: {
  34840. blurred: PostProcess;
  34841. weight: number;
  34842. };
  34843. }
  34844. /**
  34845. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34846. */
  34847. class DepthOfFieldMergePostProcess extends PostProcess {
  34848. private blurSteps;
  34849. /**
  34850. * Creates a new instance of DepthOfFieldMergePostProcess
  34851. * @param name The name of the effect.
  34852. * @param originalFromInput Post process which's input will be used for the merge.
  34853. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34854. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34855. * @param options The required width/height ratio to downsize to before computing the render pass.
  34856. * @param camera The camera to apply the render pass to.
  34857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34858. * @param engine The engine which the post process will be applied. (default: current engine)
  34859. * @param reusable If the post process can be reused on the same frame. (default: false)
  34860. * @param textureType Type of textures used when performing the post process. (default: 0)
  34861. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34862. */
  34863. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34864. /**
  34865. * Updates the effect with the current post process compile time values and recompiles the shader.
  34866. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34867. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34868. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34869. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  34870. * @param onCompiled Called when the shader has been compiled.
  34871. * @param onError Called if there is an error when compiling a shader.
  34872. */
  34873. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34874. }
  34875. }
  34876. declare module BABYLON {
  34877. /**
  34878. * DisplayPassPostProcess which produces an output the same as it's input
  34879. */
  34880. class DisplayPassPostProcess extends PostProcess {
  34881. /**
  34882. * Creates the DisplayPassPostProcess
  34883. * @param name The name of the effect.
  34884. * @param options The required width/height ratio to downsize to before computing the render pass.
  34885. * @param camera The camera to apply the render pass to.
  34886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34887. * @param engine The engine which the post process will be applied. (default: current engine)
  34888. * @param reusable If the post process can be reused on the same frame. (default: false)
  34889. */
  34890. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34891. }
  34892. }
  34893. declare module BABYLON {
  34894. /**
  34895. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  34896. */
  34897. class ExtractHighlightsPostProcess extends PostProcess {
  34898. /**
  34899. * The luminance threshold, pixels below this value will be set to black.
  34900. */
  34901. threshold: number;
  34902. /** @hidden */
  34903. _exposure: number;
  34904. /**
  34905. * Post process which has the input texture to be used when performing highlight extraction
  34906. * @hidden
  34907. */
  34908. _inputPostProcess: Nullable<PostProcess>;
  34909. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34910. }
  34911. }
  34912. declare module BABYLON {
  34913. /**
  34914. * Applies a kernel filter to the image
  34915. */
  34916. class FilterPostProcess extends PostProcess {
  34917. /** The matrix to be applied to the image */
  34918. kernelMatrix: Matrix;
  34919. /**
  34920. *
  34921. * @param name The name of the effect.
  34922. * @param kernelMatrix The matrix to be applied to the image
  34923. * @param options The required width/height ratio to downsize to before computing the render pass.
  34924. * @param camera The camera to apply the render pass to.
  34925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34926. * @param engine The engine which the post process will be applied. (default: current engine)
  34927. * @param reusable If the post process can be reused on the same frame. (default: false)
  34928. */
  34929. constructor(name: string,
  34930. /** The matrix to be applied to the image */
  34931. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34932. }
  34933. }
  34934. declare module BABYLON {
  34935. /**
  34936. * Fxaa post process
  34937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34938. */
  34939. class FxaaPostProcess extends PostProcess {
  34940. /** @hidden */
  34941. texelWidth: number;
  34942. /** @hidden */
  34943. texelHeight: number;
  34944. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34945. private _getDefines;
  34946. }
  34947. }
  34948. declare module BABYLON {
  34949. /**
  34950. * The GrainPostProcess adds noise to the image at mid luminance levels
  34951. */
  34952. class GrainPostProcess extends PostProcess {
  34953. /**
  34954. * The intensity of the grain added (default: 30)
  34955. */
  34956. intensity: number;
  34957. /**
  34958. * If the grain should be randomized on every frame
  34959. */
  34960. animated: boolean;
  34961. /**
  34962. * Creates a new instance of @see GrainPostProcess
  34963. * @param name The name of the effect.
  34964. * @param options The required width/height ratio to downsize to before computing the render pass.
  34965. * @param camera The camera to apply the render pass to.
  34966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34967. * @param engine The engine which the post process will be applied. (default: current engine)
  34968. * @param reusable If the post process can be reused on the same frame. (default: false)
  34969. * @param textureType Type of textures used when performing the post process. (default: 0)
  34970. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  34971. */
  34972. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34973. }
  34974. }
  34975. declare module BABYLON {
  34976. /**
  34977. * Extracts highlights from the image
  34978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34979. */
  34980. class HighlightsPostProcess extends PostProcess {
  34981. /**
  34982. * Extracts highlights from the image
  34983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34984. * @param name The name of the effect.
  34985. * @param options The required width/height ratio to downsize to before computing the render pass.
  34986. * @param camera The camera to apply the render pass to.
  34987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34988. * @param engine The engine which the post process will be applied. (default: current engine)
  34989. * @param reusable If the post process can be reused on the same frame. (default: false)
  34990. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34991. */
  34992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34993. }
  34994. }
  34995. declare module BABYLON {
  34996. /**
  34997. * ImageProcessingPostProcess
  34998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34999. */
  35000. class ImageProcessingPostProcess extends PostProcess {
  35001. /**
  35002. * Default configuration related to image processing available in the PBR Material.
  35003. */
  35004. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35005. /**
  35006. * Gets the image processing configuration used either in this material.
  35007. */
  35008. /**
  35009. * Sets the Default image processing configuration used either in the this material.
  35010. *
  35011. * If sets to null, the scene one is in use.
  35012. */
  35013. imageProcessingConfiguration: ImageProcessingConfiguration;
  35014. /**
  35015. * Keep track of the image processing observer to allow dispose and replace.
  35016. */
  35017. private _imageProcessingObserver;
  35018. /**
  35019. * Attaches a new image processing configuration to the PBR Material.
  35020. * @param configuration
  35021. */
  35022. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35023. /**
  35024. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35025. */
  35026. /**
  35027. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35028. */
  35029. colorCurves: Nullable<ColorCurves>;
  35030. /**
  35031. * Gets wether the color curves effect is enabled.
  35032. */
  35033. /**
  35034. * Sets wether the color curves effect is enabled.
  35035. */
  35036. colorCurvesEnabled: boolean;
  35037. /**
  35038. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35039. */
  35040. /**
  35041. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35042. */
  35043. colorGradingTexture: Nullable<BaseTexture>;
  35044. /**
  35045. * Gets wether the color grading effect is enabled.
  35046. */
  35047. /**
  35048. * Gets wether the color grading effect is enabled.
  35049. */
  35050. colorGradingEnabled: boolean;
  35051. /**
  35052. * Gets exposure used in the effect.
  35053. */
  35054. /**
  35055. * Sets exposure used in the effect.
  35056. */
  35057. exposure: number;
  35058. /**
  35059. * Gets wether tonemapping is enabled or not.
  35060. */
  35061. /**
  35062. * Sets wether tonemapping is enabled or not
  35063. */
  35064. toneMappingEnabled: boolean;
  35065. /**
  35066. * Gets contrast used in the effect.
  35067. */
  35068. /**
  35069. * Sets contrast used in the effect.
  35070. */
  35071. contrast: number;
  35072. /**
  35073. * Gets Vignette stretch size.
  35074. */
  35075. /**
  35076. * Sets Vignette stretch size.
  35077. */
  35078. vignetteStretch: number;
  35079. /**
  35080. * Gets Vignette centre X Offset.
  35081. */
  35082. /**
  35083. * Sets Vignette centre X Offset.
  35084. */
  35085. vignetteCentreX: number;
  35086. /**
  35087. * Gets Vignette centre Y Offset.
  35088. */
  35089. /**
  35090. * Sets Vignette centre Y Offset.
  35091. */
  35092. vignetteCentreY: number;
  35093. /**
  35094. * Gets Vignette weight or intensity of the vignette effect.
  35095. */
  35096. /**
  35097. * Sets Vignette weight or intensity of the vignette effect.
  35098. */
  35099. vignetteWeight: number;
  35100. /**
  35101. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35102. * if vignetteEnabled is set to true.
  35103. */
  35104. /**
  35105. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35106. * if vignetteEnabled is set to true.
  35107. */
  35108. vignetteColor: Color4;
  35109. /**
  35110. * Gets Camera field of view used by the Vignette effect.
  35111. */
  35112. /**
  35113. * Sets Camera field of view used by the Vignette effect.
  35114. */
  35115. vignetteCameraFov: number;
  35116. /**
  35117. * Gets the vignette blend mode allowing different kind of effect.
  35118. */
  35119. /**
  35120. * Sets the vignette blend mode allowing different kind of effect.
  35121. */
  35122. vignetteBlendMode: number;
  35123. /**
  35124. * Gets wether the vignette effect is enabled.
  35125. */
  35126. /**
  35127. * Sets wether the vignette effect is enabled.
  35128. */
  35129. vignetteEnabled: boolean;
  35130. private _fromLinearSpace;
  35131. /**
  35132. * Gets wether the input of the processing is in Gamma or Linear Space.
  35133. */
  35134. /**
  35135. * Sets wether the input of the processing is in Gamma or Linear Space.
  35136. */
  35137. fromLinearSpace: boolean;
  35138. /**
  35139. * Defines cache preventing GC.
  35140. */
  35141. private _defines;
  35142. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35143. /**
  35144. * "ImageProcessingPostProcess"
  35145. * @returns "ImageProcessingPostProcess"
  35146. */
  35147. getClassName(): string;
  35148. protected _updateParameters(): void;
  35149. dispose(camera?: Camera): void;
  35150. }
  35151. }
  35152. declare module BABYLON {
  35153. /**
  35154. * PassPostProcess which produces an output the same as it's input
  35155. */
  35156. class PassPostProcess extends PostProcess {
  35157. /**
  35158. * Creates the PassPostProcess
  35159. * @param name The name of the effect.
  35160. * @param options The required width/height ratio to downsize to before computing the render pass.
  35161. * @param camera The camera to apply the render pass to.
  35162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35163. * @param engine The engine which the post process will be applied. (default: current engine)
  35164. * @param reusable If the post process can be reused on the same frame. (default: false)
  35165. * @param textureType The type of texture to be used when performing the post processing.
  35166. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  35167. */
  35168. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35169. }
  35170. }
  35171. declare module BABYLON {
  35172. /**
  35173. * Size options for a post process
  35174. */
  35175. type PostProcessOptions = {
  35176. width: number;
  35177. height: number;
  35178. };
  35179. /**
  35180. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35181. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35182. */
  35183. class PostProcess {
  35184. /** Name of the PostProcess. */
  35185. name: string;
  35186. /**
  35187. * Width of the texture to apply the post process on
  35188. */
  35189. width: number;
  35190. /**
  35191. * Height of the texture to apply the post process on
  35192. */
  35193. height: number;
  35194. /**
  35195. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35196. * @hidden
  35197. */
  35198. _outputTexture: Nullable<InternalTexture>;
  35199. /**
  35200. * Sampling mode used by the shader
  35201. * See https://doc.babylonjs.com/classes/3.1/texture
  35202. */
  35203. renderTargetSamplingMode: number;
  35204. /**
  35205. * Clear color to use when screen clearing
  35206. */
  35207. clearColor: Color4;
  35208. /**
  35209. * If the buffer needs to be cleared before applying the post process. (default: true)
  35210. * Should be set to false if shader will overwrite all previous pixels.
  35211. */
  35212. autoClear: boolean;
  35213. /**
  35214. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35215. */
  35216. alphaMode: number;
  35217. /**
  35218. * Sets the setAlphaBlendConstants of the babylon engine
  35219. */
  35220. alphaConstants: Color4;
  35221. /**
  35222. * Animations to be used for the post processing
  35223. */
  35224. animations: Animation[];
  35225. /**
  35226. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35227. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35228. */
  35229. enablePixelPerfectMode: boolean;
  35230. /**
  35231. * Force the postprocess to be applied without taking in account viewport
  35232. */
  35233. forceFullscreenViewport: boolean;
  35234. /**
  35235. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35236. *
  35237. * | Value | Type | Description |
  35238. * | ----- | ----------------------------------- | ----------- |
  35239. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35240. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35241. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35242. *
  35243. */
  35244. scaleMode: number;
  35245. /**
  35246. * Force textures to be a power of two (default: false)
  35247. */
  35248. alwaysForcePOT: boolean;
  35249. private _samples;
  35250. /**
  35251. * Number of sample textures (default: 1)
  35252. */
  35253. samples: number;
  35254. /**
  35255. * Modify the scale of the post process to be the same as the viewport (default: false)
  35256. */
  35257. adaptScaleToCurrentViewport: boolean;
  35258. private _camera;
  35259. private _scene;
  35260. private _engine;
  35261. private _options;
  35262. private _reusable;
  35263. private _textureType;
  35264. /**
  35265. * Smart array of input and output textures for the post process.
  35266. * @hidden
  35267. */
  35268. _textures: SmartArray<InternalTexture>;
  35269. /**
  35270. * The index in _textures that corresponds to the output texture.
  35271. * @hidden
  35272. */
  35273. _currentRenderTextureInd: number;
  35274. private _effect;
  35275. private _samplers;
  35276. private _fragmentUrl;
  35277. private _vertexUrl;
  35278. private _parameters;
  35279. private _scaleRatio;
  35280. protected _indexParameters: any;
  35281. private _shareOutputWithPostProcess;
  35282. private _texelSize;
  35283. private _forcedOutputTexture;
  35284. /**
  35285. * An event triggered when the postprocess is activated.
  35286. */
  35287. onActivateObservable: Observable<Camera>;
  35288. private _onActivateObserver;
  35289. /**
  35290. * A function that is added to the onActivateObservable
  35291. */
  35292. onActivate: Nullable<(camera: Camera) => void>;
  35293. /**
  35294. * An event triggered when the postprocess changes its size.
  35295. */
  35296. onSizeChangedObservable: Observable<PostProcess>;
  35297. private _onSizeChangedObserver;
  35298. /**
  35299. * A function that is added to the onSizeChangedObservable
  35300. */
  35301. onSizeChanged: (postProcess: PostProcess) => void;
  35302. /**
  35303. * An event triggered when the postprocess applies its effect.
  35304. */
  35305. onApplyObservable: Observable<Effect>;
  35306. private _onApplyObserver;
  35307. /**
  35308. * A function that is added to the onApplyObservable
  35309. */
  35310. onApply: (effect: Effect) => void;
  35311. /**
  35312. * An event triggered before rendering the postprocess
  35313. */
  35314. onBeforeRenderObservable: Observable<Effect>;
  35315. private _onBeforeRenderObserver;
  35316. /**
  35317. * A function that is added to the onBeforeRenderObservable
  35318. */
  35319. onBeforeRender: (effect: Effect) => void;
  35320. /**
  35321. * An event triggered after rendering the postprocess
  35322. */
  35323. onAfterRenderObservable: Observable<Effect>;
  35324. private _onAfterRenderObserver;
  35325. /**
  35326. * A function that is added to the onAfterRenderObservable
  35327. */
  35328. onAfterRender: (efect: Effect) => void;
  35329. /**
  35330. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  35331. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35332. */
  35333. inputTexture: InternalTexture;
  35334. /**
  35335. * Gets the camera which post process is applied to.
  35336. * @returns The camera the post process is applied to.
  35337. */
  35338. getCamera(): Camera;
  35339. /**
  35340. * Gets the texel size of the postprocess.
  35341. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35342. */
  35343. readonly texelSize: Vector2;
  35344. /**
  35345. * Creates a new instance PostProcess
  35346. * @param name The name of the PostProcess.
  35347. * @param fragmentUrl The url of the fragment shader to be used.
  35348. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35349. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35350. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35351. * @param camera The camera to apply the render pass to.
  35352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35353. * @param engine The engine which the post process will be applied. (default: current engine)
  35354. * @param reusable If the post process can be reused on the same frame. (default: false)
  35355. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35356. * @param textureType Type of textures used when performing the post process. (default: 0)
  35357. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35358. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  35359. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35360. */
  35361. constructor(
  35362. /** Name of the PostProcess. */
  35363. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  35364. /**
  35365. * Gets the engine which this post process belongs to.
  35366. * @returns The engine the post process was enabled with.
  35367. */
  35368. getEngine(): Engine;
  35369. /**
  35370. * The effect that is created when initializing the post process.
  35371. * @returns The created effect corrisponding the the postprocess.
  35372. */
  35373. getEffect(): Effect;
  35374. /**
  35375. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35376. * @param postProcess The post process to share the output with.
  35377. * @returns This post process.
  35378. */
  35379. shareOutputWith(postProcess: PostProcess): PostProcess;
  35380. /**
  35381. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35382. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35383. */
  35384. useOwnOutput(): void;
  35385. /**
  35386. * Updates the effect with the current post process compile time values and recompiles the shader.
  35387. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35388. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35389. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35390. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  35391. * @param onCompiled Called when the shader has been compiled.
  35392. * @param onError Called if there is an error when compiling a shader.
  35393. */
  35394. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35395. /**
  35396. * The post process is reusable if it can be used multiple times within one frame.
  35397. * @returns If the post process is reusable
  35398. */
  35399. isReusable(): boolean;
  35400. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35401. markTextureDirty(): void;
  35402. /**
  35403. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35404. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  35405. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35406. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35407. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35408. * @returns The target texture that was bound to be written to.
  35409. */
  35410. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35411. /**
  35412. * If the post process is supported.
  35413. */
  35414. readonly isSupported: boolean;
  35415. /**
  35416. * The aspect ratio of the output texture.
  35417. */
  35418. readonly aspectRatio: number;
  35419. /**
  35420. * Get a value indicating if the post-process is ready to be used
  35421. * @returns true if the post-process is ready (shader is compiled)
  35422. */
  35423. isReady(): boolean;
  35424. /**
  35425. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35426. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35427. */
  35428. apply(): Nullable<Effect>;
  35429. private _disposeTextures;
  35430. /**
  35431. * Disposes the post process.
  35432. * @param camera The camera to dispose the post process on.
  35433. */
  35434. dispose(camera?: Camera): void;
  35435. }
  35436. }
  35437. declare module BABYLON {
  35438. /**
  35439. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35440. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35441. */
  35442. class PostProcessManager {
  35443. private _scene;
  35444. private _indexBuffer;
  35445. private _vertexBuffers;
  35446. /**
  35447. * Creates a new instance PostProcess
  35448. * @param scene The scene that the post process is associated with.
  35449. */
  35450. constructor(scene: Scene);
  35451. private _prepareBuffers;
  35452. private _buildIndexBuffer;
  35453. /**
  35454. * Rebuilds the vertex buffers of the manager.
  35455. * @hidden
  35456. */
  35457. _rebuild(): void;
  35458. /**
  35459. * Prepares a frame to be run through a post process.
  35460. * @param sourceTexture The input texture to the post procesess. (default: null)
  35461. * @param postProcesses An array of post processes to be run. (default: null)
  35462. * @returns True if the post processes were able to be run.
  35463. * @hidden
  35464. */
  35465. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35466. /**
  35467. * Manually render a set of post processes to a texture.
  35468. * @param postProcesses An array of post processes to be run.
  35469. * @param targetTexture The target texture to render to.
  35470. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35471. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35472. * @param lodLevel defines which lod of the texture to render to
  35473. */
  35474. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35475. /**
  35476. * Finalize the result of the output of the postprocesses.
  35477. * @param doNotPresent If true the result will not be displayed to the screen.
  35478. * @param targetTexture The target texture to render to.
  35479. * @param faceIndex The index of the face to bind the target texture to.
  35480. * @param postProcesses The array of post processes to render.
  35481. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35482. * @hidden
  35483. */
  35484. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35485. /**
  35486. * Disposes of the post process manager.
  35487. */
  35488. dispose(): void;
  35489. }
  35490. }
  35491. declare module BABYLON {
  35492. /**
  35493. * Post process which applies a refractin texture
  35494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35495. */
  35496. class RefractionPostProcess extends PostProcess {
  35497. /** the base color of the refraction (used to taint the rendering) */
  35498. color: Color3;
  35499. /** simulated refraction depth */
  35500. depth: number;
  35501. /** the coefficient of the base color (0 to remove base color tainting) */
  35502. colorLevel: number;
  35503. private _refTexture;
  35504. private _ownRefractionTexture;
  35505. /**
  35506. * Gets or sets the refraction texture
  35507. * Please note that you are responsible for disposing the texture if you set it manually
  35508. */
  35509. refractionTexture: Texture;
  35510. /**
  35511. * Initializes the RefractionPostProcess
  35512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35513. * @param name The name of the effect.
  35514. * @param refractionTextureUrl Url of the refraction texture to use
  35515. * @param color the base color of the refraction (used to taint the rendering)
  35516. * @param depth simulated refraction depth
  35517. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35518. * @param camera The camera to apply the render pass to.
  35519. * @param options The required width/height ratio to downsize to before computing the render pass.
  35520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35521. * @param engine The engine which the post process will be applied. (default: current engine)
  35522. * @param reusable If the post process can be reused on the same frame. (default: false)
  35523. */
  35524. constructor(name: string, refractionTextureUrl: string,
  35525. /** the base color of the refraction (used to taint the rendering) */
  35526. color: Color3,
  35527. /** simulated refraction depth */
  35528. depth: number,
  35529. /** the coefficient of the base color (0 to remove base color tainting) */
  35530. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35531. /**
  35532. * Disposes of the post process
  35533. * @param camera Camera to dispose post process on
  35534. */
  35535. dispose(camera: Camera): void;
  35536. }
  35537. }
  35538. declare module BABYLON {
  35539. /**
  35540. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35541. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35542. */
  35543. class SharpenPostProcess extends PostProcess {
  35544. /**
  35545. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35546. */
  35547. colorAmount: number;
  35548. /**
  35549. * How much sharpness should be applied (default: 0.3)
  35550. */
  35551. edgeAmount: number;
  35552. /**
  35553. * Creates a new instance ConvolutionPostProcess
  35554. * @param name The name of the effect.
  35555. * @param options The required width/height ratio to downsize to before computing the render pass.
  35556. * @param camera The camera to apply the render pass to.
  35557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35558. * @param engine The engine which the post process will be applied. (default: current engine)
  35559. * @param reusable If the post process can be reused on the same frame. (default: false)
  35560. * @param textureType Type of textures used when performing the post process. (default: 0)
  35561. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  35562. */
  35563. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35564. }
  35565. }
  35566. declare module BABYLON {
  35567. /**
  35568. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35569. */
  35570. class StereoscopicInterlacePostProcess extends PostProcess {
  35571. private _stepSize;
  35572. private _passedProcess;
  35573. /**
  35574. * Initializes a StereoscopicInterlacePostProcess
  35575. * @param name The name of the effect.
  35576. * @param rigCameras The rig cameras to be appled to the post process
  35577. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35579. * @param engine The engine which the post process will be applied. (default: current engine)
  35580. * @param reusable If the post process can be reused on the same frame. (default: false)
  35581. */
  35582. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35583. }
  35584. }
  35585. declare module BABYLON {
  35586. /** Defines operator used for tonemapping */
  35587. enum TonemappingOperator {
  35588. /** Hable */
  35589. Hable = 0,
  35590. /** Reinhard */
  35591. Reinhard = 1,
  35592. /** HejiDawson */
  35593. HejiDawson = 2,
  35594. /** Photographic */
  35595. Photographic = 3
  35596. }
  35597. /**
  35598. * Defines a post process to apply tone mapping
  35599. */
  35600. class TonemapPostProcess extends PostProcess {
  35601. private _operator;
  35602. /** Defines the required exposure adjustement */
  35603. exposureAdjustment: number;
  35604. /**
  35605. * Creates a new TonemapPostProcess
  35606. * @param name defines the name of the postprocess
  35607. * @param _operator defines the operator to use
  35608. * @param exposureAdjustment defines the required exposure adjustement
  35609. * @param camera defines the camera to use (can be null)
  35610. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35611. * @param engine defines the hosting engine (can be ignore if camera is set)
  35612. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35613. */
  35614. constructor(name: string, _operator: TonemappingOperator,
  35615. /** Defines the required exposure adjustement */
  35616. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35617. }
  35618. }
  35619. declare module BABYLON {
  35620. /**
  35621. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35622. */
  35623. class VolumetricLightScatteringPostProcess extends PostProcess {
  35624. private _volumetricLightScatteringPass;
  35625. private _volumetricLightScatteringRTT;
  35626. private _viewPort;
  35627. private _screenCoordinates;
  35628. private _cachedDefines;
  35629. /**
  35630. * If not undefined, the mesh position is computed from the attached node position
  35631. */
  35632. attachedNode: {
  35633. position: Vector3;
  35634. };
  35635. /**
  35636. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35637. */
  35638. customMeshPosition: Vector3;
  35639. /**
  35640. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35641. */
  35642. useCustomMeshPosition: boolean;
  35643. /**
  35644. * If the post-process should inverse the light scattering direction
  35645. */
  35646. invert: boolean;
  35647. /**
  35648. * The internal mesh used by the post-process
  35649. */
  35650. mesh: Mesh;
  35651. /**
  35652. * @hidden
  35653. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35654. */
  35655. useDiffuseColor: boolean;
  35656. /**
  35657. * Array containing the excluded meshes not rendered in the internal pass
  35658. */
  35659. excludedMeshes: AbstractMesh[];
  35660. /**
  35661. * Controls the overall intensity of the post-process
  35662. */
  35663. exposure: number;
  35664. /**
  35665. * Dissipates each sample's contribution in range [0, 1]
  35666. */
  35667. decay: number;
  35668. /**
  35669. * Controls the overall intensity of each sample
  35670. */
  35671. weight: number;
  35672. /**
  35673. * Controls the density of each sample
  35674. */
  35675. density: number;
  35676. /**
  35677. * @constructor
  35678. * @param name The post-process name
  35679. * @param 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)
  35680. * @param camera The camera that the post-process will be attached to
  35681. * @param mesh The mesh used to create the light scattering
  35682. * @param samples The post-process quality, default 100
  35683. * @param samplingModeThe post-process filtering mode
  35684. * @param engine The babylon engine
  35685. * @param reusable If the post-process is reusable
  35686. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35687. */
  35688. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35689. /**
  35690. * Returns the string "VolumetricLightScatteringPostProcess"
  35691. * @returns "VolumetricLightScatteringPostProcess"
  35692. */
  35693. getClassName(): string;
  35694. private _isReady;
  35695. /**
  35696. * Sets the new light position for light scattering effect
  35697. * @param position The new custom light position
  35698. */
  35699. setCustomMeshPosition(position: Vector3): void;
  35700. /**
  35701. * Returns the light position for light scattering effect
  35702. * @return Vector3 The custom light position
  35703. */
  35704. getCustomMeshPosition(): Vector3;
  35705. /**
  35706. * Disposes the internal assets and detaches the post-process from the camera
  35707. */
  35708. dispose(camera: Camera): void;
  35709. /**
  35710. * Returns the render target texture used by the post-process
  35711. * @return the render target texture used by the post-process
  35712. */
  35713. getPass(): RenderTargetTexture;
  35714. private _meshExcluded;
  35715. private _createPass;
  35716. private _updateMeshScreenCoordinates;
  35717. /**
  35718. * Creates a default mesh for the Volumeric Light Scattering post-process
  35719. * @param name The mesh name
  35720. * @param scene The scene where to create the mesh
  35721. * @return the default mesh
  35722. */
  35723. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35724. }
  35725. }
  35726. declare module BABYLON {
  35727. /**
  35728. * VRDistortionCorrectionPostProcess used for mobile VR
  35729. */
  35730. class VRDistortionCorrectionPostProcess extends PostProcess {
  35731. private _isRightEye;
  35732. private _distortionFactors;
  35733. private _postProcessScaleFactor;
  35734. private _lensCenterOffset;
  35735. private _scaleIn;
  35736. private _scaleFactor;
  35737. private _lensCenter;
  35738. /**
  35739. * Initializes the VRDistortionCorrectionPostProcess
  35740. * @param name The name of the effect.
  35741. * @param camera The camera to apply the render pass to.
  35742. * @param isRightEye If this is for the right eye distortion
  35743. * @param vrMetrics All the required metrics for the VR camera
  35744. */
  35745. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35746. }
  35747. }
  35748. declare module BABYLON {
  35749. /**
  35750. * Class used to represent a sprite
  35751. * @see http://doc.babylonjs.com/babylon101/sprites
  35752. */
  35753. class Sprite {
  35754. /** defines the name */
  35755. name: string;
  35756. /** Gets or sets the current world position */
  35757. position: Vector3;
  35758. /** Gets or sets the main color */
  35759. color: Color4;
  35760. /** Gets or sets the width */
  35761. width: number;
  35762. /** Gets or sets the height */
  35763. height: number;
  35764. /** Gets or sets rotation angle */
  35765. angle: number;
  35766. /** Gets or sets the cell index in the sprite sheet */
  35767. cellIndex: number;
  35768. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  35769. invertU: number;
  35770. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  35771. invertV: number;
  35772. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  35773. disposeWhenFinishedAnimating: boolean;
  35774. /** Gets the list of attached animations */
  35775. animations: Animation[];
  35776. /** Gets or sets a boolean indicating if the sprite can be picked */
  35777. isPickable: boolean;
  35778. /**
  35779. * Gets or sets the associated action manager
  35780. */
  35781. actionManager: Nullable<ActionManager>;
  35782. private _animationStarted;
  35783. private _loopAnimation;
  35784. private _fromIndex;
  35785. private _toIndex;
  35786. private _delay;
  35787. private _direction;
  35788. private _manager;
  35789. private _time;
  35790. private _onAnimationEnd;
  35791. /**
  35792. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  35793. */
  35794. isVisible: boolean;
  35795. /**
  35796. * Gets or sets the sprite size
  35797. */
  35798. size: number;
  35799. /**
  35800. * Creates a new Sprite
  35801. * @param name defines the name
  35802. * @param manager defines the manager
  35803. */
  35804. constructor(
  35805. /** defines the name */
  35806. name: string, manager: ISpriteManager);
  35807. /**
  35808. * Starts an animation
  35809. * @param from defines the initial key
  35810. * @param to defines the end key
  35811. * @param loop defines if the animation must loop
  35812. * @param delay defines the start delay (in ms)
  35813. * @param onAnimationEnd defines a callback to call when animation ends
  35814. */
  35815. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  35816. /** Stops current animation (if any) */
  35817. stopAnimation(): void;
  35818. /** @hidden */
  35819. _animate(deltaTime: number): void;
  35820. /** Release associated resources */
  35821. dispose(): void;
  35822. }
  35823. }
  35824. declare module BABYLON {
  35825. /**
  35826. * Defines the minimum interface to fullfil in order to be a sprite manager.
  35827. */
  35828. interface ISpriteManager extends IDisposable {
  35829. /**
  35830. * Restricts the camera to viewing objects with the same layerMask.
  35831. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  35832. */
  35833. layerMask: number;
  35834. /**
  35835. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35836. */
  35837. isPickable: boolean;
  35838. /**
  35839. * Specifies the rendering group id for this mesh (0 by default)
  35840. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35841. */
  35842. renderingGroupId: number;
  35843. /**
  35844. * Defines the list of sprites managed by the manager.
  35845. */
  35846. sprites: Array<Sprite>;
  35847. /**
  35848. * Tests the intersection of a sprite with a specific ray.
  35849. * @param ray The ray we are sending to test the collision
  35850. * @param camera The camera space we are sending rays in
  35851. * @param predicate A predicate allowing excluding sprites from the list of object to test
  35852. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  35853. * @returns picking info or null.
  35854. */
  35855. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35856. /**
  35857. * Renders the list of sprites on screen.
  35858. */
  35859. render(): void;
  35860. }
  35861. /**
  35862. * Class used to manage multiple sprites on the same spritesheet
  35863. * @see http://doc.babylonjs.com/babylon101/sprites
  35864. */
  35865. class SpriteManager implements ISpriteManager {
  35866. /** defines the manager's name */
  35867. name: string;
  35868. /** Gets the list of sprites */
  35869. sprites: Sprite[];
  35870. /** Gets or sets the rendering group id (0 by default) */
  35871. renderingGroupId: number;
  35872. /** Gets or sets camera layer mask */
  35873. layerMask: number;
  35874. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  35875. fogEnabled: boolean;
  35876. /** Gets or sets a boolean indicating if the sprites are pickable */
  35877. isPickable: boolean;
  35878. /** Defines the default width of a cell in the spritesheet */
  35879. cellWidth: number;
  35880. /** Defines the default height of a cell in the spritesheet */
  35881. cellHeight: number;
  35882. /**
  35883. * An event triggered when the manager is disposed.
  35884. */
  35885. onDisposeObservable: Observable<SpriteManager>;
  35886. private _onDisposeObserver;
  35887. /**
  35888. * Callback called when the manager is disposed
  35889. */
  35890. onDispose: () => void;
  35891. private _capacity;
  35892. private _spriteTexture;
  35893. private _epsilon;
  35894. private _scene;
  35895. private _vertexData;
  35896. private _buffer;
  35897. private _vertexBuffers;
  35898. private _indexBuffer;
  35899. private _effectBase;
  35900. private _effectFog;
  35901. /**
  35902. * Gets or sets the spritesheet texture
  35903. */
  35904. texture: Texture;
  35905. /**
  35906. * Creates a new sprite manager
  35907. * @param name defines the manager's name
  35908. * @param imgUrl defines the sprite sheet url
  35909. * @param capacity defines the maximum allowed number of sprites
  35910. * @param cellSize defines the size of a sprite cell
  35911. * @param scene defines the hosting scene
  35912. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  35913. * @param samplingMode defines the smapling mode to use with spritesheet
  35914. */
  35915. constructor(
  35916. /** defines the manager's name */
  35917. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  35918. private _appendSpriteVertex;
  35919. /**
  35920. * Intersects the sprites with a ray
  35921. * @param ray defines the ray to intersect with
  35922. * @param camera defines the current active camera
  35923. * @param predicate defines a predicate used to select candidate sprites
  35924. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  35925. * @returns null if no hit or a PickingInfo
  35926. */
  35927. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35928. /**
  35929. * Render all child sprites
  35930. */
  35931. render(): void;
  35932. /**
  35933. * Release associated resources
  35934. */
  35935. dispose(): void;
  35936. }
  35937. }
  35938. declare module BABYLON {
  35939. interface Scene {
  35940. /** @hidden */
  35941. _pointerOverSprite: Nullable<Sprite>;
  35942. /** @hidden */
  35943. _pickedDownSprite: Nullable<Sprite>;
  35944. /** @hidden */
  35945. _tempSpritePickingRay: Nullable<Ray>;
  35946. /**
  35947. * All of the sprite managers added to this scene
  35948. * @see http://doc.babylonjs.com/babylon101/sprites
  35949. */
  35950. spriteManagers: Array<ISpriteManager>;
  35951. /**
  35952. * An event triggered when sprites rendering is about to start
  35953. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35954. */
  35955. onBeforeSpritesRenderingObservable: Observable<Scene>;
  35956. /**
  35957. * An event triggered when sprites rendering is done
  35958. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35959. */
  35960. onAfterSpritesRenderingObservable: Observable<Scene>;
  35961. /** @hidden */
  35962. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35963. /** Launch a ray to try to pick a sprite in the scene
  35964. * @param x position on screen
  35965. * @param y position on screen
  35966. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  35967. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35968. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35969. * @returns a PickingInfo
  35970. */
  35971. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35972. /** Use the given ray to pick a sprite in the scene
  35973. * @param ray The ray (in world space) to use to pick meshes
  35974. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  35975. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35976. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  35977. * @returns a PickingInfo
  35978. */
  35979. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35980. /**
  35981. * Force the sprite under the pointer
  35982. * @param sprite defines the sprite to use
  35983. */
  35984. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  35985. /**
  35986. * Gets the sprite under the pointer
  35987. * @returns a Sprite or null if no sprite is under the pointer
  35988. */
  35989. getPointerOverSprite(): Nullable<Sprite>;
  35990. }
  35991. /**
  35992. * Defines the sprite scene component responsible to manage sprites
  35993. * in a given scene.
  35994. */
  35995. class SpriteSceneComponent implements ISceneComponent {
  35996. /**
  35997. * The component name helpfull to identify the component in the list of scene components.
  35998. */
  35999. readonly name: string;
  36000. /**
  36001. * The scene the component belongs to.
  36002. */
  36003. scene: Scene;
  36004. /** @hidden */
  36005. private _spritePredicate;
  36006. /**
  36007. * Creates a new instance of the component for the given scene
  36008. * @param scene Defines the scene to register the component in
  36009. */
  36010. constructor(scene: Scene);
  36011. /**
  36012. * Registers the component in a given scene
  36013. */
  36014. register(): void;
  36015. /**
  36016. * Rebuilds the elements related to this component in case of
  36017. * context lost for instance.
  36018. */
  36019. rebuild(): void;
  36020. /**
  36021. * Disposes the component and the associated ressources.
  36022. */
  36023. dispose(): void;
  36024. private _pickSpriteButKeepRay;
  36025. private _pointerMove;
  36026. private _pointerDown;
  36027. private _pointerUp;
  36028. }
  36029. }
  36030. declare module BABYLON {
  36031. /**
  36032. * @hidden
  36033. **/
  36034. class _AlphaState {
  36035. private _isAlphaBlendDirty;
  36036. private _isBlendFunctionParametersDirty;
  36037. private _isBlendEquationParametersDirty;
  36038. private _isBlendConstantsDirty;
  36039. private _alphaBlend;
  36040. private _blendFunctionParameters;
  36041. private _blendEquationParameters;
  36042. private _blendConstants;
  36043. /**
  36044. * Initializes the state.
  36045. */
  36046. constructor();
  36047. readonly isDirty: boolean;
  36048. alphaBlend: boolean;
  36049. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36050. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36051. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36052. reset(): void;
  36053. apply(gl: WebGLRenderingContext): void;
  36054. }
  36055. }
  36056. declare module BABYLON {
  36057. /**
  36058. * @hidden
  36059. **/
  36060. class _DepthCullingState {
  36061. private _isDepthTestDirty;
  36062. private _isDepthMaskDirty;
  36063. private _isDepthFuncDirty;
  36064. private _isCullFaceDirty;
  36065. private _isCullDirty;
  36066. private _isZOffsetDirty;
  36067. private _isFrontFaceDirty;
  36068. private _depthTest;
  36069. private _depthMask;
  36070. private _depthFunc;
  36071. private _cull;
  36072. private _cullFace;
  36073. private _zOffset;
  36074. private _frontFace;
  36075. /**
  36076. * Initializes the state.
  36077. */
  36078. constructor();
  36079. readonly isDirty: boolean;
  36080. zOffset: number;
  36081. cullFace: Nullable<number>;
  36082. cull: Nullable<boolean>;
  36083. depthFunc: Nullable<number>;
  36084. depthMask: boolean;
  36085. depthTest: boolean;
  36086. frontFace: Nullable<number>;
  36087. reset(): void;
  36088. apply(gl: WebGLRenderingContext): void;
  36089. }
  36090. }
  36091. declare module BABYLON {
  36092. /**
  36093. * @hidden
  36094. **/
  36095. class _StencilState {
  36096. private _isStencilTestDirty;
  36097. private _isStencilMaskDirty;
  36098. private _isStencilFuncDirty;
  36099. private _isStencilOpDirty;
  36100. private _stencilTest;
  36101. private _stencilMask;
  36102. private _stencilFunc;
  36103. private _stencilFuncRef;
  36104. private _stencilFuncMask;
  36105. private _stencilOpStencilFail;
  36106. private _stencilOpDepthFail;
  36107. private _stencilOpStencilDepthPass;
  36108. readonly isDirty: boolean;
  36109. stencilFunc: number;
  36110. stencilFuncRef: number;
  36111. stencilFuncMask: number;
  36112. stencilOpStencilFail: number;
  36113. stencilOpDepthFail: number;
  36114. stencilOpStencilDepthPass: number;
  36115. stencilMask: number;
  36116. stencilTest: boolean;
  36117. constructor();
  36118. reset(): void;
  36119. apply(gl: WebGLRenderingContext): void;
  36120. }
  36121. }
  36122. declare module BABYLON {
  36123. /**
  36124. * Class used to evalaute queries containing `and` and `or` operators
  36125. */
  36126. class AndOrNotEvaluator {
  36127. /**
  36128. * Evaluate a query
  36129. * @param query defines the query to evaluate
  36130. * @param evaluateCallback defines the callback used to filter result
  36131. * @returns true if the query matches
  36132. */
  36133. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36134. private static _HandleParenthesisContent;
  36135. private static _SimplifyNegation;
  36136. }
  36137. }
  36138. declare module BABYLON {
  36139. /**
  36140. * Defines the list of states available for a task inside a AssetsManager
  36141. */
  36142. enum AssetTaskState {
  36143. /**
  36144. * Initialization
  36145. */
  36146. INIT = 0,
  36147. /**
  36148. * Running
  36149. */
  36150. RUNNING = 1,
  36151. /**
  36152. * Done
  36153. */
  36154. DONE = 2,
  36155. /**
  36156. * Error
  36157. */
  36158. ERROR = 3
  36159. }
  36160. /**
  36161. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36162. */
  36163. abstract class AbstractAssetTask {
  36164. /**
  36165. * Task name
  36166. */ name: string;
  36167. /**
  36168. * Callback called when the task is successful
  36169. */
  36170. onSuccess: (task: any) => void;
  36171. /**
  36172. * Callback called when the task is not successful
  36173. */
  36174. onError: (task: any, message?: string, exception?: any) => void;
  36175. /**
  36176. * Creates a new AssetsManager
  36177. * @param name defines the name of the task
  36178. */
  36179. constructor(
  36180. /**
  36181. * Task name
  36182. */ name: string);
  36183. private _isCompleted;
  36184. private _taskState;
  36185. private _errorObject;
  36186. /**
  36187. * Get if the task is completed
  36188. */
  36189. readonly isCompleted: boolean;
  36190. /**
  36191. * Gets the current state of the task
  36192. */
  36193. readonly taskState: AssetTaskState;
  36194. /**
  36195. * Gets the current error object (if task is in error)
  36196. */
  36197. readonly errorObject: {
  36198. message?: string;
  36199. exception?: any;
  36200. };
  36201. /**
  36202. * Internal only
  36203. * @hidden
  36204. */
  36205. _setErrorObject(message?: string, exception?: any): void;
  36206. /**
  36207. * Execute the current task
  36208. * @param scene defines the scene where you want your assets to be loaded
  36209. * @param onSuccess is a callback called when the task is successfully executed
  36210. * @param onError is a callback called if an error occurs
  36211. */
  36212. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36213. /**
  36214. * Execute the current task
  36215. * @param scene defines the scene where you want your assets to be loaded
  36216. * @param onSuccess is a callback called when the task is successfully executed
  36217. * @param onError is a callback called if an error occurs
  36218. */
  36219. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36220. /**
  36221. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36222. * This can be used with failed tasks that have the reason for failure fixed.
  36223. */
  36224. reset(): void;
  36225. private onErrorCallback;
  36226. private onDoneCallback;
  36227. }
  36228. /**
  36229. * Define the interface used by progress events raised during assets loading
  36230. */
  36231. interface IAssetsProgressEvent {
  36232. /**
  36233. * Defines the number of remaining tasks to process
  36234. */
  36235. remainingCount: number;
  36236. /**
  36237. * Defines the total number of tasks
  36238. */
  36239. totalCount: number;
  36240. /**
  36241. * Defines the task that was just processed
  36242. */
  36243. task: AbstractAssetTask;
  36244. }
  36245. /**
  36246. * Class used to share progress information about assets loading
  36247. */
  36248. class AssetsProgressEvent implements IAssetsProgressEvent {
  36249. /**
  36250. * Defines the number of remaining tasks to process
  36251. */
  36252. remainingCount: number;
  36253. /**
  36254. * Defines the total number of tasks
  36255. */
  36256. totalCount: number;
  36257. /**
  36258. * Defines the task that was just processed
  36259. */
  36260. task: AbstractAssetTask;
  36261. /**
  36262. * Creates a AssetsProgressEvent
  36263. * @param remainingCount defines the number of remaining tasks to process
  36264. * @param totalCount defines the total number of tasks
  36265. * @param task defines the task that was just processed
  36266. */
  36267. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36268. }
  36269. /**
  36270. * Define a task used by AssetsManager to load meshes
  36271. */
  36272. class MeshAssetTask extends AbstractAssetTask {
  36273. /**
  36274. * Defines the name of the task
  36275. */
  36276. name: string;
  36277. /**
  36278. * Defines the list of mesh's names you want to load
  36279. */
  36280. meshesNames: any;
  36281. /**
  36282. * Defines the root url to use as a base to load your meshes and associated resources
  36283. */
  36284. rootUrl: string;
  36285. /**
  36286. * Defines the filename of the scene to load from
  36287. */
  36288. sceneFilename: string;
  36289. /**
  36290. * Gets the list of loaded meshes
  36291. */
  36292. loadedMeshes: Array<AbstractMesh>;
  36293. /**
  36294. * Gets the list of loaded particle systems
  36295. */
  36296. loadedParticleSystems: Array<IParticleSystem>;
  36297. /**
  36298. * Gets the list of loaded skeletons
  36299. */
  36300. loadedSkeletons: Array<Skeleton>;
  36301. /**
  36302. * Callback called when the task is successful
  36303. */
  36304. onSuccess: (task: MeshAssetTask) => void;
  36305. /**
  36306. * Callback called when the task is successful
  36307. */
  36308. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36309. /**
  36310. * Creates a new MeshAssetTask
  36311. * @param name defines the name of the task
  36312. * @param meshesNames defines the list of mesh's names you want to load
  36313. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36314. * @param sceneFilename defines the filename of the scene to load from
  36315. */
  36316. constructor(
  36317. /**
  36318. * Defines the name of the task
  36319. */
  36320. name: string,
  36321. /**
  36322. * Defines the list of mesh's names you want to load
  36323. */
  36324. meshesNames: any,
  36325. /**
  36326. * Defines the root url to use as a base to load your meshes and associated resources
  36327. */
  36328. rootUrl: string,
  36329. /**
  36330. * Defines the filename of the scene to load from
  36331. */
  36332. sceneFilename: string);
  36333. /**
  36334. * Execute the current task
  36335. * @param scene defines the scene where you want your assets to be loaded
  36336. * @param onSuccess is a callback called when the task is successfully executed
  36337. * @param onError is a callback called if an error occurs
  36338. */
  36339. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36340. }
  36341. /**
  36342. * Define a task used by AssetsManager to load text content
  36343. */
  36344. class TextFileAssetTask extends AbstractAssetTask {
  36345. /**
  36346. * Defines the name of the task
  36347. */
  36348. name: string;
  36349. /**
  36350. * Defines the location of the file to load
  36351. */
  36352. url: string;
  36353. /**
  36354. * Gets the loaded text string
  36355. */
  36356. text: string;
  36357. /**
  36358. * Callback called when the task is successful
  36359. */
  36360. onSuccess: (task: TextFileAssetTask) => void;
  36361. /**
  36362. * Callback called when the task is successful
  36363. */
  36364. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  36365. /**
  36366. * Creates a new TextFileAssetTask object
  36367. * @param name defines the name of the task
  36368. * @param url defines the location of the file to load
  36369. */
  36370. constructor(
  36371. /**
  36372. * Defines the name of the task
  36373. */
  36374. name: string,
  36375. /**
  36376. * Defines the location of the file to load
  36377. */
  36378. url: string);
  36379. /**
  36380. * Execute the current task
  36381. * @param scene defines the scene where you want your assets to be loaded
  36382. * @param onSuccess is a callback called when the task is successfully executed
  36383. * @param onError is a callback called if an error occurs
  36384. */
  36385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36386. }
  36387. /**
  36388. * Define a task used by AssetsManager to load binary data
  36389. */
  36390. class BinaryFileAssetTask extends AbstractAssetTask {
  36391. /**
  36392. * Defines the name of the task
  36393. */
  36394. name: string;
  36395. /**
  36396. * Defines the location of the file to load
  36397. */
  36398. url: string;
  36399. /**
  36400. * Gets the lodaded data (as an array buffer)
  36401. */
  36402. data: ArrayBuffer;
  36403. /**
  36404. * Callback called when the task is successful
  36405. */
  36406. onSuccess: (task: BinaryFileAssetTask) => void;
  36407. /**
  36408. * Callback called when the task is successful
  36409. */
  36410. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  36411. /**
  36412. * Creates a new BinaryFileAssetTask object
  36413. * @param name defines the name of the new task
  36414. * @param url defines the location of the file to load
  36415. */
  36416. constructor(
  36417. /**
  36418. * Defines the name of the task
  36419. */
  36420. name: string,
  36421. /**
  36422. * Defines the location of the file to load
  36423. */
  36424. url: string);
  36425. /**
  36426. * Execute the current task
  36427. * @param scene defines the scene where you want your assets to be loaded
  36428. * @param onSuccess is a callback called when the task is successfully executed
  36429. * @param onError is a callback called if an error occurs
  36430. */
  36431. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36432. }
  36433. /**
  36434. * Define a task used by AssetsManager to load images
  36435. */
  36436. class ImageAssetTask extends AbstractAssetTask {
  36437. /**
  36438. * Defines the name of the task
  36439. */
  36440. name: string;
  36441. /**
  36442. * Defines the location of the image to load
  36443. */
  36444. url: string;
  36445. /**
  36446. * Gets the loaded images
  36447. */
  36448. image: HTMLImageElement;
  36449. /**
  36450. * Callback called when the task is successful
  36451. */
  36452. onSuccess: (task: ImageAssetTask) => void;
  36453. /**
  36454. * Callback called when the task is successful
  36455. */
  36456. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  36457. /**
  36458. * Creates a new ImageAssetTask
  36459. * @param name defines the name of the task
  36460. * @param url defines the location of the image to load
  36461. */
  36462. constructor(
  36463. /**
  36464. * Defines the name of the task
  36465. */
  36466. name: string,
  36467. /**
  36468. * Defines the location of the image to load
  36469. */
  36470. url: string);
  36471. /**
  36472. * Execute the current task
  36473. * @param scene defines the scene where you want your assets to be loaded
  36474. * @param onSuccess is a callback called when the task is successfully executed
  36475. * @param onError is a callback called if an error occurs
  36476. */
  36477. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36478. }
  36479. /**
  36480. * Defines the interface used by texture loading tasks
  36481. */
  36482. interface ITextureAssetTask<TEX extends BaseTexture> {
  36483. /**
  36484. * Gets the loaded texture
  36485. */
  36486. texture: TEX;
  36487. }
  36488. /**
  36489. * Define a task used by AssetsManager to load 2D textures
  36490. */
  36491. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  36492. /**
  36493. * Defines the name of the task
  36494. */
  36495. name: string;
  36496. /**
  36497. * Defines the location of the file to load
  36498. */
  36499. url: string;
  36500. /**
  36501. * Defines if mipmap should not be generated (default is false)
  36502. */
  36503. noMipmap?: boolean | undefined;
  36504. /**
  36505. * Defines if texture must be inverted on Y axis (default is false)
  36506. */
  36507. invertY?: boolean | undefined;
  36508. /**
  36509. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36510. */
  36511. samplingMode: number;
  36512. /**
  36513. * Gets the loaded texture
  36514. */
  36515. texture: Texture;
  36516. /**
  36517. * Callback called when the task is successful
  36518. */
  36519. onSuccess: (task: TextureAssetTask) => void;
  36520. /**
  36521. * Callback called when the task is successful
  36522. */
  36523. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  36524. /**
  36525. * Creates a new TextureAssetTask object
  36526. * @param name defines the name of the task
  36527. * @param url defines the location of the file to load
  36528. * @param noMipmap defines if mipmap should not be generated (default is false)
  36529. * @param invertY defines if texture must be inverted on Y axis (default is false)
  36530. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36531. */
  36532. constructor(
  36533. /**
  36534. * Defines the name of the task
  36535. */
  36536. name: string,
  36537. /**
  36538. * Defines the location of the file to load
  36539. */
  36540. url: string,
  36541. /**
  36542. * Defines if mipmap should not be generated (default is false)
  36543. */
  36544. noMipmap?: boolean | undefined,
  36545. /**
  36546. * Defines if texture must be inverted on Y axis (default is false)
  36547. */
  36548. invertY?: boolean | undefined,
  36549. /**
  36550. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36551. */
  36552. samplingMode?: number);
  36553. /**
  36554. * Execute the current task
  36555. * @param scene defines the scene where you want your assets to be loaded
  36556. * @param onSuccess is a callback called when the task is successfully executed
  36557. * @param onError is a callback called if an error occurs
  36558. */
  36559. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36560. }
  36561. /**
  36562. * Define a task used by AssetsManager to load cube textures
  36563. */
  36564. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  36565. /**
  36566. * Defines the name of the task
  36567. */
  36568. name: string;
  36569. /**
  36570. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36571. */
  36572. url: string;
  36573. /**
  36574. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36575. */
  36576. extensions?: string[] | undefined;
  36577. /**
  36578. * Defines if mipmaps should not be generated (default is false)
  36579. */
  36580. noMipmap?: boolean | undefined;
  36581. /**
  36582. * Defines the explicit list of files (undefined by default)
  36583. */
  36584. files?: string[] | undefined;
  36585. /**
  36586. * Gets the loaded texture
  36587. */
  36588. texture: CubeTexture;
  36589. /**
  36590. * Callback called when the task is successful
  36591. */
  36592. onSuccess: (task: CubeTextureAssetTask) => void;
  36593. /**
  36594. * Callback called when the task is successful
  36595. */
  36596. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  36597. /**
  36598. * Creates a new CubeTextureAssetTask
  36599. * @param name defines the name of the task
  36600. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36601. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36602. * @param noMipmap defines if mipmaps should not be generated (default is false)
  36603. * @param files defines the explicit list of files (undefined by default)
  36604. */
  36605. constructor(
  36606. /**
  36607. * Defines the name of the task
  36608. */
  36609. name: string,
  36610. /**
  36611. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  36612. */
  36613. url: string,
  36614. /**
  36615. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  36616. */
  36617. extensions?: string[] | undefined,
  36618. /**
  36619. * Defines if mipmaps should not be generated (default is false)
  36620. */
  36621. noMipmap?: boolean | undefined,
  36622. /**
  36623. * Defines the explicit list of files (undefined by default)
  36624. */
  36625. files?: string[] | undefined);
  36626. /**
  36627. * Execute the current task
  36628. * @param scene defines the scene where you want your assets to be loaded
  36629. * @param onSuccess is a callback called when the task is successfully executed
  36630. * @param onError is a callback called if an error occurs
  36631. */
  36632. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36633. }
  36634. /**
  36635. * Define a task used by AssetsManager to load HDR cube textures
  36636. */
  36637. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  36638. /**
  36639. * Defines the name of the task
  36640. */
  36641. name: string;
  36642. /**
  36643. * Defines the location of the file to load
  36644. */
  36645. url: string;
  36646. /**
  36647. * Defines the desired size (the more it increases the longer the generation will be)
  36648. */
  36649. size: number;
  36650. /**
  36651. * Defines if mipmaps should not be generated (default is false)
  36652. */
  36653. noMipmap: boolean;
  36654. /**
  36655. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36656. */
  36657. generateHarmonics: boolean;
  36658. /**
  36659. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  36660. */
  36661. gammaSpace: boolean;
  36662. /**
  36663. * Internal Use Only
  36664. */
  36665. reserved: boolean;
  36666. /**
  36667. * Gets the loaded texture
  36668. */
  36669. texture: HDRCubeTexture;
  36670. /**
  36671. * Callback called when the task is successful
  36672. */
  36673. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  36674. /**
  36675. * Callback called when the task is successful
  36676. */
  36677. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  36678. /**
  36679. * Creates a new HDRCubeTextureAssetTask object
  36680. * @param name defines the name of the task
  36681. * @param url defines the location of the file to load
  36682. * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  36683. * @param noMipmap defines if mipmaps should not be generated (default is false)
  36684. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36685. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  36686. * @param reserved Internal use only
  36687. */
  36688. constructor(
  36689. /**
  36690. * Defines the name of the task
  36691. */
  36692. name: string,
  36693. /**
  36694. * Defines the location of the file to load
  36695. */
  36696. url: string,
  36697. /**
  36698. * Defines the desired size (the more it increases the longer the generation will be)
  36699. */
  36700. size: number,
  36701. /**
  36702. * Defines if mipmaps should not be generated (default is false)
  36703. */
  36704. noMipmap?: boolean,
  36705. /**
  36706. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  36707. */
  36708. generateHarmonics?: boolean,
  36709. /**
  36710. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  36711. */
  36712. gammaSpace?: boolean,
  36713. /**
  36714. * Internal Use Only
  36715. */
  36716. reserved?: boolean);
  36717. /**
  36718. * Execute the current task
  36719. * @param scene defines the scene where you want your assets to be loaded
  36720. * @param onSuccess is a callback called when the task is successfully executed
  36721. * @param onError is a callback called if an error occurs
  36722. */
  36723. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36724. }
  36725. /**
  36726. * This class can be used to easily import assets into a scene
  36727. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  36728. */
  36729. class AssetsManager {
  36730. private _scene;
  36731. private _isLoading;
  36732. protected _tasks: AbstractAssetTask[];
  36733. protected _waitingTasksCount: number;
  36734. protected _totalTasksCount: number;
  36735. /**
  36736. * Callback called when all tasks are processed
  36737. */
  36738. onFinish: (tasks: AbstractAssetTask[]) => void;
  36739. /**
  36740. * Callback called when a task is successful
  36741. */
  36742. onTaskSuccess: (task: AbstractAssetTask) => void;
  36743. /**
  36744. * Callback called when a task had an error
  36745. */
  36746. onTaskError: (task: AbstractAssetTask) => void;
  36747. /**
  36748. * Callback called when a task is done (whatever the result is)
  36749. */
  36750. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  36751. /**
  36752. * Observable called when all tasks are processed
  36753. */
  36754. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  36755. /**
  36756. * Observable called when a task had an error
  36757. */
  36758. onTaskErrorObservable: Observable<AbstractAssetTask>;
  36759. /**
  36760. * Observable called when a task is successful
  36761. */
  36762. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  36763. /**
  36764. * Observable called when a task is done (whatever the result is)
  36765. */
  36766. onProgressObservable: Observable<IAssetsProgressEvent>;
  36767. /**
  36768. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  36769. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36770. */
  36771. useDefaultLoadingScreen: boolean;
  36772. /**
  36773. * Creates a new AssetsManager
  36774. * @param scene defines the scene to work on
  36775. */
  36776. constructor(scene: Scene);
  36777. /**
  36778. * Add a MeshAssetTask to the list of active tasks
  36779. * @param taskName defines the name of the new task
  36780. * @param meshesNames defines the name of meshes to load
  36781. * @param rootUrl defines the root url to use to locate files
  36782. * @param sceneFilename defines the filename of the scene file
  36783. * @returns a new MeshAssetTask object
  36784. */
  36785. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  36786. /**
  36787. * Add a TextFileAssetTask to the list of active tasks
  36788. * @param taskName defines the name of the new task
  36789. * @param url defines the url of the file to load
  36790. * @returns a new TextFileAssetTask object
  36791. */
  36792. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  36793. /**
  36794. * Add a BinaryFileAssetTask to the list of active tasks
  36795. * @param taskName defines the name of the new task
  36796. * @param url defines the url of the file to load
  36797. * @returns a new BinaryFileAssetTask object
  36798. */
  36799. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  36800. /**
  36801. * Add a ImageAssetTask to the list of active tasks
  36802. * @param taskName defines the name of the new task
  36803. * @param url defines the url of the file to load
  36804. * @returns a new ImageAssetTask object
  36805. */
  36806. addImageTask(taskName: string, url: string): ImageAssetTask;
  36807. /**
  36808. * Add a TextureAssetTask to the list of active tasks
  36809. * @param taskName defines the name of the new task
  36810. * @param url defines the url of the file to load
  36811. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36812. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  36813. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  36814. * @returns a new TextureAssetTask object
  36815. */
  36816. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  36817. /**
  36818. * Add a CubeTextureAssetTask to the list of active tasks
  36819. * @param taskName defines the name of the new task
  36820. * @param url defines the url of the file to load
  36821. * @param extensions defines the extension to use to load the cube map (can be null)
  36822. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36823. * @param files defines the list of files to load (can be null)
  36824. * @returns a new CubeTextureAssetTask object
  36825. */
  36826. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  36827. /**
  36828. *
  36829. * Add a HDRCubeTextureAssetTask to the list of active tasks
  36830. * @param taskName defines the name of the new task
  36831. * @param url defines the url of the file to load
  36832. * @param size defines the size you want for the cubemap (can be null)
  36833. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  36834. * @param generateHarmonics defines if you want to automatically generate (true by default)
  36835. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  36836. * @param reserved Internal use only
  36837. * @returns a new HDRCubeTextureAssetTask object
  36838. */
  36839. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  36840. /**
  36841. * Remove a task from the assets manager.
  36842. * @param task the task to remove
  36843. */
  36844. removeTask(task: AbstractAssetTask): void;
  36845. private _decreaseWaitingTasksCount;
  36846. private _runTask;
  36847. /**
  36848. * Reset the AssetsManager and remove all tasks
  36849. * @return the current instance of the AssetsManager
  36850. */
  36851. reset(): AssetsManager;
  36852. /**
  36853. * Start the loading process
  36854. * @return the current instance of the AssetsManager
  36855. */
  36856. load(): AssetsManager;
  36857. }
  36858. }
  36859. declare module BABYLON {
  36860. /**
  36861. * Class used to enable access to IndexedDB
  36862. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  36863. */
  36864. class Database {
  36865. private callbackManifestChecked;
  36866. private currentSceneUrl;
  36867. private db;
  36868. private _enableSceneOffline;
  36869. private _enableTexturesOffline;
  36870. private manifestVersionFound;
  36871. private mustUpdateRessources;
  36872. private hasReachedQuota;
  36873. private isSupported;
  36874. private idbFactory;
  36875. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  36876. static IsUASupportingBlobStorage: boolean;
  36877. /** Gets a boolean indicating if Database storate is enabled */
  36878. static IDBStorageEnabled: boolean;
  36879. /**
  36880. * Gets a boolean indicating if scene must be saved in the database
  36881. */
  36882. readonly enableSceneOffline: boolean;
  36883. /**
  36884. * Gets a boolean indicating if textures must be saved in the database
  36885. */
  36886. readonly enableTexturesOffline: boolean;
  36887. /**
  36888. * Creates a new Database
  36889. * @param urlToScene defines the url to load the scene
  36890. * @param callbackManifestChecked defines the callback to use when manifest is checked
  36891. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  36892. */
  36893. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  36894. private static _ParseURL;
  36895. private static _ReturnFullUrlLocation;
  36896. private _checkManifestFile;
  36897. /**
  36898. * Open the database and make it available
  36899. * @param successCallback defines the callback to call on success
  36900. * @param errorCallback defines the callback to call on error
  36901. */
  36902. openAsync(successCallback: () => void, errorCallback: () => void): void;
  36903. /**
  36904. * Loads an image from the database
  36905. * @param url defines the url to load from
  36906. * @param image defines the target DOM image
  36907. */
  36908. loadImageFromDB(url: string, image: HTMLImageElement): void;
  36909. private _loadImageFromDBAsync;
  36910. private _saveImageIntoDBAsync;
  36911. private _checkVersionFromDB;
  36912. private _loadVersionFromDBAsync;
  36913. private _saveVersionIntoDBAsync;
  36914. /**
  36915. * Loads a file from database
  36916. * @param url defines the URL to load from
  36917. * @param sceneLoaded defines a callback to call on success
  36918. * @param progressCallBack defines a callback to call when progress changed
  36919. * @param errorCallback defines a callback to call on error
  36920. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  36921. */
  36922. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  36923. private _loadFileFromDBAsync;
  36924. private _saveFileIntoDBAsync;
  36925. }
  36926. }
  36927. declare module BABYLON {
  36928. /**
  36929. * Direct draw surface info
  36930. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  36931. */
  36932. interface DDSInfo {
  36933. /**
  36934. * Width of the texture
  36935. */
  36936. width: number;
  36937. /**
  36938. * Width of the texture
  36939. */
  36940. height: number;
  36941. /**
  36942. * Number of Mipmaps for the texture
  36943. * @see https://en.wikipedia.org/wiki/Mipmap
  36944. */
  36945. mipmapCount: number;
  36946. /**
  36947. * If the textures format is a known fourCC format
  36948. * @see https://www.fourcc.org/
  36949. */
  36950. isFourCC: boolean;
  36951. /**
  36952. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  36953. */
  36954. isRGB: boolean;
  36955. /**
  36956. * If the texture is a lumincance format
  36957. */
  36958. isLuminance: boolean;
  36959. /**
  36960. * If this is a cube texture
  36961. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  36962. */
  36963. isCube: boolean;
  36964. /**
  36965. * If the texture is a compressed format eg. FOURCC_DXT1
  36966. */
  36967. isCompressed: boolean;
  36968. /**
  36969. * The dxgiFormat of the texture
  36970. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  36971. */
  36972. dxgiFormat: number;
  36973. /**
  36974. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  36975. */
  36976. textureType: number;
  36977. /**
  36978. * Sphericle polynomial created for the dds texture
  36979. */
  36980. sphericalPolynomial?: SphericalPolynomial;
  36981. }
  36982. /**
  36983. * Class used to provide DDS decompression tools
  36984. */
  36985. class DDSTools {
  36986. /**
  36987. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  36988. */
  36989. static StoreLODInAlphaChannel: boolean;
  36990. /**
  36991. * Gets DDS information from an array buffer
  36992. * @param arrayBuffer defines the array buffer to read data from
  36993. * @returns the DDS information
  36994. */
  36995. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  36996. private static _FloatView;
  36997. private static _Int32View;
  36998. private static _ToHalfFloat;
  36999. private static _FromHalfFloat;
  37000. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37001. private static _GetHalfFloatRGBAArrayBuffer;
  37002. private static _GetFloatRGBAArrayBuffer;
  37003. private static _GetFloatAsUIntRGBAArrayBuffer;
  37004. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37005. private static _GetRGBAArrayBuffer;
  37006. private static _ExtractLongWordOrder;
  37007. private static _GetRGBArrayBuffer;
  37008. private static _GetLuminanceArrayBuffer;
  37009. /**
  37010. * Uploads DDS Levels to a Babylon Texture
  37011. * @hidden
  37012. */
  37013. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37014. }
  37015. }
  37016. declare module BABYLON {
  37017. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37018. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37019. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37020. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37021. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37022. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37023. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37024. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37025. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37026. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37027. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37028. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37029. /**
  37030. * Decorator used to define property that can be serialized as reference to a camera
  37031. * @param sourceName defines the name of the property to decorate
  37032. */
  37033. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37034. /**
  37035. * Class used to help serialization objects
  37036. */
  37037. class SerializationHelper {
  37038. /**
  37039. * Static function used to serialized a specific entity
  37040. * @param entity defines the entity to serialize
  37041. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37042. * @returns a JSON compatible object representing the serialization of the entity
  37043. */
  37044. static Serialize<T>(entity: T, serializationObject?: any): any;
  37045. /**
  37046. * Creates a new entity from a serialization data object
  37047. * @param creationFunction defines a function used to instanciated the new entity
  37048. * @param source defines the source serialization data
  37049. * @param scene defines the hosting scene
  37050. * @param rootUrl defines the root url for resources
  37051. * @returns a new entity
  37052. */
  37053. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37054. /**
  37055. * Clones an object
  37056. * @param creationFunction defines the function used to instanciate the new object
  37057. * @param source defines the source object
  37058. * @returns the cloned object
  37059. */
  37060. static Clone<T>(creationFunction: () => T, source: T): T;
  37061. /**
  37062. * Instanciates a new object based on a source one (some data will be shared between both object)
  37063. * @param creationFunction defines the function used to instanciate the new object
  37064. * @param source defines the source object
  37065. * @returns the new object
  37066. */
  37067. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37068. }
  37069. }
  37070. declare module BABYLON {
  37071. /**
  37072. * Wrapper class for promise with external resolve and reject.
  37073. */
  37074. class Deferred<T> {
  37075. /**
  37076. * The promise associated with this deferred object.
  37077. */
  37078. readonly promise: Promise<T>;
  37079. private _resolve;
  37080. private _reject;
  37081. /**
  37082. * The resolve method of the promise associated with this deferred object.
  37083. */
  37084. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37085. /**
  37086. * The reject method of the promise associated with this deferred object.
  37087. */
  37088. readonly reject: (reason?: any) => void;
  37089. /**
  37090. * Constructor for this deferred object.
  37091. */
  37092. constructor();
  37093. }
  37094. }
  37095. declare module BABYLON {
  37096. /**
  37097. * Raw texture data and descriptor sufficient for WebGL texture upload
  37098. */
  37099. interface EnvironmentTextureInfo {
  37100. /**
  37101. * Version of the environment map
  37102. */
  37103. version: number;
  37104. /**
  37105. * Width of image
  37106. */
  37107. width: number;
  37108. /**
  37109. * Irradiance information stored in the file.
  37110. */
  37111. irradiance: any;
  37112. /**
  37113. * Specular information stored in the file.
  37114. */
  37115. specular: any;
  37116. }
  37117. /**
  37118. * Sets of helpers addressing the serialization and deserialization of environment texture
  37119. * stored in a BabylonJS env file.
  37120. * Those files are usually stored as .env files.
  37121. */
  37122. class EnvironmentTextureTools {
  37123. /**
  37124. * Magic number identifying the env file.
  37125. */
  37126. private static _MagicBytes;
  37127. /**
  37128. * Gets the environment info from an env file.
  37129. * @param data The array buffer containing the .env bytes.
  37130. * @returns the environment file info (the json header) if successfully parsed.
  37131. */
  37132. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37133. /**
  37134. * Creates an environment texture from a loaded cube texture.
  37135. * @param texture defines the cube texture to convert in env file
  37136. * @return a promise containing the environment data if succesfull.
  37137. */
  37138. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37139. /**
  37140. * Creates a JSON representation of the spherical data.
  37141. * @param texture defines the texture containing the polynomials
  37142. * @return the JSON representation of the spherical info
  37143. */
  37144. private static _CreateEnvTextureIrradiance;
  37145. /**
  37146. * Uploads the texture info contained in the env file to the GPU.
  37147. * @param texture defines the internal texture to upload to
  37148. * @param arrayBuffer defines the buffer cotaining the data to load
  37149. * @param info defines the texture info retrieved through the GetEnvInfo method
  37150. * @returns a promise
  37151. */
  37152. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37153. /**
  37154. * Uploads the levels of image data to the GPU.
  37155. * @param texture defines the internal texture to upload to
  37156. * @param imageData defines the array buffer views of image data [mipmap][face]
  37157. * @returns a promise
  37158. */
  37159. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37160. /**
  37161. * Uploads spherical polynomials information to the texture.
  37162. * @param texture defines the texture we are trying to upload the information to
  37163. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37164. */
  37165. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37166. }
  37167. }
  37168. declare module BABYLON {
  37169. /**
  37170. * Class used to help managing file picking and drag'n'drop
  37171. */
  37172. class FilesInput {
  37173. /**
  37174. * List of files ready to be loaded
  37175. */
  37176. static FilesToLoad: {
  37177. [key: string]: File;
  37178. };
  37179. /**
  37180. * Callback called when a file is processed
  37181. */
  37182. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37183. private _engine;
  37184. private _currentScene;
  37185. private _sceneLoadedCallback;
  37186. private _progressCallback;
  37187. private _additionalRenderLoopLogicCallback;
  37188. private _textureLoadingCallback;
  37189. private _startingProcessingFilesCallback;
  37190. private _onReloadCallback;
  37191. private _errorCallback;
  37192. private _elementToMonitor;
  37193. private _sceneFileToLoad;
  37194. private _filesToLoad;
  37195. /**
  37196. * Creates a new FilesInput
  37197. * @param engine defines the rendering engine
  37198. * @param scene defines the hosting scene
  37199. * @param sceneLoadedCallback callback called when scene is loaded
  37200. * @param progressCallback callback called to track progress
  37201. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37202. * @param textureLoadingCallback callback called when a texture is loading
  37203. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37204. * @param onReloadCallback callback called when a reload is requested
  37205. * @param errorCallback callback call if an error occurs
  37206. */
  37207. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  37208. private _dragEnterHandler;
  37209. private _dragOverHandler;
  37210. private _dropHandler;
  37211. /**
  37212. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37213. * @param elementToMonitor defines the DOM element to track
  37214. */
  37215. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37216. /**
  37217. * Release all associated resources
  37218. */
  37219. dispose(): void;
  37220. private renderFunction;
  37221. private drag;
  37222. private drop;
  37223. private _traverseFolder;
  37224. private _processFiles;
  37225. /**
  37226. * Load files from a drop event
  37227. * @param event defines the drop event to use as source
  37228. */
  37229. loadFiles(event: any): void;
  37230. private _processReload;
  37231. /**
  37232. * Reload the current scene from the loaded files
  37233. */
  37234. reload(): void;
  37235. }
  37236. }
  37237. declare module BABYLON {
  37238. /**
  37239. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37240. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37241. */
  37242. class KhronosTextureContainer {
  37243. /** contents of the KTX container file */
  37244. arrayBuffer: any;
  37245. private static HEADER_LEN;
  37246. private static COMPRESSED_2D;
  37247. private static COMPRESSED_3D;
  37248. private static TEX_2D;
  37249. private static TEX_3D;
  37250. /**
  37251. * Gets the openGL type
  37252. */
  37253. glType: number;
  37254. /**
  37255. * Gets the openGL type size
  37256. */
  37257. glTypeSize: number;
  37258. /**
  37259. * Gets the openGL format
  37260. */
  37261. glFormat: number;
  37262. /**
  37263. * Gets the openGL internal format
  37264. */
  37265. glInternalFormat: number;
  37266. /**
  37267. * Gets the base internal format
  37268. */
  37269. glBaseInternalFormat: number;
  37270. /**
  37271. * Gets image width in pixel
  37272. */
  37273. pixelWidth: number;
  37274. /**
  37275. * Gets image height in pixel
  37276. */
  37277. pixelHeight: number;
  37278. /**
  37279. * Gets image depth in pixels
  37280. */
  37281. pixelDepth: number;
  37282. /**
  37283. * Gets the number of array elements
  37284. */
  37285. numberOfArrayElements: number;
  37286. /**
  37287. * Gets the number of faces
  37288. */
  37289. numberOfFaces: number;
  37290. /**
  37291. * Gets the number of mipmap levels
  37292. */
  37293. numberOfMipmapLevels: number;
  37294. /**
  37295. * Gets the bytes of key value data
  37296. */
  37297. bytesOfKeyValueData: number;
  37298. /**
  37299. * Gets the load type
  37300. */
  37301. loadType: number;
  37302. /**
  37303. * Creates a new KhronosTextureContainer
  37304. * @param arrayBuffer contents of the KTX container file
  37305. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37306. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37307. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37308. */
  37309. constructor(
  37310. /** contents of the KTX container file */
  37311. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37312. /**
  37313. * Revert the endianness of a value.
  37314. * Not as fast hardware based, but will probably never need to use
  37315. * @param val defines the value to convert
  37316. * @returns the new value
  37317. */
  37318. switchEndianness(val: number): number;
  37319. /**
  37320. * Uploads KTX content to a Babylon Texture.
  37321. * It is assumed that the texture has already been created & is currently bound
  37322. * @hidden
  37323. */
  37324. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37325. private _upload2DCompressedLevels;
  37326. }
  37327. }
  37328. declare module BABYLON {
  37329. /**
  37330. * A class serves as a medium between the observable and its observers
  37331. */
  37332. class EventState {
  37333. /**
  37334. * Create a new EventState
  37335. * @param mask defines the mask associated with this state
  37336. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37337. * @param target defines the original target of the state
  37338. * @param currentTarget defines the current target of the state
  37339. */
  37340. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37341. /**
  37342. * Initialize the current event state
  37343. * @param mask defines the mask associated with this state
  37344. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37345. * @param target defines the original target of the state
  37346. * @param currentTarget defines the current target of the state
  37347. * @returns the current event state
  37348. */
  37349. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37350. /**
  37351. * An Observer can set this property to true to prevent subsequent observers of being notified
  37352. */
  37353. skipNextObservers: boolean;
  37354. /**
  37355. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37356. */
  37357. mask: number;
  37358. /**
  37359. * The object that originally notified the event
  37360. */
  37361. target?: any;
  37362. /**
  37363. * The current object in the bubbling phase
  37364. */
  37365. currentTarget?: any;
  37366. /**
  37367. * This will be populated with the return value of the last function that was executed.
  37368. * If it is the first function in the callback chain it will be the event data.
  37369. */
  37370. lastReturnValue?: any;
  37371. }
  37372. /**
  37373. * Represent an Observer registered to a given Observable object.
  37374. */
  37375. class Observer<T> {
  37376. /**
  37377. * Defines the callback to call when the observer is notified
  37378. */
  37379. callback: (eventData: T, eventState: EventState) => void;
  37380. /**
  37381. * Defines the mask of the observer (used to filter notifications)
  37382. */
  37383. mask: number;
  37384. /**
  37385. * Defines the current scope used to restore the JS context
  37386. */
  37387. scope: any;
  37388. /** @hidden */
  37389. _willBeUnregistered: boolean;
  37390. /**
  37391. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  37392. */
  37393. unregisterOnNextCall: boolean;
  37394. /**
  37395. * Creates a new observer
  37396. * @param callback defines the callback to call when the observer is notified
  37397. * @param mask defines the mask of the observer (used to filter notifications)
  37398. * @param scope defines the current scope used to restore the JS context
  37399. */
  37400. constructor(
  37401. /**
  37402. * Defines the callback to call when the observer is notified
  37403. */
  37404. callback: (eventData: T, eventState: EventState) => void,
  37405. /**
  37406. * Defines the mask of the observer (used to filter notifications)
  37407. */
  37408. mask: number,
  37409. /**
  37410. * Defines the current scope used to restore the JS context
  37411. */
  37412. scope?: any);
  37413. }
  37414. /**
  37415. * Represent a list of observers registered to multiple Observables object.
  37416. */
  37417. class MultiObserver<T> {
  37418. private _observers;
  37419. private _observables;
  37420. /**
  37421. * Release associated resources
  37422. */
  37423. dispose(): void;
  37424. /**
  37425. * Raise a callback when one of the observable will notify
  37426. * @param observables defines a list of observables to watch
  37427. * @param callback defines the callback to call on notification
  37428. * @param mask defines the mask used to filter notifications
  37429. * @param scope defines the current scope used to restore the JS context
  37430. * @returns the new MultiObserver
  37431. */
  37432. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  37433. }
  37434. /**
  37435. * The Observable class is a simple implementation of the Observable pattern.
  37436. *
  37437. * 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.
  37438. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  37439. * 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).
  37440. * 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.
  37441. */
  37442. class Observable<T> {
  37443. private _observers;
  37444. private _eventState;
  37445. private _onObserverAdded;
  37446. /**
  37447. * Creates a new observable
  37448. * @param onObserverAdded defines a callback to call when a new observer is added
  37449. */
  37450. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  37451. /**
  37452. * Create a new Observer with the specified callback
  37453. * @param callback the callback that will be executed for that Observer
  37454. * @param mask the mask used to filter observers
  37455. * @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.
  37456. * @param scope optional scope for the callback to be called from
  37457. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  37458. * @returns the new observer created for the callback
  37459. */
  37460. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  37461. /**
  37462. * Create a new Observer with the specified callback and unregisters after the next notification
  37463. * @param callback the callback that will be executed for that Observer
  37464. * @returns the new observer created for the callback
  37465. */
  37466. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  37467. /**
  37468. * Remove an Observer from the Observable object
  37469. * @param observer the instance of the Observer to remove
  37470. * @returns false if it doesn't belong to this Observable
  37471. */
  37472. remove(observer: Nullable<Observer<T>>): boolean;
  37473. /**
  37474. * Remove a callback from the Observable object
  37475. * @param callback the callback to remove
  37476. * @param scope optional scope. If used only the callbacks with this scope will be removed
  37477. * @returns false if it doesn't belong to this Observable
  37478. */
  37479. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  37480. private _deferUnregister;
  37481. private _remove;
  37482. /**
  37483. * Notify all Observers by calling their respective callback with the given data
  37484. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  37485. * @param eventData defines the data to send to all observers
  37486. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  37487. * @param target defines the original target of the state
  37488. * @param currentTarget defines the current target of the state
  37489. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  37490. */
  37491. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  37492. /**
  37493. * Calling this will execute each callback, expecting it to be a promise or return a value.
  37494. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  37495. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  37496. * and it is crucial that all callbacks will be executed.
  37497. * The order of the callbacks is kept, callbacks are not executed parallel.
  37498. *
  37499. * @param eventData The data to be sent to each callback
  37500. * @param mask is used to filter observers defaults to -1
  37501. * @param target defines the callback target (see EventState)
  37502. * @param currentTarget defines he current object in the bubbling phase
  37503. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  37504. */
  37505. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  37506. /**
  37507. * Notify a specific observer
  37508. * @param observer defines the observer to notify
  37509. * @param eventData defines the data to be sent to each callback
  37510. * @param mask is used to filter observers defaults to -1
  37511. */
  37512. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  37513. /**
  37514. * Gets a boolean indicating if the observable has at least one observer
  37515. * @returns true is the Observable has at least one Observer registered
  37516. */
  37517. hasObservers(): boolean;
  37518. /**
  37519. * Clear the list of observers
  37520. */
  37521. clear(): void;
  37522. /**
  37523. * Clone the current observable
  37524. * @returns a new observable
  37525. */
  37526. clone(): Observable<T>;
  37527. /**
  37528. * Does this observable handles observer registered with a given mask
  37529. * @param mask defines the mask to be tested
  37530. * @return whether or not one observer registered with the given mask is handeled
  37531. **/
  37532. hasSpecificMask(mask?: number): boolean;
  37533. }
  37534. }
  37535. declare module BABYLON {
  37536. /**
  37537. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37538. */
  37539. class PerformanceMonitor {
  37540. private _enabled;
  37541. private _rollingFrameTime;
  37542. private _lastFrameTimeMs;
  37543. /**
  37544. * constructor
  37545. * @param frameSampleSize The number of samples required to saturate the sliding window
  37546. */
  37547. constructor(frameSampleSize?: number);
  37548. /**
  37549. * Samples current frame
  37550. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37551. */
  37552. sampleFrame(timeMs?: number): void;
  37553. /**
  37554. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37555. */
  37556. readonly averageFrameTime: number;
  37557. /**
  37558. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37559. */
  37560. readonly averageFrameTimeVariance: number;
  37561. /**
  37562. * Returns the frame time of the most recent frame
  37563. */
  37564. readonly instantaneousFrameTime: number;
  37565. /**
  37566. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37567. */
  37568. readonly averageFPS: number;
  37569. /**
  37570. * Returns the average framerate in frames per second using the most recent frame time
  37571. */
  37572. readonly instantaneousFPS: number;
  37573. /**
  37574. * Returns true if enough samples have been taken to completely fill the sliding window
  37575. */
  37576. readonly isSaturated: boolean;
  37577. /**
  37578. * Enables contributions to the sliding window sample set
  37579. */
  37580. enable(): void;
  37581. /**
  37582. * Disables contributions to the sliding window sample set
  37583. * Samples will not be interpolated over the disabled period
  37584. */
  37585. disable(): void;
  37586. /**
  37587. * Returns true if sampling is enabled
  37588. */
  37589. readonly isEnabled: boolean;
  37590. /**
  37591. * Resets performance monitor
  37592. */
  37593. reset(): void;
  37594. }
  37595. /**
  37596. * RollingAverage
  37597. *
  37598. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37599. */
  37600. class RollingAverage {
  37601. /**
  37602. * Current average
  37603. */
  37604. average: number;
  37605. /**
  37606. * Current variance
  37607. */
  37608. variance: number;
  37609. protected _samples: Array<number>;
  37610. protected _sampleCount: number;
  37611. protected _pos: number;
  37612. protected _m2: number;
  37613. /**
  37614. * constructor
  37615. * @param length The number of samples required to saturate the sliding window
  37616. */
  37617. constructor(length: number);
  37618. /**
  37619. * Adds a sample to the sample set
  37620. * @param v The sample value
  37621. */
  37622. add(v: number): void;
  37623. /**
  37624. * Returns previously added values or null if outside of history or outside the sliding window domain
  37625. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37626. * @return Value previously recorded with add() or null if outside of range
  37627. */
  37628. history(i: number): number;
  37629. /**
  37630. * Returns true if enough samples have been taken to completely fill the sliding window
  37631. * @return true if sample-set saturated
  37632. */
  37633. isSaturated(): boolean;
  37634. /**
  37635. * Resets the rolling average (equivalent to 0 samples taken so far)
  37636. */
  37637. reset(): void;
  37638. /**
  37639. * Wraps a value around the sample range boundaries
  37640. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37641. * @return Wrapped position in sample range
  37642. */
  37643. protected _wrapPosition(i: number): number;
  37644. }
  37645. }
  37646. declare module BABYLON {
  37647. /**
  37648. * Helper class that provides a small promise polyfill
  37649. */
  37650. class PromisePolyfill {
  37651. /**
  37652. * Static function used to check if the polyfill is required
  37653. * If this is the case then the function will inject the polyfill to window.Promise
  37654. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37655. */
  37656. static Apply(force?: boolean): void;
  37657. }
  37658. }
  37659. declare module BABYLON {
  37660. /**
  37661. * Defines the root class used to create scene optimization to use with SceneOptimizer
  37662. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37663. */
  37664. class SceneOptimization {
  37665. /**
  37666. * Defines the priority of this optimization (0 by default which means first in the list)
  37667. */
  37668. priority: number;
  37669. /**
  37670. * Gets a string describing the action executed by the current optimization
  37671. * @returns description string
  37672. */
  37673. getDescription(): string;
  37674. /**
  37675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37676. * @param scene defines the current scene where to apply this optimization
  37677. * @param optimizer defines the current optimizer
  37678. * @returns true if everything that can be done was applied
  37679. */
  37680. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37681. /**
  37682. * Creates the SceneOptimization object
  37683. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37684. * @param desc defines the description associated with the optimization
  37685. */
  37686. constructor(
  37687. /**
  37688. * Defines the priority of this optimization (0 by default which means first in the list)
  37689. */
  37690. priority?: number);
  37691. }
  37692. /**
  37693. * Defines an optimization used to reduce the size of render target textures
  37694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37695. */
  37696. class TextureOptimization extends SceneOptimization {
  37697. /**
  37698. * Defines the priority of this optimization (0 by default which means first in the list)
  37699. */
  37700. priority: number;
  37701. /**
  37702. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  37703. */
  37704. maximumSize: number;
  37705. /**
  37706. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37707. */
  37708. step: number;
  37709. /**
  37710. * Gets a string describing the action executed by the current optimization
  37711. * @returns description string
  37712. */
  37713. getDescription(): string;
  37714. /**
  37715. * Creates the TextureOptimization object
  37716. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37717. * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  37718. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37719. */
  37720. constructor(
  37721. /**
  37722. * Defines the priority of this optimization (0 by default which means first in the list)
  37723. */
  37724. priority?: number,
  37725. /**
  37726. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  37727. */
  37728. maximumSize?: number,
  37729. /**
  37730. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  37731. */
  37732. step?: number);
  37733. /**
  37734. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37735. * @param scene defines the current scene where to apply this optimization
  37736. * @param optimizer defines the current optimizer
  37737. * @returns true if everything that can be done was applied
  37738. */
  37739. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37740. }
  37741. /**
  37742. * Defines an optimization used to increase or decrease the rendering resolution
  37743. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37744. */
  37745. class HardwareScalingOptimization extends SceneOptimization {
  37746. /**
  37747. * Defines the priority of this optimization (0 by default which means first in the list)
  37748. */
  37749. priority: number;
  37750. /**
  37751. * Defines the maximum scale to use (2 by default)
  37752. */
  37753. maximumScale: number;
  37754. /**
  37755. * Defines the step to use between two passes (0.5 by default)
  37756. */
  37757. step: number;
  37758. private _currentScale;
  37759. private _directionOffset;
  37760. /**
  37761. * Gets a string describing the action executed by the current optimization
  37762. * @return description string
  37763. */
  37764. getDescription(): string;
  37765. /**
  37766. * Creates the HardwareScalingOptimization object
  37767. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37768. * @param maximumScale defines the maximum scale to use (2 by default)
  37769. * @param step defines the step to use between two passes (0.5 by default)
  37770. */
  37771. constructor(
  37772. /**
  37773. * Defines the priority of this optimization (0 by default which means first in the list)
  37774. */
  37775. priority?: number,
  37776. /**
  37777. * Defines the maximum scale to use (2 by default)
  37778. */
  37779. maximumScale?: number,
  37780. /**
  37781. * Defines the step to use between two passes (0.5 by default)
  37782. */
  37783. step?: number);
  37784. /**
  37785. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37786. * @param scene defines the current scene where to apply this optimization
  37787. * @param optimizer defines the current optimizer
  37788. * @returns true if everything that can be done was applied
  37789. */
  37790. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37791. }
  37792. /**
  37793. * Defines an optimization used to remove shadows
  37794. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37795. */
  37796. class ShadowsOptimization extends SceneOptimization {
  37797. /**
  37798. * Gets a string describing the action executed by the current optimization
  37799. * @return description string
  37800. */
  37801. getDescription(): string;
  37802. /**
  37803. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37804. * @param scene defines the current scene where to apply this optimization
  37805. * @param optimizer defines the current optimizer
  37806. * @returns true if everything that can be done was applied
  37807. */
  37808. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37809. }
  37810. /**
  37811. * Defines an optimization used to turn post-processes off
  37812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37813. */
  37814. class PostProcessesOptimization extends SceneOptimization {
  37815. /**
  37816. * Gets a string describing the action executed by the current optimization
  37817. * @return description string
  37818. */
  37819. getDescription(): string;
  37820. /**
  37821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37822. * @param scene defines the current scene where to apply this optimization
  37823. * @param optimizer defines the current optimizer
  37824. * @returns true if everything that can be done was applied
  37825. */
  37826. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37827. }
  37828. /**
  37829. * Defines an optimization used to turn lens flares off
  37830. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37831. */
  37832. class LensFlaresOptimization extends SceneOptimization {
  37833. /**
  37834. * Gets a string describing the action executed by the current optimization
  37835. * @return description string
  37836. */
  37837. getDescription(): string;
  37838. /**
  37839. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37840. * @param scene defines the current scene where to apply this optimization
  37841. * @param optimizer defines the current optimizer
  37842. * @returns true if everything that can be done was applied
  37843. */
  37844. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37845. }
  37846. /**
  37847. * Defines an optimization based on user defined callback.
  37848. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37849. */
  37850. class CustomOptimization extends SceneOptimization {
  37851. /**
  37852. * Callback called to apply the custom optimization.
  37853. */
  37854. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  37855. /**
  37856. * Callback called to get custom description
  37857. */
  37858. onGetDescription: () => string;
  37859. /**
  37860. * Gets a string describing the action executed by the current optimization
  37861. * @returns description string
  37862. */
  37863. getDescription(): string;
  37864. /**
  37865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37866. * @param scene defines the current scene where to apply this optimization
  37867. * @param optimizer defines the current optimizer
  37868. * @returns true if everything that can be done was applied
  37869. */
  37870. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37871. }
  37872. /**
  37873. * Defines an optimization used to turn particles off
  37874. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37875. */
  37876. class ParticlesOptimization extends SceneOptimization {
  37877. /**
  37878. * Gets a string describing the action executed by the current optimization
  37879. * @return description string
  37880. */
  37881. getDescription(): string;
  37882. /**
  37883. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37884. * @param scene defines the current scene where to apply this optimization
  37885. * @param optimizer defines the current optimizer
  37886. * @returns true if everything that can be done was applied
  37887. */
  37888. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37889. }
  37890. /**
  37891. * Defines an optimization used to turn render targets off
  37892. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37893. */
  37894. class RenderTargetsOptimization extends SceneOptimization {
  37895. /**
  37896. * Gets a string describing the action executed by the current optimization
  37897. * @return description string
  37898. */
  37899. getDescription(): string;
  37900. /**
  37901. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37902. * @param scene defines the current scene where to apply this optimization
  37903. * @param optimizer defines the current optimizer
  37904. * @returns true if everything that can be done was applied
  37905. */
  37906. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  37907. }
  37908. /**
  37909. * Defines an optimization used to merge meshes with compatible materials
  37910. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37911. */
  37912. class MergeMeshesOptimization extends SceneOptimization {
  37913. private static _UpdateSelectionTree;
  37914. /**
  37915. * Gets or sets a boolean which defines if optimization octree has to be updated
  37916. */
  37917. /**
  37918. * Gets or sets a boolean which defines if optimization octree has to be updated
  37919. */
  37920. static UpdateSelectionTree: boolean;
  37921. /**
  37922. * Gets a string describing the action executed by the current optimization
  37923. * @return description string
  37924. */
  37925. getDescription(): string;
  37926. private _canBeMerged;
  37927. /**
  37928. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  37929. * @param scene defines the current scene where to apply this optimization
  37930. * @param optimizer defines the current optimizer
  37931. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  37932. * @returns true if everything that can be done was applied
  37933. */
  37934. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  37935. }
  37936. /**
  37937. * Defines a list of options used by SceneOptimizer
  37938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  37939. */
  37940. class SceneOptimizerOptions {
  37941. /**
  37942. * Defines the target frame rate to reach (60 by default)
  37943. */
  37944. targetFrameRate: number;
  37945. /**
  37946. * Defines the interval between two checkes (2000ms by default)
  37947. */
  37948. trackerDuration: number;
  37949. /**
  37950. * Gets the list of optimizations to apply
  37951. */
  37952. optimizations: SceneOptimization[];
  37953. /**
  37954. * Creates a new list of options used by SceneOptimizer
  37955. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  37956. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  37957. */
  37958. constructor(
  37959. /**
  37960. * Defines the target frame rate to reach (60 by default)
  37961. */
  37962. targetFrameRate?: number,
  37963. /**
  37964. * Defines the interval between two checkes (2000ms by default)
  37965. */
  37966. trackerDuration?: number);
  37967. /**
  37968. * Add a new optimization
  37969. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  37970. * @returns the current SceneOptimizerOptions
  37971. */
  37972. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  37973. /**
  37974. * Add a new custom optimization
  37975. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  37976. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  37977. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  37978. * @returns the current SceneOptimizerOptions
  37979. */
  37980. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  37981. /**
  37982. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  37983. * @param targetFrameRate defines the target frame rate (60 by default)
  37984. * @returns a SceneOptimizerOptions object
  37985. */
  37986. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37987. /**
  37988. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  37989. * @param targetFrameRate defines the target frame rate (60 by default)
  37990. * @returns a SceneOptimizerOptions object
  37991. */
  37992. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37993. /**
  37994. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  37995. * @param targetFrameRate defines the target frame rate (60 by default)
  37996. * @returns a SceneOptimizerOptions object
  37997. */
  37998. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  37999. }
  38000. /**
  38001. * Class used to run optimizations in order to reach a target frame rate
  38002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38003. */
  38004. class SceneOptimizer implements IDisposable {
  38005. private _isRunning;
  38006. private _options;
  38007. private _scene;
  38008. private _currentPriorityLevel;
  38009. private _targetFrameRate;
  38010. private _trackerDuration;
  38011. private _currentFrameRate;
  38012. private _sceneDisposeObserver;
  38013. private _improvementMode;
  38014. /**
  38015. * Defines an observable called when the optimizer reaches the target frame rate
  38016. */
  38017. onSuccessObservable: Observable<SceneOptimizer>;
  38018. /**
  38019. * Defines an observable called when the optimizer enables an optimization
  38020. */
  38021. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38022. /**
  38023. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38024. */
  38025. onFailureObservable: Observable<SceneOptimizer>;
  38026. /**
  38027. * Gets a boolean indicating if the optimizer is in improvement mode
  38028. */
  38029. readonly isInImprovementMode: boolean;
  38030. /**
  38031. * Gets the current priority level (0 at start)
  38032. */
  38033. readonly currentPriorityLevel: number;
  38034. /**
  38035. * Gets the current frame rate checked by the SceneOptimizer
  38036. */
  38037. readonly currentFrameRate: number;
  38038. /**
  38039. * Gets or sets the current target frame rate (60 by default)
  38040. */
  38041. /**
  38042. * Gets or sets the current target frame rate (60 by default)
  38043. */
  38044. targetFrameRate: number;
  38045. /**
  38046. * Gets or sets the current interval between two checks (every 2000ms by default)
  38047. */
  38048. /**
  38049. * Gets or sets the current interval between two checks (every 2000ms by default)
  38050. */
  38051. trackerDuration: number;
  38052. /**
  38053. * Gets the list of active optimizations
  38054. */
  38055. readonly optimizations: SceneOptimization[];
  38056. /**
  38057. * Creates a new SceneOptimizer
  38058. * @param scene defines the scene to work on
  38059. * @param options defines the options to use with the SceneOptimizer
  38060. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38061. * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)
  38062. */
  38063. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38064. /**
  38065. * Stops the current optimizer
  38066. */
  38067. stop(): void;
  38068. /**
  38069. * Reset the optimizer to initial step (current priority level = 0)
  38070. */
  38071. reset(): void;
  38072. /**
  38073. * Start the optimizer. By default it will try to reach a specific framerate
  38074. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38075. */
  38076. start(): void;
  38077. private _checkCurrentState;
  38078. /**
  38079. * Release all resources
  38080. */
  38081. dispose(): void;
  38082. /**
  38083. * Helper function to create a SceneOptimizer with one single line of code
  38084. * @param scene defines the scene to work on
  38085. * @param options defines the options to use with the SceneOptimizer
  38086. * @param onSuccess defines a callback to call on success
  38087. * @param onFailure defines a callback to call on failure
  38088. * @returns the new SceneOptimizer object
  38089. */
  38090. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38091. }
  38092. }
  38093. declare module BABYLON {
  38094. /**
  38095. * Class used to serialize a scene into a string
  38096. */
  38097. class SceneSerializer {
  38098. /**
  38099. * Clear cache used by a previous serialization
  38100. */
  38101. static ClearCache(): void;
  38102. /**
  38103. * Serialize a scene into a JSON compatible object
  38104. * @param scene defines the scene to serialize
  38105. * @returns a JSON compatible object
  38106. */
  38107. static Serialize(scene: Scene): any;
  38108. /**
  38109. * Serialize a mesh into a JSON compatible object
  38110. * @param toSerialize defines the mesh to serialize
  38111. * @param withParents defines if parents must be serialized as well
  38112. * @param withChildren defines if children must be serialized as well
  38113. * @returns a JSON compatible object
  38114. */
  38115. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38116. }
  38117. }
  38118. declare module BABYLON {
  38119. /**
  38120. * Defines an array and its length.
  38121. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38122. */
  38123. interface ISmartArrayLike<T> {
  38124. /**
  38125. * The data of the array.
  38126. */
  38127. data: Array<T>;
  38128. /**
  38129. * The active length of the array.
  38130. */
  38131. length: number;
  38132. }
  38133. /**
  38134. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38135. */
  38136. class SmartArray<T> implements ISmartArrayLike<T> {
  38137. /**
  38138. * The full set of data from the array.
  38139. */
  38140. data: Array<T>;
  38141. /**
  38142. * The active length of the array.
  38143. */
  38144. length: number;
  38145. protected _id: number;
  38146. /**
  38147. * Instantiates a Smart Array.
  38148. * @param capacity defines the default capacity of the array.
  38149. */
  38150. constructor(capacity: number);
  38151. /**
  38152. * Pushes a value at the end of the active data.
  38153. * @param value defines the object to push in the array.
  38154. */
  38155. push(value: T): void;
  38156. /**
  38157. * Iterates over the active data and apply the lambda to them.
  38158. * @param func defines the action to apply on each value.
  38159. */
  38160. forEach(func: (content: T) => void): void;
  38161. /**
  38162. * Sorts the full sets of data.
  38163. * @param compareFn defines the comparison function to apply.
  38164. */
  38165. sort(compareFn: (a: T, b: T) => number): void;
  38166. /**
  38167. * Resets the active data to an empty array.
  38168. */
  38169. reset(): void;
  38170. /**
  38171. * Releases all the data from the array as well as the array.
  38172. */
  38173. dispose(): void;
  38174. /**
  38175. * Concats the active data with a given array.
  38176. * @param array defines the data to concatenate with.
  38177. */
  38178. concat(array: any): void;
  38179. /**
  38180. * Returns the position of a value in the active data.
  38181. * @param value defines the value to find the index for
  38182. * @returns the index if found in the active data otherwise -1
  38183. */
  38184. indexOf(value: T): number;
  38185. /**
  38186. * Returns whether an element is part of the active data.
  38187. * @param value defines the value to look for
  38188. * @returns true if found in the active data otherwise false
  38189. */
  38190. contains(value: T): boolean;
  38191. private static _GlobalId;
  38192. }
  38193. /**
  38194. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38195. * The data in this array can only be present once
  38196. */
  38197. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38198. private _duplicateId;
  38199. /**
  38200. * Pushes a value at the end of the active data.
  38201. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38202. * @param value defines the object to push in the array.
  38203. */
  38204. push(value: T): void;
  38205. /**
  38206. * Pushes a value at the end of the active data.
  38207. * If the data is already present, it won t be added again
  38208. * @param value defines the object to push in the array.
  38209. * @returns true if added false if it was already present
  38210. */
  38211. pushNoDuplicate(value: T): boolean;
  38212. /**
  38213. * Resets the active data to an empty array.
  38214. */
  38215. reset(): void;
  38216. /**
  38217. * Concats the active data with a given array.
  38218. * This ensures no dupplicate will be present in the result.
  38219. * @param array defines the data to concatenate with.
  38220. */
  38221. concatWithNoDuplicate(array: any): void;
  38222. }
  38223. }
  38224. declare module BABYLON {
  38225. /**
  38226. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38227. * The underlying implementation relies on an associative array to ensure the best performances.
  38228. * The value can be anything including 'null' but except 'undefined'
  38229. */
  38230. class StringDictionary<T> {
  38231. /**
  38232. * This will clear this dictionary and copy the content from the 'source' one.
  38233. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38234. * @param source the dictionary to take the content from and copy to this dictionary
  38235. */
  38236. copyFrom(source: StringDictionary<T>): void;
  38237. /**
  38238. * Get a value based from its key
  38239. * @param key the given key to get the matching value from
  38240. * @return the value if found, otherwise undefined is returned
  38241. */
  38242. get(key: string): T | undefined;
  38243. /**
  38244. * Get a value from its key or add it if it doesn't exist.
  38245. * This method will ensure you that a given key/data will be present in the dictionary.
  38246. * @param key the given key to get the matching value from
  38247. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38248. * The factory will only be invoked if there's no data for the given key.
  38249. * @return the value corresponding to the key.
  38250. */
  38251. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38252. /**
  38253. * Get a value from its key if present in the dictionary otherwise add it
  38254. * @param key the key to get the value from
  38255. * @param val if there's no such key/value pair in the dictionary add it with this value
  38256. * @return the value corresponding to the key
  38257. */
  38258. getOrAdd(key: string, val: T): T;
  38259. /**
  38260. * Check if there's a given key in the dictionary
  38261. * @param key the key to check for
  38262. * @return true if the key is present, false otherwise
  38263. */
  38264. contains(key: string): boolean;
  38265. /**
  38266. * Add a new key and its corresponding value
  38267. * @param key the key to add
  38268. * @param value the value corresponding to the key
  38269. * @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
  38270. */
  38271. add(key: string, value: T): boolean;
  38272. /**
  38273. * Update a specific value associated to a key
  38274. * @param key defines the key to use
  38275. * @param value defines the value to store
  38276. * @returns true if the value was updated (or false if the key was not found)
  38277. */
  38278. set(key: string, value: T): boolean;
  38279. /**
  38280. * Get the element of the given key and remove it from the dictionary
  38281. * @param key defines the key to search
  38282. * @returns the value associated with the key or null if not found
  38283. */
  38284. getAndRemove(key: string): Nullable<T>;
  38285. /**
  38286. * Remove a key/value from the dictionary.
  38287. * @param key the key to remove
  38288. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38289. */
  38290. remove(key: string): boolean;
  38291. /**
  38292. * Clear the whole content of the dictionary
  38293. */
  38294. clear(): void;
  38295. /**
  38296. * Gets the current count
  38297. */
  38298. readonly count: number;
  38299. /**
  38300. * Execute a callback on each key/val of the dictionary.
  38301. * Note that you can remove any element in this dictionary in the callback implementation
  38302. * @param callback the callback to execute on a given key/value pair
  38303. */
  38304. forEach(callback: (key: string, val: T) => void): void;
  38305. /**
  38306. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38307. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38308. * Note that you can remove any element in this dictionary in the callback implementation
  38309. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38310. * @returns the first item
  38311. */
  38312. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38313. private _count;
  38314. private _data;
  38315. }
  38316. }
  38317. declare module BABYLON {
  38318. /**
  38319. * Class used to store custom tags
  38320. */
  38321. class Tags {
  38322. /**
  38323. * Adds support for tags on the given object
  38324. * @param obj defines the object to use
  38325. */
  38326. static EnableFor(obj: any): void;
  38327. /**
  38328. * Removes tags support
  38329. * @param obj defines the object to use
  38330. */
  38331. static DisableFor(obj: any): void;
  38332. /**
  38333. * Gets a boolean indicating if the given object has tags
  38334. * @param obj defines the object to use
  38335. * @returns a boolean
  38336. */
  38337. static HasTags(obj: any): boolean;
  38338. /**
  38339. * Gets the tags available on a given object
  38340. * @param obj defines the object to use
  38341. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38342. * @returns the tags
  38343. */
  38344. static GetTags(obj: any, asString?: boolean): any;
  38345. /**
  38346. * Adds tags to an object
  38347. * @param obj defines the object to use
  38348. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38349. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38350. */
  38351. static AddTagsTo(obj: any, tagsString: string): void;
  38352. /**
  38353. * @hidden
  38354. */
  38355. static _AddTagTo(obj: any, tag: string): void;
  38356. /**
  38357. * Removes specific tags from a specific object
  38358. * @param obj defines the object to use
  38359. * @param tagsString defines the tags to remove
  38360. */
  38361. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38362. /**
  38363. * @hidden
  38364. */
  38365. static _RemoveTagFrom(obj: any, tag: string): void;
  38366. /**
  38367. * Defines if tags hosted on an object match a given query
  38368. * @param obj defines the object to use
  38369. * @param tagsQuery defines the tag query
  38370. * @returns a boolean
  38371. */
  38372. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38373. }
  38374. }
  38375. declare module BABYLON {
  38376. /**
  38377. * Class used to host texture specific utilities
  38378. */
  38379. class TextureTools {
  38380. /**
  38381. * Uses the GPU to create a copy texture rescaled at a given size
  38382. * @param texture Texture to copy from
  38383. * @param width defines the desired width
  38384. * @param height defines the desired height
  38385. * @param useBilinearMode defines if bilinear mode has to be used
  38386. * @return the generated texture
  38387. */
  38388. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38389. /**
  38390. * Gets an environment BRDF texture for a given scene
  38391. * @param scene defines the hosting scene
  38392. * @returns the environment BRDF texture
  38393. */
  38394. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  38395. private static _environmentBRDFBase64Texture;
  38396. }
  38397. }
  38398. declare module BABYLON {
  38399. /**
  38400. * Based on jsTGALoader - Javascript loader for TGA file
  38401. * By Vincent Thibault
  38402. * @see http://blog.robrowser.com/javascript-tga-loader.html
  38403. */
  38404. class TGATools {
  38405. private static _TYPE_INDEXED;
  38406. private static _TYPE_RGB;
  38407. private static _TYPE_GREY;
  38408. private static _TYPE_RLE_INDEXED;
  38409. private static _TYPE_RLE_RGB;
  38410. private static _TYPE_RLE_GREY;
  38411. private static _ORIGIN_MASK;
  38412. private static _ORIGIN_SHIFT;
  38413. private static _ORIGIN_BL;
  38414. private static _ORIGIN_BR;
  38415. private static _ORIGIN_UL;
  38416. private static _ORIGIN_UR;
  38417. /**
  38418. * Gets the header of a TGA file
  38419. * @param data defines the TGA data
  38420. * @returns the header
  38421. */
  38422. static GetTGAHeader(data: Uint8Array): any;
  38423. /**
  38424. * Uploads TGA content to a Babylon Texture
  38425. * @hidden
  38426. */
  38427. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  38428. /** @hidden */
  38429. 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;
  38430. /** @hidden */
  38431. 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;
  38432. /** @hidden */
  38433. 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;
  38434. /** @hidden */
  38435. 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;
  38436. /** @hidden */
  38437. 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;
  38438. /** @hidden */
  38439. 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;
  38440. }
  38441. }
  38442. declare module BABYLON {
  38443. /**
  38444. * Interface containing an array of animations
  38445. */
  38446. interface IAnimatable {
  38447. /**
  38448. * Array of animations
  38449. */
  38450. animations: Array<Animation>;
  38451. }
  38452. /** Interface used by value gradients (color, factor, ...) */
  38453. interface IValueGradient {
  38454. /**
  38455. * Gets or sets the gradient value (between 0 and 1)
  38456. */
  38457. gradient: number;
  38458. }
  38459. /** Class used to store color4 gradient */
  38460. class ColorGradient implements IValueGradient {
  38461. /**
  38462. * Gets or sets the gradient value (between 0 and 1)
  38463. */
  38464. gradient: number;
  38465. /**
  38466. * Gets or sets first associated color
  38467. */
  38468. color1: Color4;
  38469. /**
  38470. * Gets or sets second associated color
  38471. */
  38472. color2?: Color4;
  38473. /**
  38474. * Will get a color picked randomly between color1 and color2.
  38475. * If color2 is undefined then color1 will be used
  38476. * @param result defines the target Color4 to store the result in
  38477. */
  38478. getColorToRef(result: Color4): void;
  38479. }
  38480. /** Class used to store color 3 gradient */
  38481. class Color3Gradient implements IValueGradient {
  38482. /**
  38483. * Gets or sets the gradient value (between 0 and 1)
  38484. */
  38485. gradient: number;
  38486. /**
  38487. * Gets or sets the associated color
  38488. */
  38489. color: Color3;
  38490. }
  38491. /** Class used to store factor gradient */
  38492. class FactorGradient implements IValueGradient {
  38493. /**
  38494. * Gets or sets the gradient value (between 0 and 1)
  38495. */
  38496. gradient: number;
  38497. /**
  38498. * Gets or sets first associated factor
  38499. */
  38500. factor1: number;
  38501. /**
  38502. * Gets or sets second associated factor
  38503. */
  38504. factor2?: number;
  38505. /**
  38506. * Will get a number picked randomly between factor1 and factor2.
  38507. * If factor2 is undefined then factor1 will be used
  38508. * @returns the picked number
  38509. */
  38510. getFactor(): number;
  38511. }
  38512. /**
  38513. * @ignore
  38514. * Application error to support additional information when loading a file
  38515. */
  38516. class LoadFileError extends Error {
  38517. /** defines the optional XHR request */
  38518. request?: XMLHttpRequest | undefined;
  38519. private static _setPrototypeOf;
  38520. /**
  38521. * Creates a new LoadFileError
  38522. * @param message defines the message of the error
  38523. * @param request defines the optional XHR request
  38524. */
  38525. constructor(message: string,
  38526. /** defines the optional XHR request */
  38527. request?: XMLHttpRequest | undefined);
  38528. }
  38529. /**
  38530. * Class used to define a retry strategy when error happens while loading assets
  38531. */
  38532. class RetryStrategy {
  38533. /**
  38534. * Function used to defines an exponential back off strategy
  38535. * @param maxRetries defines the maximum number of retries (3 by default)
  38536. * @param baseInterval defines the interval between retries
  38537. * @returns the strategy function to use
  38538. */
  38539. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38540. }
  38541. /**
  38542. * File request interface
  38543. */
  38544. interface IFileRequest {
  38545. /**
  38546. * Raised when the request is complete (success or error).
  38547. */
  38548. onCompleteObservable: Observable<IFileRequest>;
  38549. /**
  38550. * Aborts the request for a file.
  38551. */
  38552. abort: () => void;
  38553. }
  38554. /**
  38555. * Class containing a set of static utilities functions
  38556. */
  38557. class Tools {
  38558. /**
  38559. * Gets or sets the base URL to use to load assets
  38560. */
  38561. static BaseUrl: string;
  38562. /**
  38563. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38564. */
  38565. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38566. /**
  38567. * Default behaviour for cors in the application.
  38568. * It can be a string if the expected behavior is identical in the entire app.
  38569. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38570. */
  38571. static CorsBehavior: string | ((url: string | string[]) => string);
  38572. /**
  38573. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38574. * @ignorenaming
  38575. */
  38576. static UseFallbackTexture: boolean;
  38577. /**
  38578. * Use this object to register external classes like custom textures or material
  38579. * to allow the laoders to instantiate them
  38580. */
  38581. static RegisteredExternalClasses: {
  38582. [key: string]: Object;
  38583. };
  38584. /**
  38585. * Texture content used if a texture cannot loaded
  38586. * @ignorenaming
  38587. */
  38588. static fallbackTexture: string;
  38589. /**
  38590. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38591. * @param u defines the coordinate on X axis
  38592. * @param v defines the coordinate on Y axis
  38593. * @param width defines the width of the source data
  38594. * @param height defines the height of the source data
  38595. * @param pixels defines the source byte array
  38596. * @param color defines the output color
  38597. */
  38598. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  38599. /**
  38600. * Interpolates between a and b via alpha
  38601. * @param a The lower value (returned when alpha = 0)
  38602. * @param b The upper value (returned when alpha = 1)
  38603. * @param alpha The interpolation-factor
  38604. * @return The mixed value
  38605. */
  38606. static Mix(a: number, b: number, alpha: number): number;
  38607. /**
  38608. * Tries to instantiate a new object from a given class name
  38609. * @param className defines the class name to instantiate
  38610. * @returns the new object or null if the system was not able to do the instantiation
  38611. */
  38612. static Instantiate(className: string): any;
  38613. /**
  38614. * Provides a slice function that will work even on IE
  38615. * @param data defines the array to slice
  38616. * @param start defines the start of the data (optional)
  38617. * @param end defines the end of the data (optional)
  38618. * @returns the new sliced array
  38619. */
  38620. static Slice<T>(data: T, start?: number, end?: number): T;
  38621. /**
  38622. * Polyfill for setImmediate
  38623. * @param action defines the action to execute after the current execution block
  38624. */
  38625. static SetImmediate(action: () => void): void;
  38626. /**
  38627. * Function indicating if a number is an exponent of 2
  38628. * @param value defines the value to test
  38629. * @returns true if the value is an exponent of 2
  38630. */
  38631. static IsExponentOfTwo(value: number): boolean;
  38632. private static _tmpFloatArray;
  38633. /**
  38634. * Returns the nearest 32-bit single precision float representation of a Number
  38635. * @param value A Number. If the parameter is of a different type, it will get converted
  38636. * to a number or to NaN if it cannot be converted
  38637. * @returns number
  38638. */
  38639. static FloatRound(value: number): number;
  38640. /**
  38641. * Find the next highest power of two.
  38642. * @param x Number to start search from.
  38643. * @return Next highest power of two.
  38644. */
  38645. static CeilingPOT(x: number): number;
  38646. /**
  38647. * Find the next lowest power of two.
  38648. * @param x Number to start search from.
  38649. * @return Next lowest power of two.
  38650. */
  38651. static FloorPOT(x: number): number;
  38652. /**
  38653. * Find the nearest power of two.
  38654. * @param x Number to start search from.
  38655. * @return Next nearest power of two.
  38656. */
  38657. static NearestPOT(x: number): number;
  38658. /**
  38659. * Get the closest exponent of two
  38660. * @param value defines the value to approximate
  38661. * @param max defines the maximum value to return
  38662. * @param mode defines how to define the closest value
  38663. * @returns closest exponent of two of the given value
  38664. */
  38665. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  38666. /**
  38667. * Extracts the filename from a path
  38668. * @param path defines the path to use
  38669. * @returns the filename
  38670. */
  38671. static GetFilename(path: string): string;
  38672. /**
  38673. * Extracts the "folder" part of a path (everything before the filename).
  38674. * @param uri The URI to extract the info from
  38675. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38676. * @returns The "folder" part of the path
  38677. */
  38678. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38679. /**
  38680. * Extracts text content from a DOM element hierarchy
  38681. * @param element defines the root element
  38682. * @returns a string
  38683. */
  38684. static GetDOMTextContent(element: HTMLElement): string;
  38685. /**
  38686. * Convert an angle in radians to degrees
  38687. * @param angle defines the angle to convert
  38688. * @returns the angle in degrees
  38689. */
  38690. static ToDegrees(angle: number): number;
  38691. /**
  38692. * Convert an angle in degrees to radians
  38693. * @param angle defines the angle to convert
  38694. * @returns the angle in radians
  38695. */
  38696. static ToRadians(angle: number): number;
  38697. /**
  38698. * Encode a buffer to a base64 string
  38699. * @param buffer defines the buffer to encode
  38700. * @returns the encoded string
  38701. */
  38702. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  38703. /**
  38704. * Extracts minimum and maximum values from a list of indexed positions
  38705. * @param positions defines the positions to use
  38706. * @param indices defines the indices to the positions
  38707. * @param indexStart defines the start index
  38708. * @param indexCount defines the end index
  38709. * @param bias defines bias value to add to the result
  38710. * @return minimum and maximum values
  38711. */
  38712. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  38713. minimum: Vector3;
  38714. maximum: Vector3;
  38715. };
  38716. /**
  38717. * Extracts minimum and maximum values from a list of positions
  38718. * @param positions defines the positions to use
  38719. * @param start defines the start index in the positions array
  38720. * @param count defines the number of positions to handle
  38721. * @param bias defines bias value to add to the result
  38722. * @param stride defines the stride size to use (distance between two positions in the positions array)
  38723. * @return minimum and maximum values
  38724. */
  38725. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  38726. minimum: Vector3;
  38727. maximum: Vector3;
  38728. };
  38729. /**
  38730. * Returns an array if obj is not an array
  38731. * @param obj defines the object to evaluate as an array
  38732. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38733. * @returns either obj directly if obj is an array or a new array containing obj
  38734. */
  38735. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38736. /**
  38737. * Gets the pointer prefix to use
  38738. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38739. */
  38740. static GetPointerPrefix(): string;
  38741. /**
  38742. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  38743. * @param func - the function to be called
  38744. * @param requester - the object that will request the next frame. Falls back to window.
  38745. * @returns frame number
  38746. */
  38747. static QueueNewFrame(func: () => void, requester?: any): number;
  38748. /**
  38749. * Ask the browser to promote the current element to fullscreen rendering mode
  38750. * @param element defines the DOM element to promote
  38751. */
  38752. static RequestFullscreen(element: HTMLElement): void;
  38753. /**
  38754. * Asks the browser to exit fullscreen mode
  38755. */
  38756. static ExitFullscreen(): void;
  38757. /**
  38758. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38759. * @param url define the url we are trying
  38760. * @param element define the dom element where to configure the cors policy
  38761. */
  38762. static SetCorsBehavior(url: string | string[], element: {
  38763. crossOrigin: string | null;
  38764. }): void;
  38765. /**
  38766. * Removes unwanted characters from an url
  38767. * @param url defines the url to clean
  38768. * @returns the cleaned url
  38769. */
  38770. static CleanUrl(url: string): string;
  38771. /**
  38772. * Gets or sets a function used to pre-process url before using them to load assets
  38773. */
  38774. static PreprocessUrl: (url: string) => string;
  38775. /**
  38776. * Loads an image as an HTMLImageElement.
  38777. * @param input url string, ArrayBuffer, or Blob to load
  38778. * @param onLoad callback called when the image successfully loads
  38779. * @param onError callback called when the image fails to load
  38780. * @param database database for caching
  38781. * @returns the HTMLImageElement of the loaded image
  38782. */
  38783. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  38784. /**
  38785. * Loads a file
  38786. * @param url url string, ArrayBuffer, or Blob to load
  38787. * @param onSuccess callback called when the file successfully loads
  38788. * @param onProgress callback called while file is loading (if the server supports this mode)
  38789. * @param database database for caching
  38790. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38791. * @param onError callback called when the file fails to load
  38792. * @returns a file request object
  38793. */
  38794. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  38795. /**
  38796. * Load a script (identified by an url). When the url returns, the
  38797. * content of this file is added into a new script element, attached to the DOM (body element)
  38798. * @param scriptUrl defines the url of the script to laod
  38799. * @param onSuccess defines the callback called when the script is loaded
  38800. * @param onError defines the callback to call if an error occurs
  38801. */
  38802. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  38803. /**
  38804. * Loads a file from a blob
  38805. * @param fileToLoad defines the blob to use
  38806. * @param callback defines the callback to call when data is loaded
  38807. * @param progressCallback defines the callback to call during loading process
  38808. * @returns a file request object
  38809. */
  38810. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38811. /**
  38812. * Loads a file
  38813. * @param fileToLoad defines the file to load
  38814. * @param callback defines the callback to call when data is loaded
  38815. * @param progressCallBack defines the callback to call during loading process
  38816. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38817. * @returns a file request object
  38818. */
  38819. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  38820. /**
  38821. * Creates a data url from a given string content
  38822. * @param content defines the content to convert
  38823. * @returns the new data url link
  38824. */
  38825. static FileAsURL(content: string): string;
  38826. /**
  38827. * Format the given number to a specific decimal format
  38828. * @param value defines the number to format
  38829. * @param decimals defines the number of decimals to use
  38830. * @returns the formatted string
  38831. */
  38832. static Format(value: number, decimals?: number): string;
  38833. /**
  38834. * Checks if a given vector is inside a specific range
  38835. * @param v defines the vector to test
  38836. * @param min defines the minimum range
  38837. * @param max defines the maximum range
  38838. */
  38839. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  38840. /**
  38841. * Tries to copy an object by duplicating every property
  38842. * @param source defines the source object
  38843. * @param destination defines the target object
  38844. * @param doNotCopyList defines a list of properties to avoid
  38845. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38846. */
  38847. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38848. /**
  38849. * Gets a boolean indicating if the given object has no own property
  38850. * @param obj defines the object to test
  38851. * @returns true if object has no own property
  38852. */
  38853. static IsEmpty(obj: any): boolean;
  38854. /**
  38855. * Function used to register events at window level
  38856. * @param events defines the events to register
  38857. */
  38858. static RegisterTopRootEvents(events: {
  38859. name: string;
  38860. handler: Nullable<(e: FocusEvent) => any>;
  38861. }[]): void;
  38862. /**
  38863. * Function used to unregister events from window level
  38864. * @param events defines the events to unregister
  38865. */
  38866. static UnregisterTopRootEvents(events: {
  38867. name: string;
  38868. handler: Nullable<(e: FocusEvent) => any>;
  38869. }[]): void;
  38870. /**
  38871. * Dumps the current bound framebuffer
  38872. * @param width defines the rendering width
  38873. * @param height defines the rendering height
  38874. * @param engine defines the hosting engine
  38875. * @param successCallback defines the callback triggered once the data are available
  38876. * @param mimeType defines the mime type of the result
  38877. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38878. */
  38879. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38880. /**
  38881. * Converts the canvas data to blob.
  38882. * This acts as a polyfill for browsers not supporting the to blob function.
  38883. * @param canvas Defines the canvas to extract the data from
  38884. * @param successCallback Defines the callback triggered once the data are available
  38885. * @param mimeType Defines the mime type of the result
  38886. */
  38887. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38888. /**
  38889. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38890. * @param successCallback defines the callback triggered once the data are available
  38891. * @param mimeType defines the mime type of the result
  38892. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38893. */
  38894. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38895. /**
  38896. * Downloads a blob in the browser
  38897. * @param blob defines the blob to download
  38898. * @param fileName defines the name of the downloaded file
  38899. */
  38900. static Download(blob: Blob, fileName: string): void;
  38901. /**
  38902. * Captures a screenshot of the current rendering
  38903. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38904. * @param engine defines the rendering engine
  38905. * @param camera defines the source camera
  38906. * @param size This parameter can be set to a single number or to an object with the
  38907. * following (optional) properties: precision, width, height. If a single number is passed,
  38908. * it will be used for both width and height. If an object is passed, the screenshot size
  38909. * will be derived from the parameters. The precision property is a multiplier allowing
  38910. * rendering at a higher or lower resolution
  38911. * @param successCallback defines the callback receives a single parameter which contains the
  38912. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38913. * src parameter of an <img> to display it
  38914. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38915. * Check your browser for supported MIME types
  38916. */
  38917. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  38918. /**
  38919. * Generates an image screenshot from the specified camera.
  38920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38921. * @param engine The engine to use for rendering
  38922. * @param camera The camera to use for rendering
  38923. * @param size This parameter can be set to a single number or to an object with the
  38924. * following (optional) properties: precision, width, height. If a single number is passed,
  38925. * it will be used for both width and height. If an object is passed, the screenshot size
  38926. * will be derived from the parameters. The precision property is a multiplier allowing
  38927. * rendering at a higher or lower resolution
  38928. * @param successCallback The callback receives a single parameter which contains the
  38929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38930. * src parameter of an <img> to display it
  38931. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38932. * Check your browser for supported MIME types
  38933. * @param samples Texture samples (default: 1)
  38934. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38935. * @param fileName A name for for the downloaded file.
  38936. */
  38937. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38938. /**
  38939. * Validates if xhr data is correct
  38940. * @param xhr defines the request to validate
  38941. * @param dataType defines the expected data type
  38942. * @returns true if data is correct
  38943. */
  38944. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  38945. /**
  38946. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38947. * Be aware Math.random() could cause collisions, but:
  38948. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  38949. * @returns a pseudo random id
  38950. */
  38951. static RandomId(): string;
  38952. /**
  38953. * Test if the given uri is a base64 string
  38954. * @param uri The uri to test
  38955. * @return True if the uri is a base64 string or false otherwise
  38956. */
  38957. static IsBase64(uri: string): boolean;
  38958. /**
  38959. * Decode the given base64 uri.
  38960. * @param uri The uri to decode
  38961. * @return The decoded base64 data.
  38962. */
  38963. static DecodeBase64(uri: string): ArrayBuffer;
  38964. /**
  38965. * No log
  38966. */
  38967. static readonly NoneLogLevel: number;
  38968. /**
  38969. * Only message logs
  38970. */
  38971. static readonly MessageLogLevel: number;
  38972. /**
  38973. * Only warning logs
  38974. */
  38975. static readonly WarningLogLevel: number;
  38976. /**
  38977. * Only error logs
  38978. */
  38979. static readonly ErrorLogLevel: number;
  38980. /**
  38981. * All logs
  38982. */
  38983. static readonly AllLogLevel: number;
  38984. private static _LogCache;
  38985. /**
  38986. * Gets a value indicating the number of loading errors
  38987. * @ignorenaming
  38988. */
  38989. static errorsCount: number;
  38990. /**
  38991. * Callback called when a new log is added
  38992. */
  38993. static OnNewCacheEntry: (entry: string) => void;
  38994. private static _AddLogEntry;
  38995. private static _FormatMessage;
  38996. private static _LogDisabled;
  38997. private static _LogEnabled;
  38998. private static _WarnDisabled;
  38999. private static _WarnEnabled;
  39000. private static _ErrorDisabled;
  39001. private static _ErrorEnabled;
  39002. /**
  39003. * Log a message to the console
  39004. */
  39005. static Log: (message: string) => void;
  39006. /**
  39007. * Write a warning message to the console
  39008. */
  39009. static Warn: (message: string) => void;
  39010. /**
  39011. * Write an error message to the console
  39012. */
  39013. static Error: (message: string) => void;
  39014. /**
  39015. * Gets current log cache (list of logs)
  39016. */
  39017. static readonly LogCache: string;
  39018. /**
  39019. * Clears the log cache
  39020. */
  39021. static ClearLogCache(): void;
  39022. /**
  39023. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39024. */
  39025. static LogLevels: number;
  39026. /**
  39027. * Checks if the loaded document was accessed via `file:`-Protocol.
  39028. * @returns boolean
  39029. */
  39030. static IsFileURL(): boolean;
  39031. /**
  39032. * Checks if the window object exists
  39033. * @returns true if the window object exists
  39034. */
  39035. static IsWindowObjectExist(): boolean;
  39036. /**
  39037. * No performance log
  39038. */
  39039. static readonly PerformanceNoneLogLevel: number;
  39040. /**
  39041. * Use user marks to log performance
  39042. */
  39043. static readonly PerformanceUserMarkLogLevel: number;
  39044. /**
  39045. * Log performance to the console
  39046. */
  39047. static readonly PerformanceConsoleLogLevel: number;
  39048. private static _performance;
  39049. /**
  39050. * Sets the current performance log level
  39051. */
  39052. static PerformanceLogLevel: number;
  39053. private static _StartPerformanceCounterDisabled;
  39054. private static _EndPerformanceCounterDisabled;
  39055. private static _StartUserMark;
  39056. private static _EndUserMark;
  39057. private static _StartPerformanceConsole;
  39058. private static _EndPerformanceConsole;
  39059. /**
  39060. * Starts a performance counter
  39061. */
  39062. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39063. /**
  39064. * Ends a specific performance coutner
  39065. */
  39066. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39067. /**
  39068. * Gets either window.performance.now() if supported or Date.now() else
  39069. */
  39070. static readonly Now: number;
  39071. /**
  39072. * This method will return the name of the class used to create the instance of the given object.
  39073. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39074. * @param object the object to get the class name from
  39075. * @param isType defines if the object is actually a type
  39076. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39077. */
  39078. static GetClassName(object: any, isType?: boolean): string;
  39079. /**
  39080. * Gets the first element of an array satisfying a given predicate
  39081. * @param array defines the array to browse
  39082. * @param predicate defines the predicate to use
  39083. * @returns null if not found or the element
  39084. */
  39085. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39086. /**
  39087. * This method will return the name of the full name of the class, including its owning module (if any).
  39088. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  39089. * @param object the object to get the class name from
  39090. * @param isType defines if the object is actually a type
  39091. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  39092. * @ignorenaming
  39093. */
  39094. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39095. /**
  39096. * Returns a promise that resolves after the given amount of time.
  39097. * @param delay Number of milliseconds to delay
  39098. * @returns Promise that resolves after the given amount of time
  39099. */
  39100. static DelayAsync(delay: number): Promise<void>;
  39101. /**
  39102. * Gets the current gradient from an array of IValueGradient
  39103. * @param ratio defines the current ratio to get
  39104. * @param gradients defines the array of IValueGradient
  39105. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39106. */
  39107. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39108. }
  39109. /**
  39110. * This class is used to track a performance counter which is number based.
  39111. * The user has access to many properties which give statistics of different nature.
  39112. *
  39113. * The implementer can track two kinds of Performance Counter: time and count.
  39114. * 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.
  39115. * 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.
  39116. */
  39117. class PerfCounter {
  39118. /**
  39119. * Gets or sets a global boolean to turn on and off all the counters
  39120. */
  39121. static Enabled: boolean;
  39122. /**
  39123. * Returns the smallest value ever
  39124. */
  39125. readonly min: number;
  39126. /**
  39127. * Returns the biggest value ever
  39128. */
  39129. readonly max: number;
  39130. /**
  39131. * Returns the average value since the performance counter is running
  39132. */
  39133. readonly average: number;
  39134. /**
  39135. * Returns the average value of the last second the counter was monitored
  39136. */
  39137. readonly lastSecAverage: number;
  39138. /**
  39139. * Returns the current value
  39140. */
  39141. readonly current: number;
  39142. /**
  39143. * Gets the accumulated total
  39144. */
  39145. readonly total: number;
  39146. /**
  39147. * Gets the total value count
  39148. */
  39149. readonly count: number;
  39150. /**
  39151. * Creates a new counter
  39152. */
  39153. constructor();
  39154. /**
  39155. * Call this method to start monitoring a new frame.
  39156. * 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.
  39157. */
  39158. fetchNewFrame(): void;
  39159. /**
  39160. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39161. * @param newCount the count value to add to the monitored count
  39162. * @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.
  39163. */
  39164. addCount(newCount: number, fetchResult: boolean): void;
  39165. /**
  39166. * Start monitoring this performance counter
  39167. */
  39168. beginMonitoring(): void;
  39169. /**
  39170. * Compute the time lapsed since the previous beginMonitoring() call.
  39171. * @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
  39172. */
  39173. endMonitoring(newFrame?: boolean): void;
  39174. private _fetchResult;
  39175. private _startMonitoringTime;
  39176. private _min;
  39177. private _max;
  39178. private _average;
  39179. private _current;
  39180. private _totalValueCount;
  39181. private _totalAccumulated;
  39182. private _lastSecAverage;
  39183. private _lastSecAccumulated;
  39184. private _lastSecTime;
  39185. private _lastSecValueCount;
  39186. }
  39187. /**
  39188. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39189. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39190. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39191. * @param name The name of the class, case should be preserved
  39192. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39193. */
  39194. function className(name: string, module?: string): (target: Object) => void;
  39195. /**
  39196. * An implementation of a loop for asynchronous functions.
  39197. */
  39198. class AsyncLoop {
  39199. /**
  39200. * Defines the number of iterations for the loop
  39201. */
  39202. iterations: number;
  39203. /**
  39204. * Defines the current index of the loop.
  39205. */
  39206. index: number;
  39207. private _done;
  39208. private _fn;
  39209. private _successCallback;
  39210. /**
  39211. * Constructor.
  39212. * @param iterations the number of iterations.
  39213. * @param func the function to run each iteration
  39214. * @param successCallback the callback that will be called upon succesful execution
  39215. * @param offset starting offset.
  39216. */
  39217. constructor(
  39218. /**
  39219. * Defines the number of iterations for the loop
  39220. */
  39221. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39222. /**
  39223. * Execute the next iteration. Must be called after the last iteration was finished.
  39224. */
  39225. executeNext(): void;
  39226. /**
  39227. * Break the loop and run the success callback.
  39228. */
  39229. breakLoop(): void;
  39230. /**
  39231. * Create and run an async loop.
  39232. * @param iterations the number of iterations.
  39233. * @param fn the function to run each iteration
  39234. * @param successCallback the callback that will be called upon succesful execution
  39235. * @param offset starting offset.
  39236. * @returns the created async loop object
  39237. */
  39238. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39239. /**
  39240. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39241. * @param iterations total number of iterations
  39242. * @param syncedIterations number of synchronous iterations in each async iteration.
  39243. * @param fn the function to call each iteration.
  39244. * @param callback a success call back that will be called when iterating stops.
  39245. * @param breakFunction a break condition (optional)
  39246. * @param timeout timeout settings for the setTimeout function. default - 0.
  39247. * @returns the created async loop object
  39248. */
  39249. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39250. }
  39251. }
  39252. interface HTMLCanvasElement {
  39253. /** Track wether a record is in progress */
  39254. isRecording: boolean;
  39255. /** Capture Stream method defined by some browsers */
  39256. captureStream(fps?: number): MediaStream;
  39257. }
  39258. interface MediaRecorder {
  39259. /** Starts recording */
  39260. start(timeSlice: number): void;
  39261. /** Stops recording */
  39262. stop(): void;
  39263. /** Event raised when an error arised. */
  39264. onerror: (event: ErrorEvent) => void;
  39265. /** Event raised when the recording stops. */
  39266. onstop: (event: Event) => void;
  39267. /** Event raised when a new chunk of data is available and should be tracked. */
  39268. ondataavailable: (event: Event) => void;
  39269. }
  39270. interface MediaRecorderOptions {
  39271. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39272. mimeType?: string;
  39273. /** The chosen bitrate for the audio component of the media. */
  39274. audioBitsPerSecond?: number;
  39275. /** The chosen bitrate for the video component of the media. */
  39276. videoBitsPerSecond?: number;
  39277. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  39278. bitsPerSecond?: number;
  39279. }
  39280. interface MediaRecorderConstructor {
  39281. /**
  39282. * A reference to the prototype.
  39283. */
  39284. readonly prototype: MediaRecorder;
  39285. /**
  39286. * Creates a new MediaRecorder.
  39287. * @param stream Defines the stream to record.
  39288. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39289. */
  39290. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39291. }
  39292. /**
  39293. * MediaRecoreder object available in some browsers.
  39294. */
  39295. declare var MediaRecorder: MediaRecorderConstructor;
  39296. declare module BABYLON {
  39297. /**
  39298. * This represents the different options avilable for the video capture.
  39299. */
  39300. interface VideoRecorderOptions {
  39301. /** Defines the mime type of the video */
  39302. mimeType: string;
  39303. /** Defines the video the video should be recorded at */
  39304. fps: number;
  39305. /** Defines the chunk size for the recording data */
  39306. recordChunckSize: number;
  39307. }
  39308. /**
  39309. * This can helps recording videos from BabylonJS.
  39310. * This is based on the available WebRTC functionalities of the browser.
  39311. *
  39312. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39313. */
  39314. class VideoRecorder {
  39315. private static readonly _defaultOptions;
  39316. /**
  39317. * Returns wehther or not the VideoRecorder is available in your browser.
  39318. * @param engine Defines the Babylon Engine to check the support for
  39319. * @returns true if supported otherwise false
  39320. */
  39321. static IsSupported(engine: Engine): boolean;
  39322. private readonly _options;
  39323. private _canvas;
  39324. private _mediaRecorder;
  39325. private _recordedChunks;
  39326. private _fileName;
  39327. private _resolve;
  39328. private _reject;
  39329. /**
  39330. * True wether a recording is already in progress.
  39331. */
  39332. readonly isRecording: boolean;
  39333. /**
  39334. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39335. * a video file.
  39336. * @param engine Defines the BabylonJS Engine you wish to record
  39337. * @param options Defines options that can be used to customized the capture
  39338. */
  39339. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39340. /**
  39341. * Stops the current recording before the default capture timeout passed in the startRecording
  39342. * functions.
  39343. */
  39344. stopRecording(): void;
  39345. /**
  39346. * Starts recording the canvas for a max duration specified in parameters.
  39347. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  39348. * @param maxDuration Defines the maximum recording time in seconds.
  39349. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39350. * @return a promise callback at the end of the recording with the video data in Blob.
  39351. */
  39352. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39353. /**
  39354. * Releases internal resources used during the recording.
  39355. */
  39356. dispose(): void;
  39357. private _handleDataAvailable;
  39358. private _handleError;
  39359. private _handleStop;
  39360. }
  39361. }
  39362. declare module BABYLON {
  39363. /**
  39364. * Defines the potential axis of a Joystick
  39365. */
  39366. enum JoystickAxis {
  39367. /** X axis */
  39368. X = 0,
  39369. /** Y axis */
  39370. Y = 1,
  39371. /** Z axis */
  39372. Z = 2
  39373. }
  39374. /**
  39375. * Class used to define virtual joystick (used in touch mode)
  39376. */
  39377. class VirtualJoystick {
  39378. /**
  39379. * Gets or sets a boolean indicating that left and right values must be inverted
  39380. */
  39381. reverseLeftRight: boolean;
  39382. /**
  39383. * Gets or sets a boolean indicating that up and down values must be inverted
  39384. */
  39385. reverseUpDown: boolean;
  39386. /**
  39387. * Gets the offset value for the position (ie. the change of the position value)
  39388. */
  39389. deltaPosition: Vector3;
  39390. /**
  39391. * Gets a boolean indicating if the virtual joystick was pressed
  39392. */
  39393. pressed: boolean;
  39394. private static _globalJoystickIndex;
  39395. private static vjCanvas;
  39396. private static vjCanvasContext;
  39397. private static vjCanvasWidth;
  39398. private static vjCanvasHeight;
  39399. private static halfWidth;
  39400. private _action;
  39401. private _axisTargetedByLeftAndRight;
  39402. private _axisTargetedByUpAndDown;
  39403. private _joystickSensibility;
  39404. private _inversedSensibility;
  39405. private _joystickPointerID;
  39406. private _joystickColor;
  39407. private _joystickPointerPos;
  39408. private _joystickPreviousPointerPos;
  39409. private _joystickPointerStartPos;
  39410. private _deltaJoystickVector;
  39411. private _leftJoystick;
  39412. private _touches;
  39413. private _onPointerDownHandlerRef;
  39414. private _onPointerMoveHandlerRef;
  39415. private _onPointerUpHandlerRef;
  39416. private _onResize;
  39417. /**
  39418. * Creates a new virtual joystick
  39419. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39420. */
  39421. constructor(leftJoystick?: boolean);
  39422. /**
  39423. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39424. * @param newJoystickSensibility defines the new sensibility
  39425. */
  39426. setJoystickSensibility(newJoystickSensibility: number): void;
  39427. private _onPointerDown;
  39428. private _onPointerMove;
  39429. private _onPointerUp;
  39430. /**
  39431. * Change the color of the virtual joystick
  39432. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39433. */
  39434. setJoystickColor(newColor: string): void;
  39435. /**
  39436. * Defines a callback to call when the joystick is touched
  39437. * @param action defines the callback
  39438. */
  39439. setActionOnTouch(action: () => any): void;
  39440. /**
  39441. * Defines which axis you'd like to control for left & right
  39442. * @param axis defines the axis to use
  39443. */
  39444. setAxisForLeftRight(axis: JoystickAxis): void;
  39445. /**
  39446. * Defines which axis you'd like to control for up & down
  39447. * @param axis defines the axis to use
  39448. */
  39449. setAxisForUpDown(axis: JoystickAxis): void;
  39450. private _drawVirtualJoystick;
  39451. /**
  39452. * Release internal HTML canvas
  39453. */
  39454. releaseCanvas(): void;
  39455. }
  39456. }
  39457. declare module BABYLON {
  39458. /**
  39459. * Helper class to push actions to a pool of workers.
  39460. */
  39461. class WorkerPool implements IDisposable {
  39462. private _workerInfos;
  39463. private _pendingActions;
  39464. /**
  39465. * Constructor
  39466. * @param workers Array of workers to use for actions
  39467. */
  39468. constructor(workers: Array<Worker>);
  39469. /**
  39470. * Terminates all workers and clears any pending actions.
  39471. */
  39472. dispose(): void;
  39473. /**
  39474. * Pushes an action to the worker pool. If all the workers are active, the action will be
  39475. * pended until a worker has completed its action.
  39476. * @param action The action to perform. Call onComplete when the action is complete.
  39477. */
  39478. push(action: (worker: Worker, onComplete: () => void) => void): void;
  39479. private _execute;
  39480. }
  39481. }
  39482. declare module BABYLON {
  39483. /**
  39484. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39485. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39486. */
  39487. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39488. /**
  39489. * Gets the name of the behavior.
  39490. */
  39491. readonly name: string;
  39492. private _zoomStopsAnimation;
  39493. private _idleRotationSpeed;
  39494. private _idleRotationWaitTime;
  39495. private _idleRotationSpinupTime;
  39496. /**
  39497. * Sets the flag that indicates if user zooming should stop animation.
  39498. */
  39499. /**
  39500. * Gets the flag that indicates if user zooming should stop animation.
  39501. */
  39502. zoomStopsAnimation: boolean;
  39503. /**
  39504. * Sets the default speed at which the camera rotates around the model.
  39505. */
  39506. /**
  39507. * Gets the default speed at which the camera rotates around the model.
  39508. */
  39509. idleRotationSpeed: number;
  39510. /**
  39511. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39512. */
  39513. /**
  39514. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39515. */
  39516. idleRotationWaitTime: number;
  39517. /**
  39518. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39519. */
  39520. /**
  39521. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39522. */
  39523. idleRotationSpinupTime: number;
  39524. /**
  39525. * Gets a value indicating if the camera is currently rotating because of this behavior
  39526. */
  39527. readonly rotationInProgress: boolean;
  39528. private _onPrePointerObservableObserver;
  39529. private _onAfterCheckInputsObserver;
  39530. private _attachedCamera;
  39531. private _isPointerDown;
  39532. private _lastFrameTime;
  39533. private _lastInteractionTime;
  39534. private _cameraRotationSpeed;
  39535. /**
  39536. * Initializes the behavior.
  39537. */
  39538. init(): void;
  39539. /**
  39540. * Attaches the behavior to its arc rotate camera.
  39541. * @param camera Defines the camera to attach the behavior to
  39542. */
  39543. attach(camera: ArcRotateCamera): void;
  39544. /**
  39545. * Detaches the behavior from its current arc rotate camera.
  39546. */
  39547. detach(): void;
  39548. /**
  39549. * Returns true if user is scrolling.
  39550. * @return true if user is scrolling.
  39551. */
  39552. private _userIsZooming;
  39553. private _lastFrameRadius;
  39554. private _shouldAnimationStopForInteraction;
  39555. /**
  39556. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39557. */
  39558. private _applyUserInteraction;
  39559. private _userIsMoving;
  39560. }
  39561. }
  39562. declare module BABYLON {
  39563. /**
  39564. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39565. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39566. */
  39567. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39568. /**
  39569. * Gets the name of the behavior.
  39570. */
  39571. readonly name: string;
  39572. /**
  39573. * The easing function used by animations
  39574. */
  39575. static EasingFunction: BackEase;
  39576. /**
  39577. * The easing mode used by animations
  39578. */
  39579. static EasingMode: number;
  39580. /**
  39581. * The duration of the animation, in milliseconds
  39582. */
  39583. transitionDuration: number;
  39584. /**
  39585. * Length of the distance animated by the transition when lower radius is reached
  39586. */
  39587. lowerRadiusTransitionRange: number;
  39588. /**
  39589. * Length of the distance animated by the transition when upper radius is reached
  39590. */
  39591. upperRadiusTransitionRange: number;
  39592. private _autoTransitionRange;
  39593. /**
  39594. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39595. */
  39596. /**
  39597. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39598. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39599. */
  39600. autoTransitionRange: boolean;
  39601. private _attachedCamera;
  39602. private _onAfterCheckInputsObserver;
  39603. private _onMeshTargetChangedObserver;
  39604. /**
  39605. * Initializes the behavior.
  39606. */
  39607. init(): void;
  39608. /**
  39609. * Attaches the behavior to its arc rotate camera.
  39610. * @param camera Defines the camera to attach the behavior to
  39611. */
  39612. attach(camera: ArcRotateCamera): void;
  39613. /**
  39614. * Detaches the behavior from its current arc rotate camera.
  39615. */
  39616. detach(): void;
  39617. private _radiusIsAnimating;
  39618. private _radiusBounceTransition;
  39619. private _animatables;
  39620. private _cachedWheelPrecision;
  39621. /**
  39622. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39623. * @param radiusLimit The limit to check against.
  39624. * @return Bool to indicate if at limit.
  39625. */
  39626. private _isRadiusAtLimit;
  39627. /**
  39628. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39629. * @param radiusDelta The delta by which to animate to. Can be negative.
  39630. */
  39631. private _applyBoundRadiusAnimation;
  39632. /**
  39633. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39634. */
  39635. protected _clearAnimationLocks(): void;
  39636. /**
  39637. * Stops and removes all animations that have been applied to the camera
  39638. */
  39639. stopAllAnimations(): void;
  39640. }
  39641. }
  39642. declare module BABYLON {
  39643. /**
  39644. * The framing behavior (BABYLON.FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  39645. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39646. */
  39647. class FramingBehavior implements Behavior<ArcRotateCamera> {
  39648. /**
  39649. * Gets the name of the behavior.
  39650. */
  39651. readonly name: string;
  39652. private _mode;
  39653. private _radiusScale;
  39654. private _positionScale;
  39655. private _defaultElevation;
  39656. private _elevationReturnTime;
  39657. private _elevationReturnWaitTime;
  39658. private _zoomStopsAnimation;
  39659. private _framingTime;
  39660. /**
  39661. * The easing function used by animations
  39662. */
  39663. static EasingFunction: ExponentialEase;
  39664. /**
  39665. * The easing mode used by animations
  39666. */
  39667. static EasingMode: number;
  39668. /**
  39669. * Sets the current mode used by the behavior
  39670. */
  39671. /**
  39672. * Gets current mode used by the behavior.
  39673. */
  39674. mode: number;
  39675. /**
  39676. * Sets the scale applied to the radius (1 by default)
  39677. */
  39678. /**
  39679. * Gets the scale applied to the radius
  39680. */
  39681. radiusScale: number;
  39682. /**
  39683. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39684. */
  39685. /**
  39686. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39687. */
  39688. positionScale: number;
  39689. /**
  39690. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39691. * behaviour is triggered, in radians.
  39692. */
  39693. /**
  39694. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39695. * behaviour is triggered, in radians.
  39696. */
  39697. defaultElevation: number;
  39698. /**
  39699. * Sets the time (in milliseconds) taken to return to the default beta position.
  39700. * Negative value indicates camera should not return to default.
  39701. */
  39702. /**
  39703. * Gets the time (in milliseconds) taken to return to the default beta position.
  39704. * Negative value indicates camera should not return to default.
  39705. */
  39706. elevationReturnTime: number;
  39707. /**
  39708. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39709. */
  39710. /**
  39711. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39712. */
  39713. elevationReturnWaitTime: number;
  39714. /**
  39715. * Sets the flag that indicates if user zooming should stop animation.
  39716. */
  39717. /**
  39718. * Gets the flag that indicates if user zooming should stop animation.
  39719. */
  39720. zoomStopsAnimation: boolean;
  39721. /**
  39722. * Sets the transition time when framing the mesh, in milliseconds
  39723. */
  39724. /**
  39725. * Gets the transition time when framing the mesh, in milliseconds
  39726. */
  39727. framingTime: number;
  39728. /**
  39729. * Define if the behavior should automatically change the configured
  39730. * camera limits and sensibilities.
  39731. */
  39732. autoCorrectCameraLimitsAndSensibility: boolean;
  39733. private _onPrePointerObservableObserver;
  39734. private _onAfterCheckInputsObserver;
  39735. private _onMeshTargetChangedObserver;
  39736. private _attachedCamera;
  39737. private _isPointerDown;
  39738. private _lastInteractionTime;
  39739. /**
  39740. * Initializes the behavior.
  39741. */
  39742. init(): void;
  39743. /**
  39744. * Attaches the behavior to its arc rotate camera.
  39745. * @param camera Defines the camera to attach the behavior to
  39746. */
  39747. attach(camera: ArcRotateCamera): void;
  39748. /**
  39749. * Detaches the behavior from its current arc rotate camera.
  39750. */
  39751. detach(): void;
  39752. private _animatables;
  39753. private _betaIsAnimating;
  39754. private _betaTransition;
  39755. private _radiusTransition;
  39756. private _vectorTransition;
  39757. /**
  39758. * Targets the given mesh and updates zoom level accordingly.
  39759. * @param mesh The mesh to target.
  39760. * @param radius Optional. If a cached radius position already exists, overrides default.
  39761. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39762. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39763. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39764. */
  39765. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39766. /**
  39767. * Targets the given mesh with its children and updates zoom level accordingly.
  39768. * @param mesh The mesh to target.
  39769. * @param radius Optional. If a cached radius position already exists, overrides default.
  39770. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39771. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39772. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39773. */
  39774. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39775. /**
  39776. * Targets the given meshes with their children and updates zoom level accordingly.
  39777. * @param meshes The mesh to target.
  39778. * @param radius Optional. If a cached radius position already exists, overrides default.
  39779. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39780. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39781. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39782. */
  39783. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39784. /**
  39785. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39786. * @param minimumWorld Determines the smaller position of the bounding box extend
  39787. * @param maximumWorld Determines the bigger position of the bounding box extend
  39788. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39789. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39790. */
  39791. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39792. /**
  39793. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39794. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39795. * frustum width.
  39796. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39797. * to fully enclose the mesh in the viewing frustum.
  39798. */
  39799. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39800. /**
  39801. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39802. * is automatically returned to its default position (expected to be above ground plane).
  39803. */
  39804. private _maintainCameraAboveGround;
  39805. /**
  39806. * Returns the frustum slope based on the canvas ratio and camera FOV
  39807. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39808. */
  39809. private _getFrustumSlope;
  39810. /**
  39811. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39812. */
  39813. private _clearAnimationLocks;
  39814. /**
  39815. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39816. */
  39817. private _applyUserInteraction;
  39818. /**
  39819. * Stops and removes all animations that have been applied to the camera
  39820. */
  39821. stopAllAnimations(): void;
  39822. /**
  39823. * Gets a value indicating if the user is moving the camera
  39824. */
  39825. readonly isUserIsMoving: boolean;
  39826. /**
  39827. * The camera can move all the way towards the mesh.
  39828. */
  39829. static IgnoreBoundsSizeMode: number;
  39830. /**
  39831. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39832. */
  39833. static FitFrustumSidesMode: number;
  39834. }
  39835. }
  39836. declare module BABYLON {
  39837. /**
  39838. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39839. */
  39840. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  39841. private ui;
  39842. /**
  39843. * The name of the behavior
  39844. */
  39845. name: string;
  39846. /**
  39847. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39848. */
  39849. distanceAwayFromFace: number;
  39850. /**
  39851. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39852. */
  39853. distanceAwayFromBottomOfFace: number;
  39854. private _faceVectors;
  39855. private _target;
  39856. private _scene;
  39857. private _onRenderObserver;
  39858. private _tmpMatrix;
  39859. private _tmpVector;
  39860. /**
  39861. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39862. * @param ui The transform node that should be attched to the mesh
  39863. */
  39864. constructor(ui: BABYLON.TransformNode);
  39865. /**
  39866. * Initializes the behavior
  39867. */
  39868. init(): void;
  39869. private _closestFace;
  39870. private _zeroVector;
  39871. private _lookAtTmpMatrix;
  39872. private _lookAtToRef;
  39873. /**
  39874. * Attaches the AttachToBoxBehavior to the passed in mesh
  39875. * @param target The mesh that the specified node will be attached to
  39876. */
  39877. attach(target: BABYLON.Mesh): void;
  39878. /**
  39879. * Detaches the behavior from the mesh
  39880. */
  39881. detach(): void;
  39882. }
  39883. }
  39884. declare module BABYLON {
  39885. /**
  39886. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39887. */
  39888. class FadeInOutBehavior implements Behavior<Mesh> {
  39889. /**
  39890. * Time in milliseconds to delay before fading in (Default: 0)
  39891. */
  39892. delay: number;
  39893. /**
  39894. * Time in milliseconds for the mesh to fade in (Default: 300)
  39895. */
  39896. fadeInTime: number;
  39897. private _millisecondsPerFrame;
  39898. private _hovered;
  39899. private _hoverValue;
  39900. private _ownerNode;
  39901. /**
  39902. * Instatiates the FadeInOutBehavior
  39903. */
  39904. constructor();
  39905. /**
  39906. * The name of the behavior
  39907. */
  39908. readonly name: string;
  39909. /**
  39910. * Initializes the behavior
  39911. */
  39912. init(): void;
  39913. /**
  39914. * Attaches the fade behavior on the passed in mesh
  39915. * @param ownerNode The mesh that will be faded in/out once attached
  39916. */
  39917. attach(ownerNode: Mesh): void;
  39918. /**
  39919. * Detaches the behavior from the mesh
  39920. */
  39921. detach(): void;
  39922. /**
  39923. * Triggers the mesh to begin fading in or out
  39924. * @param value if the object should fade in or out (true to fade in)
  39925. */
  39926. fadeIn(value: boolean): void;
  39927. private _update;
  39928. private _setAllVisibility;
  39929. }
  39930. }
  39931. declare module BABYLON {
  39932. /**
  39933. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39934. */
  39935. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39936. private _dragBehaviorA;
  39937. private _dragBehaviorB;
  39938. private _startDistance;
  39939. private _initialScale;
  39940. private _targetScale;
  39941. private _ownerNode;
  39942. private _sceneRenderObserver;
  39943. /**
  39944. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39945. */
  39946. constructor();
  39947. /**
  39948. * The name of the behavior
  39949. */
  39950. readonly name: string;
  39951. /**
  39952. * Initializes the behavior
  39953. */
  39954. init(): void;
  39955. private _getCurrentDistance;
  39956. /**
  39957. * Attaches the scale behavior the passed in mesh
  39958. * @param ownerNode The mesh that will be scaled around once attached
  39959. */
  39960. attach(ownerNode: Mesh): void;
  39961. /**
  39962. * Detaches the behavior from the mesh
  39963. */
  39964. detach(): void;
  39965. }
  39966. }
  39967. declare module BABYLON {
  39968. /**
  39969. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39970. */
  39971. class PointerDragBehavior implements Behavior<Mesh> {
  39972. private static _AnyMouseID;
  39973. private _attachedNode;
  39974. private _dragPlane;
  39975. private _scene;
  39976. private _pointerObserver;
  39977. private _beforeRenderObserver;
  39978. private static _planeScene;
  39979. /**
  39980. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  39981. */
  39982. maxDragAngle: number;
  39983. /**
  39984. * @hidden
  39985. */
  39986. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39987. /**
  39988. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39989. */
  39990. currentDraggingPointerID: number;
  39991. /**
  39992. * The last position where the pointer hit the drag plane in world space
  39993. */
  39994. lastDragPosition: Vector3;
  39995. /**
  39996. * If the behavior is currently in a dragging state
  39997. */
  39998. dragging: boolean;
  39999. /**
  40000. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  40001. */
  40002. dragDeltaRatio: number;
  40003. /**
  40004. * If the drag plane orientation should be updated during the dragging (Default: true)
  40005. */
  40006. updateDragPlane: boolean;
  40007. private _debugMode;
  40008. private _moving;
  40009. /**
  40010. * Fires each time the attached mesh is dragged with the pointer
  40011. * * delta between last drag position and current drag position in world space
  40012. * * dragDistance along the drag axis
  40013. * * dragPlaneNormal normal of the current drag plane used during the drag
  40014. * * dragPlanePoint in world space where the drag intersects the drag plane
  40015. */
  40016. onDragObservable: Observable<{
  40017. delta: Vector3;
  40018. dragPlanePoint: Vector3;
  40019. dragPlaneNormal: Vector3;
  40020. dragDistance: number;
  40021. pointerId: number;
  40022. }>;
  40023. /**
  40024. * Fires each time a drag begins (eg. mouse down on mesh)
  40025. */
  40026. onDragStartObservable: Observable<{
  40027. dragPlanePoint: Vector3;
  40028. pointerId: number;
  40029. }>;
  40030. /**
  40031. * Fires each time a drag ends (eg. mouse release after drag)
  40032. */
  40033. onDragEndObservable: Observable<{
  40034. dragPlanePoint: Vector3;
  40035. pointerId: number;
  40036. }>;
  40037. /**
  40038. * If the attached mesh should be moved when dragged
  40039. */
  40040. moveAttached: boolean;
  40041. /**
  40042. * If the drag behavior will react to drag events (Default: true)
  40043. */
  40044. enabled: boolean;
  40045. /**
  40046. * If camera controls should be detached during the drag
  40047. */
  40048. detachCameraControls: boolean;
  40049. /**
  40050. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40051. */
  40052. useObjectOrienationForDragging: boolean;
  40053. private _options;
  40054. /**
  40055. * Creates a pointer drag behavior that can be attached to a mesh
  40056. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  40057. */
  40058. constructor(options?: {
  40059. dragAxis?: Vector3;
  40060. dragPlaneNormal?: Vector3;
  40061. });
  40062. /**
  40063. * The name of the behavior
  40064. */
  40065. readonly name: string;
  40066. /**
  40067. * Initializes the behavior
  40068. */
  40069. init(): void;
  40070. private _tmpVector;
  40071. private _alternatePickedPoint;
  40072. private _worldDragAxis;
  40073. private _targetPosition;
  40074. private _attachedElement;
  40075. /**
  40076. * Attaches the drag behavior the passed in mesh
  40077. * @param ownerNode The mesh that will be dragged around once attached
  40078. */
  40079. attach(ownerNode: Mesh): void;
  40080. /**
  40081. * Force relase the drag action by code.
  40082. */
  40083. releaseDrag(): void;
  40084. private _startDragRay;
  40085. private _lastPointerRay;
  40086. /**
  40087. * Simulates the start of a pointer drag event on the behavior
  40088. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40089. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40090. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40091. */
  40092. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40093. private _startDrag;
  40094. private _dragDelta;
  40095. private _moveDrag;
  40096. private _pickWithRayOnDragPlane;
  40097. private _pointA;
  40098. private _pointB;
  40099. private _pointC;
  40100. private _lineA;
  40101. private _lineB;
  40102. private _localAxis;
  40103. private _lookAt;
  40104. private _updateDragPlanePosition;
  40105. /**
  40106. * Detaches the behavior from the mesh
  40107. */
  40108. detach(): void;
  40109. }
  40110. }
  40111. declare module BABYLON {
  40112. /**
  40113. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  40114. */
  40115. class SixDofDragBehavior implements Behavior<Mesh> {
  40116. private static _virtualScene;
  40117. private _ownerNode;
  40118. private _sceneRenderObserver;
  40119. private _scene;
  40120. private _targetPosition;
  40121. private _virtualOriginMesh;
  40122. private _virtualDragMesh;
  40123. private _pointerObserver;
  40124. private _moving;
  40125. private _startingOrientation;
  40126. /**
  40127. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  40128. */
  40129. private zDragFactor;
  40130. /**
  40131. * If the behavior is currently in a dragging state
  40132. */
  40133. dragging: boolean;
  40134. /**
  40135. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  40136. */
  40137. dragDeltaRatio: number;
  40138. /**
  40139. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40140. */
  40141. currentDraggingPointerID: number;
  40142. /**
  40143. * If camera controls should be detached during the drag
  40144. */
  40145. detachCameraControls: boolean;
  40146. /**
  40147. * Fires each time a drag starts
  40148. */
  40149. onDragStartObservable: Observable<{}>;
  40150. /**
  40151. * Fires each time a drag ends (eg. mouse release after drag)
  40152. */
  40153. onDragEndObservable: Observable<{}>;
  40154. /**
  40155. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  40156. */
  40157. constructor();
  40158. /**
  40159. * The name of the behavior
  40160. */
  40161. readonly name: string;
  40162. /**
  40163. * Initializes the behavior
  40164. */
  40165. init(): void;
  40166. /**
  40167. * Attaches the scale behavior the passed in mesh
  40168. * @param ownerNode The mesh that will be scaled around once attached
  40169. */
  40170. attach(ownerNode: Mesh): void;
  40171. /**
  40172. * Detaches the behavior from the mesh
  40173. */
  40174. detach(): void;
  40175. }
  40176. }
  40177. declare module BABYLON {
  40178. /**
  40179. * Manage the gamepad inputs to control an arc rotate camera.
  40180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40181. */
  40182. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40183. /**
  40184. * Defines the camera the input is attached to.
  40185. */
  40186. camera: ArcRotateCamera;
  40187. /**
  40188. * Defines the gamepad the input is gathering event from.
  40189. */
  40190. gamepad: Nullable<Gamepad>;
  40191. /**
  40192. * Defines the gamepad rotation sensiblity.
  40193. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40194. */
  40195. gamepadRotationSensibility: number;
  40196. /**
  40197. * Defines the gamepad move sensiblity.
  40198. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40199. */
  40200. gamepadMoveSensibility: number;
  40201. private _onGamepadConnectedObserver;
  40202. private _onGamepadDisconnectedObserver;
  40203. /**
  40204. * Attach the input controls to a specific dom element to get the input from.
  40205. * @param element Defines the element the controls should be listened from
  40206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40207. */
  40208. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40209. /**
  40210. * Detach the current controls from the specified dom element.
  40211. * @param element Defines the element to stop listening the inputs from
  40212. */
  40213. detachControl(element: Nullable<HTMLElement>): void;
  40214. /**
  40215. * Update the current camera state depending on the inputs that have been used this frame.
  40216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40217. */
  40218. checkInputs(): void;
  40219. /**
  40220. * Gets the class name of the current intput.
  40221. * @returns the class name
  40222. */
  40223. getClassName(): string;
  40224. /**
  40225. * Get the friendly name associated with the input class.
  40226. * @returns the input friendly name
  40227. */
  40228. getSimpleName(): string;
  40229. }
  40230. }
  40231. declare module BABYLON {
  40232. /**
  40233. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40235. */
  40236. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40237. /**
  40238. * Defines the camera the input is attached to.
  40239. */
  40240. camera: ArcRotateCamera;
  40241. /**
  40242. * Defines the list of key codes associated with the up action (increase alpha)
  40243. */
  40244. keysUp: number[];
  40245. /**
  40246. * Defines the list of key codes associated with the down action (decrease alpha)
  40247. */
  40248. keysDown: number[];
  40249. /**
  40250. * Defines the list of key codes associated with the left action (increase beta)
  40251. */
  40252. keysLeft: number[];
  40253. /**
  40254. * Defines the list of key codes associated with the right action (decrease beta)
  40255. */
  40256. keysRight: number[];
  40257. /**
  40258. * Defines the list of key codes associated with the reset action.
  40259. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40260. */
  40261. keysReset: number[];
  40262. /**
  40263. * Defines the panning sensibility of the inputs.
  40264. * (How fast is the camera paning)
  40265. */
  40266. panningSensibility: number;
  40267. /**
  40268. * Defines the zooming sensibility of the inputs.
  40269. * (How fast is the camera zooming)
  40270. */
  40271. zoomingSensibility: number;
  40272. /**
  40273. * Defines wether maintaining the alt key down switch the movement mode from
  40274. * orientation to zoom.
  40275. */
  40276. useAltToZoom: boolean;
  40277. /**
  40278. * Rotation speed of the camera
  40279. */
  40280. angularSpeed: number;
  40281. private _keys;
  40282. private _ctrlPressed;
  40283. private _altPressed;
  40284. private _onCanvasBlurObserver;
  40285. private _onKeyboardObserver;
  40286. private _engine;
  40287. private _scene;
  40288. /**
  40289. * Attach the input controls to a specific dom element to get the input from.
  40290. * @param element Defines the element the controls should be listened from
  40291. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40292. */
  40293. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40294. /**
  40295. * Detach the current controls from the specified dom element.
  40296. * @param element Defines the element to stop listening the inputs from
  40297. */
  40298. detachControl(element: Nullable<HTMLElement>): void;
  40299. /**
  40300. * Update the current camera state depending on the inputs that have been used this frame.
  40301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40302. */
  40303. checkInputs(): void;
  40304. /**
  40305. * Gets the class name of the current intput.
  40306. * @returns the class name
  40307. */
  40308. getClassName(): string;
  40309. /**
  40310. * Get the friendly name associated with the input class.
  40311. * @returns the input friendly name
  40312. */
  40313. getSimpleName(): string;
  40314. }
  40315. }
  40316. declare module BABYLON {
  40317. /**
  40318. * Manage the mouse wheel inputs to control an arc rotate camera.
  40319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40320. */
  40321. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40322. /**
  40323. * Defines the camera the input is attached to.
  40324. */
  40325. camera: ArcRotateCamera;
  40326. /**
  40327. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40328. */
  40329. wheelPrecision: number;
  40330. /**
  40331. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40332. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40333. */
  40334. wheelDeltaPercentage: number;
  40335. private _wheel;
  40336. private _observer;
  40337. /**
  40338. * Attach the input controls to a specific dom element to get the input from.
  40339. * @param element Defines the element the controls should be listened from
  40340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40341. */
  40342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40343. /**
  40344. * Detach the current controls from the specified dom element.
  40345. * @param element Defines the element to stop listening the inputs from
  40346. */
  40347. detachControl(element: Nullable<HTMLElement>): void;
  40348. /**
  40349. * Gets the class name of the current intput.
  40350. * @returns the class name
  40351. */
  40352. getClassName(): string;
  40353. /**
  40354. * Get the friendly name associated with the input class.
  40355. * @returns the input friendly name
  40356. */
  40357. getSimpleName(): string;
  40358. }
  40359. }
  40360. declare module BABYLON {
  40361. /**
  40362. * Manage the pointers inputs to control an arc rotate camera.
  40363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40364. */
  40365. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  40366. /**
  40367. * Defines the camera the input is attached to.
  40368. */
  40369. camera: ArcRotateCamera;
  40370. /**
  40371. * Defines the buttons associated with the input to handle camera move.
  40372. */
  40373. buttons: number[];
  40374. /**
  40375. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40376. */
  40377. angularSensibilityX: number;
  40378. /**
  40379. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40380. */
  40381. angularSensibilityY: number;
  40382. /**
  40383. * Defines the pointer pinch precision or how fast is the camera zooming.
  40384. */
  40385. pinchPrecision: number;
  40386. /**
  40387. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  40388. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40389. */
  40390. pinchDeltaPercentage: number;
  40391. /**
  40392. * Defines the pointer panning sensibility or how fast is the camera moving.
  40393. */
  40394. panningSensibility: number;
  40395. /**
  40396. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40397. */
  40398. multiTouchPanning: boolean;
  40399. /**
  40400. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  40401. */
  40402. multiTouchPanAndZoom: boolean;
  40403. /**
  40404. * Revers pinch action direction.
  40405. */
  40406. pinchInwards: boolean;
  40407. private _isPanClick;
  40408. private _pointerInput;
  40409. private _observer;
  40410. private _onMouseMove;
  40411. private _onGestureStart;
  40412. private _onGesture;
  40413. private _MSGestureHandler;
  40414. private _onLostFocus;
  40415. private _onContextMenu;
  40416. /**
  40417. * Attach the input controls to a specific dom element to get the input from.
  40418. * @param element Defines the element the controls should be listened from
  40419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40420. */
  40421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40422. /**
  40423. * Detach the current controls from the specified dom element.
  40424. * @param element Defines the element to stop listening the inputs from
  40425. */
  40426. detachControl(element: Nullable<HTMLElement>): void;
  40427. /**
  40428. * Gets the class name of the current intput.
  40429. * @returns the class name
  40430. */
  40431. getClassName(): string;
  40432. /**
  40433. * Get the friendly name associated with the input class.
  40434. * @returns the input friendly name
  40435. */
  40436. getSimpleName(): string;
  40437. }
  40438. }
  40439. declare module BABYLON {
  40440. /**
  40441. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40443. */
  40444. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40445. /**
  40446. * Defines the camera the input is attached to.
  40447. */
  40448. camera: ArcRotateCamera;
  40449. /**
  40450. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40451. */
  40452. alphaCorrection: number;
  40453. /**
  40454. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  40455. */
  40456. betaCorrection: number;
  40457. /**
  40458. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40459. */
  40460. gammaCorrection: number;
  40461. private _alpha;
  40462. private _gamma;
  40463. private _dirty;
  40464. private _deviceOrientationHandler;
  40465. /**
  40466. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40467. */
  40468. constructor();
  40469. /**
  40470. * Attach the input controls to a specific dom element to get the input from.
  40471. * @param element Defines the element the controls should be listened from
  40472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40473. */
  40474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40475. /** @hidden */
  40476. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40477. /**
  40478. * Update the current camera state depending on the inputs that have been used this frame.
  40479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40480. */
  40481. checkInputs(): void;
  40482. /**
  40483. * Detach the current controls from the specified dom element.
  40484. * @param element Defines the element to stop listening the inputs from
  40485. */
  40486. detachControl(element: Nullable<HTMLElement>): void;
  40487. /**
  40488. * Gets the class name of the current intput.
  40489. * @returns the class name
  40490. */
  40491. getClassName(): string;
  40492. /**
  40493. * Get the friendly name associated with the input class.
  40494. * @returns the input friendly name
  40495. */
  40496. getSimpleName(): string;
  40497. }
  40498. }
  40499. declare module BABYLON {
  40500. /**
  40501. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40502. * Screen rotation is taken into account.
  40503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40504. */
  40505. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40506. private _camera;
  40507. private _screenOrientationAngle;
  40508. private _constantTranform;
  40509. private _screenQuaternion;
  40510. private _alpha;
  40511. private _beta;
  40512. private _gamma;
  40513. /**
  40514. * Instantiates a new input
  40515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40516. */
  40517. constructor();
  40518. /**
  40519. * Define the camera controlled by the input.
  40520. */
  40521. camera: FreeCamera;
  40522. /**
  40523. * Attach the input controls to a specific dom element to get the input from.
  40524. * @param element Defines the element the controls should be listened from
  40525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40526. */
  40527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40528. private _orientationChanged;
  40529. private _deviceOrientation;
  40530. /**
  40531. * Detach the current controls from the specified dom element.
  40532. * @param element Defines the element to stop listening the inputs from
  40533. */
  40534. detachControl(element: Nullable<HTMLElement>): void;
  40535. /**
  40536. * Update the current camera state depending on the inputs that have been used this frame.
  40537. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40538. */
  40539. checkInputs(): void;
  40540. /**
  40541. * Gets the class name of the current intput.
  40542. * @returns the class name
  40543. */
  40544. getClassName(): string;
  40545. /**
  40546. * Get the friendly name associated with the input class.
  40547. * @returns the input friendly name
  40548. */
  40549. getSimpleName(): string;
  40550. }
  40551. }
  40552. declare module BABYLON {
  40553. /**
  40554. * Manage the gamepad inputs to control a free camera.
  40555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40556. */
  40557. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40558. /**
  40559. * Define the camera the input is attached to.
  40560. */
  40561. camera: FreeCamera;
  40562. /**
  40563. * Define the Gamepad controlling the input
  40564. */
  40565. gamepad: Nullable<Gamepad>;
  40566. /**
  40567. * Defines the gamepad rotation sensiblity.
  40568. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40569. */
  40570. gamepadAngularSensibility: number;
  40571. /**
  40572. * Defines the gamepad move sensiblity.
  40573. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40574. */
  40575. gamepadMoveSensibility: number;
  40576. private _onGamepadConnectedObserver;
  40577. private _onGamepadDisconnectedObserver;
  40578. private _cameraTransform;
  40579. private _deltaTransform;
  40580. private _vector3;
  40581. private _vector2;
  40582. /**
  40583. * Attach the input controls to a specific dom element to get the input from.
  40584. * @param element Defines the element the controls should be listened from
  40585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40586. */
  40587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40588. /**
  40589. * Detach the current controls from the specified dom element.
  40590. * @param element Defines the element to stop listening the inputs from
  40591. */
  40592. detachControl(element: Nullable<HTMLElement>): void;
  40593. /**
  40594. * Update the current camera state depending on the inputs that have been used this frame.
  40595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40596. */
  40597. checkInputs(): void;
  40598. /**
  40599. * Gets the class name of the current intput.
  40600. * @returns the class name
  40601. */
  40602. getClassName(): string;
  40603. /**
  40604. * Get the friendly name associated with the input class.
  40605. * @returns the input friendly name
  40606. */
  40607. getSimpleName(): string;
  40608. }
  40609. }
  40610. declare module BABYLON {
  40611. /**
  40612. * Manage the keyboard inputs to control the movement of a free camera.
  40613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40614. */
  40615. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  40616. /**
  40617. * Defines the camera the input is attached to.
  40618. */
  40619. camera: FreeCamera;
  40620. /**
  40621. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  40622. */
  40623. keysUp: number[];
  40624. /**
  40625. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  40626. */
  40627. keysDown: number[];
  40628. /**
  40629. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  40630. */
  40631. keysLeft: number[];
  40632. /**
  40633. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  40634. */
  40635. keysRight: number[];
  40636. private _keys;
  40637. private _onCanvasBlurObserver;
  40638. private _onKeyboardObserver;
  40639. private _engine;
  40640. private _scene;
  40641. /**
  40642. * Attach the input controls to a specific dom element to get the input from.
  40643. * @param element Defines the element the controls should be listened from
  40644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40645. */
  40646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40647. /**
  40648. * Detach the current controls from the specified dom element.
  40649. * @param element Defines the element to stop listening the inputs from
  40650. */
  40651. detachControl(element: Nullable<HTMLElement>): void;
  40652. /**
  40653. * Update the current camera state depending on the inputs that have been used this frame.
  40654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40655. */
  40656. checkInputs(): void;
  40657. /**
  40658. * Gets the class name of the current intput.
  40659. * @returns the class name
  40660. */
  40661. getClassName(): string;
  40662. /** @hidden */
  40663. _onLostFocus(e: FocusEvent): void;
  40664. /**
  40665. * Get the friendly name associated with the input class.
  40666. * @returns the input friendly name
  40667. */
  40668. getSimpleName(): string;
  40669. }
  40670. }
  40671. declare module BABYLON {
  40672. /**
  40673. * Manage the mouse inputs to control the movement of a free camera.
  40674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40675. */
  40676. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  40677. /**
  40678. * Define if touch is enabled in the mouse input
  40679. */
  40680. touchEnabled: boolean;
  40681. /**
  40682. * Defines the camera the input is attached to.
  40683. */
  40684. camera: FreeCamera;
  40685. /**
  40686. * Defines the buttons associated with the input to handle camera move.
  40687. */
  40688. buttons: number[];
  40689. /**
  40690. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  40691. */
  40692. angularSensibility: number;
  40693. private _pointerInput;
  40694. private _onMouseMove;
  40695. private _observer;
  40696. private previousPosition;
  40697. /**
  40698. * Manage the mouse inputs to control the movement of a free camera.
  40699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40700. * @param touchEnabled Defines if touch is enabled or not
  40701. */
  40702. constructor(
  40703. /**
  40704. * Define if touch is enabled in the mouse input
  40705. */
  40706. touchEnabled?: boolean);
  40707. /**
  40708. * Attach the input controls to a specific dom element to get the input from.
  40709. * @param element Defines the element the controls should be listened from
  40710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40711. */
  40712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40713. /**
  40714. * Detach the current controls from the specified dom element.
  40715. * @param element Defines the element to stop listening the inputs from
  40716. */
  40717. detachControl(element: Nullable<HTMLElement>): void;
  40718. /**
  40719. * Gets the class name of the current intput.
  40720. * @returns the class name
  40721. */
  40722. getClassName(): string;
  40723. /**
  40724. * Get the friendly name associated with the input class.
  40725. * @returns the input friendly name
  40726. */
  40727. getSimpleName(): string;
  40728. }
  40729. }
  40730. declare module BABYLON {
  40731. /**
  40732. * Manage the touch inputs to control the movement of a free camera.
  40733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40734. */
  40735. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  40736. /**
  40737. * Defines the camera the input is attached to.
  40738. */
  40739. camera: FreeCamera;
  40740. /**
  40741. * Defines the touch sensibility for rotation.
  40742. * The higher the faster.
  40743. */
  40744. touchAngularSensibility: number;
  40745. /**
  40746. * Defines the touch sensibility for move.
  40747. * The higher the faster.
  40748. */
  40749. touchMoveSensibility: number;
  40750. private _offsetX;
  40751. private _offsetY;
  40752. private _pointerPressed;
  40753. private _pointerInput;
  40754. private _observer;
  40755. private _onLostFocus;
  40756. /**
  40757. * Attach the input controls to a specific dom element to get the input from.
  40758. * @param element Defines the element the controls should be listened from
  40759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40760. */
  40761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40762. /**
  40763. * Detach the current controls from the specified dom element.
  40764. * @param element Defines the element to stop listening the inputs from
  40765. */
  40766. detachControl(element: Nullable<HTMLElement>): void;
  40767. /**
  40768. * Update the current camera state depending on the inputs that have been used this frame.
  40769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40770. */
  40771. checkInputs(): void;
  40772. /**
  40773. * Gets the class name of the current intput.
  40774. * @returns the class name
  40775. */
  40776. getClassName(): string;
  40777. /**
  40778. * Get the friendly name associated with the input class.
  40779. * @returns the input friendly name
  40780. */
  40781. getSimpleName(): string;
  40782. }
  40783. }
  40784. declare module BABYLON {
  40785. /**
  40786. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40788. */
  40789. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40790. /**
  40791. * Defines the camera the input is attached to.
  40792. */
  40793. camera: FreeCamera;
  40794. private _leftjoystick;
  40795. private _rightjoystick;
  40796. /**
  40797. * Gets the left stick of the virtual joystick.
  40798. * @returns The virtual Joystick
  40799. */
  40800. getLeftJoystick(): VirtualJoystick;
  40801. /**
  40802. * Gets the right stick of the virtual joystick.
  40803. * @returns The virtual Joystick
  40804. */
  40805. getRightJoystick(): VirtualJoystick;
  40806. /**
  40807. * Update the current camera state depending on the inputs that have been used this frame.
  40808. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40809. */
  40810. checkInputs(): void;
  40811. /**
  40812. * Attach the input controls to a specific dom element to get the input from.
  40813. * @param element Defines the element the controls should be listened from
  40814. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40815. */
  40816. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40817. /**
  40818. * Detach the current controls from the specified dom element.
  40819. * @param element Defines the element to stop listening the inputs from
  40820. */
  40821. detachControl(element: Nullable<HTMLElement>): void;
  40822. /**
  40823. * Gets the class name of the current intput.
  40824. * @returns the class name
  40825. */
  40826. getClassName(): string;
  40827. /**
  40828. * Get the friendly name associated with the input class.
  40829. * @returns the input friendly name
  40830. */
  40831. getSimpleName(): string;
  40832. }
  40833. }
  40834. declare module BABYLON {
  40835. /**
  40836. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40837. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40838. */
  40839. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40840. /**
  40841. * Creates a new AnaglyphArcRotateCamera
  40842. * @param name defines camera name
  40843. * @param alpha defines alpha angle (in radians)
  40844. * @param beta defines beta angle (in radians)
  40845. * @param radius defines radius
  40846. * @param target defines camera target
  40847. * @param interaxialDistance defines distance between each color axis
  40848. * @param scene defines the hosting scene
  40849. */
  40850. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40851. /**
  40852. * Gets camera class name
  40853. * @returns AnaglyphArcRotateCamera
  40854. */
  40855. getClassName(): string;
  40856. }
  40857. }
  40858. declare module BABYLON {
  40859. /**
  40860. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40861. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40862. */
  40863. class AnaglyphFreeCamera extends FreeCamera {
  40864. /**
  40865. * Creates a new AnaglyphFreeCamera
  40866. * @param name defines camera name
  40867. * @param position defines initial position
  40868. * @param interaxialDistance defines distance between each color axis
  40869. * @param scene defines the hosting scene
  40870. */
  40871. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40872. /**
  40873. * Gets camera class name
  40874. * @returns AnaglyphFreeCamera
  40875. */
  40876. getClassName(): string;
  40877. }
  40878. }
  40879. declare module BABYLON {
  40880. /**
  40881. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40882. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40883. */
  40884. class AnaglyphGamepadCamera extends GamepadCamera {
  40885. /**
  40886. * Creates a new AnaglyphGamepadCamera
  40887. * @param name defines camera name
  40888. * @param position defines initial position
  40889. * @param interaxialDistance defines distance between each color axis
  40890. * @param scene defines the hosting scene
  40891. */
  40892. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40893. /**
  40894. * Gets camera class name
  40895. * @returns AnaglyphGamepadCamera
  40896. */
  40897. getClassName(): string;
  40898. }
  40899. }
  40900. declare module BABYLON {
  40901. /**
  40902. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40903. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40904. */
  40905. class AnaglyphUniversalCamera extends UniversalCamera {
  40906. /**
  40907. * Creates a new AnaglyphUniversalCamera
  40908. * @param name defines camera name
  40909. * @param position defines initial position
  40910. * @param interaxialDistance defines distance between each color axis
  40911. * @param scene defines the hosting scene
  40912. */
  40913. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40914. /**
  40915. * Gets camera class name
  40916. * @returns AnaglyphUniversalCamera
  40917. */
  40918. getClassName(): string;
  40919. }
  40920. }
  40921. declare module BABYLON {
  40922. /**
  40923. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40924. * @see http://doc.babylonjs.com/features/cameras
  40925. */
  40926. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40927. /**
  40928. * Creates a new StereoscopicArcRotateCamera
  40929. * @param name defines camera name
  40930. * @param alpha defines alpha angle (in radians)
  40931. * @param beta defines beta angle (in radians)
  40932. * @param radius defines radius
  40933. * @param target defines camera target
  40934. * @param interaxialDistance defines distance between each color axis
  40935. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40936. * @param scene defines the hosting scene
  40937. */
  40938. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40939. /**
  40940. * Gets camera class name
  40941. * @returns StereoscopicArcRotateCamera
  40942. */
  40943. getClassName(): string;
  40944. }
  40945. }
  40946. declare module BABYLON {
  40947. /**
  40948. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40949. * @see http://doc.babylonjs.com/features/cameras
  40950. */
  40951. class StereoscopicFreeCamera extends FreeCamera {
  40952. /**
  40953. * Creates a new StereoscopicFreeCamera
  40954. * @param name defines camera name
  40955. * @param position defines initial position
  40956. * @param interaxialDistance defines distance between each color axis
  40957. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40958. * @param scene defines the hosting scene
  40959. */
  40960. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40961. /**
  40962. * Gets camera class name
  40963. * @returns StereoscopicFreeCamera
  40964. */
  40965. getClassName(): string;
  40966. }
  40967. }
  40968. declare module BABYLON {
  40969. /**
  40970. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40971. * @see http://doc.babylonjs.com/features/cameras
  40972. */
  40973. class StereoscopicGamepadCamera extends GamepadCamera {
  40974. /**
  40975. * Creates a new StereoscopicGamepadCamera
  40976. * @param name defines camera name
  40977. * @param position defines initial position
  40978. * @param interaxialDistance defines distance between each color axis
  40979. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40980. * @param scene defines the hosting scene
  40981. */
  40982. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40983. /**
  40984. * Gets camera class name
  40985. * @returns StereoscopicGamepadCamera
  40986. */
  40987. getClassName(): string;
  40988. }
  40989. }
  40990. declare module BABYLON {
  40991. /**
  40992. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40993. * @see http://doc.babylonjs.com/features/cameras
  40994. */
  40995. class StereoscopicUniversalCamera extends UniversalCamera {
  40996. /**
  40997. * Creates a new StereoscopicUniversalCamera
  40998. * @param name defines camera name
  40999. * @param position defines initial position
  41000. * @param interaxialDistance defines distance between each color axis
  41001. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41002. * @param scene defines the hosting scene
  41003. */
  41004. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41005. /**
  41006. * Gets camera class name
  41007. * @returns StereoscopicUniversalCamera
  41008. */
  41009. getClassName(): string;
  41010. }
  41011. }
  41012. declare module BABYLON {
  41013. /**
  41014. * This represents all the required metrics to create a VR camera.
  41015. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41016. */
  41017. class VRCameraMetrics {
  41018. /**
  41019. * Define the horizontal resolution off the screen.
  41020. */
  41021. hResolution: number;
  41022. /**
  41023. * Define the vertical resolution off the screen.
  41024. */
  41025. vResolution: number;
  41026. /**
  41027. * Define the horizontal screen size.
  41028. */
  41029. hScreenSize: number;
  41030. /**
  41031. * Define the vertical screen size.
  41032. */
  41033. vScreenSize: number;
  41034. /**
  41035. * Define the vertical screen center position.
  41036. */
  41037. vScreenCenter: number;
  41038. /**
  41039. * Define the distance of the eyes to the screen.
  41040. */
  41041. eyeToScreenDistance: number;
  41042. /**
  41043. * Define the distance between both lenses
  41044. */
  41045. lensSeparationDistance: number;
  41046. /**
  41047. * Define the distance between both viewer's eyes.
  41048. */
  41049. interpupillaryDistance: number;
  41050. /**
  41051. * Define the distortion factor of the VR postprocess.
  41052. * Please, touch with care.
  41053. */
  41054. distortionK: number[];
  41055. /**
  41056. * Define the chromatic aberration correction factors for the VR post process.
  41057. */
  41058. chromaAbCorrection: number[];
  41059. /**
  41060. * Define the scale factor of the post process.
  41061. * The smaller the better but the slower.
  41062. */
  41063. postProcessScaleFactor: number;
  41064. /**
  41065. * Define an offset for the lens center.
  41066. */
  41067. lensCenterOffset: number;
  41068. /**
  41069. * Define if the current vr camera should compensate the distortion of the lense or not.
  41070. */
  41071. compensateDistortion: boolean;
  41072. /**
  41073. * Gets the rendering aspect ratio based on the provided resolutions.
  41074. */
  41075. readonly aspectRatio: number;
  41076. /**
  41077. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41078. */
  41079. readonly aspectRatioFov: number;
  41080. /**
  41081. * @hidden
  41082. */
  41083. readonly leftHMatrix: Matrix;
  41084. /**
  41085. * @hidden
  41086. */
  41087. readonly rightHMatrix: Matrix;
  41088. /**
  41089. * @hidden
  41090. */
  41091. readonly leftPreViewMatrix: Matrix;
  41092. /**
  41093. * @hidden
  41094. */
  41095. readonly rightPreViewMatrix: Matrix;
  41096. /**
  41097. * Get the default VRMetrics based on the most generic setup.
  41098. * @returns the default vr metrics
  41099. */
  41100. static GetDefault(): VRCameraMetrics;
  41101. }
  41102. }
  41103. declare module BABYLON {
  41104. /**
  41105. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41106. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41107. */
  41108. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41109. /**
  41110. * Creates a new VRDeviceOrientationArcRotateCamera
  41111. * @param name defines camera name
  41112. * @param alpha defines the camera rotation along the logitudinal axis
  41113. * @param beta defines the camera rotation along the latitudinal axis
  41114. * @param radius defines the camera distance from its target
  41115. * @param target defines the camera target
  41116. * @param scene defines the scene the camera belongs to
  41117. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41118. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41119. */
  41120. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41121. /**
  41122. * Gets camera class name
  41123. * @returns VRDeviceOrientationArcRotateCamera
  41124. */
  41125. getClassName(): string;
  41126. }
  41127. }
  41128. declare module BABYLON {
  41129. /**
  41130. * Camera used to simulate VR rendering (based on FreeCamera)
  41131. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41132. */
  41133. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41134. /**
  41135. * Creates a new VRDeviceOrientationFreeCamera
  41136. * @param name defines camera name
  41137. * @param position defines the start position of the camera
  41138. * @param scene defines the scene the camera belongs to
  41139. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41140. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41141. */
  41142. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41143. /**
  41144. * Gets camera class name
  41145. * @returns VRDeviceOrientationFreeCamera
  41146. */
  41147. getClassName(): string;
  41148. }
  41149. }
  41150. declare module BABYLON {
  41151. /**
  41152. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41153. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41154. */
  41155. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41156. /**
  41157. * Creates a new VRDeviceOrientationGamepadCamera
  41158. * @param name defines camera name
  41159. * @param position defines the start position of the camera
  41160. * @param scene defines the scene the camera belongs to
  41161. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41162. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41163. */
  41164. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41165. /**
  41166. * Gets camera class name
  41167. * @returns VRDeviceOrientationGamepadCamera
  41168. */
  41169. getClassName(): string;
  41170. }
  41171. }
  41172. declare module BABYLON {
  41173. /**
  41174. * Options to modify the vr teleportation behavior.
  41175. */
  41176. interface VRTeleportationOptions {
  41177. /**
  41178. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41179. */
  41180. floorMeshName?: string;
  41181. /**
  41182. * A list of meshes to be used as the teleportation floor. (default: empty)
  41183. */
  41184. floorMeshes?: Mesh[];
  41185. }
  41186. /**
  41187. * Options to modify the vr experience helper's behavior.
  41188. */
  41189. interface VRExperienceHelperOptions extends WebVROptions {
  41190. /**
  41191. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41192. */
  41193. createDeviceOrientationCamera?: boolean;
  41194. /**
  41195. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41196. */
  41197. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41198. /**
  41199. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41200. */
  41201. laserToggle?: boolean;
  41202. /**
  41203. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41204. */
  41205. floorMeshes?: Mesh[];
  41206. }
  41207. /**
  41208. * Helps to quickly add VR support to an existing scene.
  41209. * See http://doc.babylonjs.com/how_to/webvr_helper
  41210. */
  41211. class VRExperienceHelper {
  41212. /** Options to modify the vr experience helper's behavior. */
  41213. webVROptions: VRExperienceHelperOptions;
  41214. private _scene;
  41215. private _position;
  41216. private _btnVR;
  41217. private _btnVRDisplayed;
  41218. private _webVRsupported;
  41219. private _webVRready;
  41220. private _webVRrequesting;
  41221. private _webVRpresenting;
  41222. private _hasEnteredVR;
  41223. private _fullscreenVRpresenting;
  41224. private _canvas;
  41225. private _webVRCamera;
  41226. private _vrDeviceOrientationCamera;
  41227. private _deviceOrientationCamera;
  41228. private _existingCamera;
  41229. private _onKeyDown;
  41230. private _onVrDisplayPresentChange;
  41231. private _onVRDisplayChanged;
  41232. private _onVRRequestPresentStart;
  41233. private _onVRRequestPresentComplete;
  41234. /**
  41235. * Observable raised when entering VR.
  41236. */
  41237. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41238. /**
  41239. * Observable raised when exiting VR.
  41240. */
  41241. onExitingVRObservable: Observable<VRExperienceHelper>;
  41242. /**
  41243. * Observable raised when controller mesh is loaded.
  41244. */
  41245. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41246. /** Return this.onEnteringVRObservable
  41247. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41248. */
  41249. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41250. /** Return this.onExitingVRObservable
  41251. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41252. */
  41253. readonly onExitingVR: Observable<VRExperienceHelper>;
  41254. /** Return this.onControllerMeshLoadedObservable
  41255. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41256. */
  41257. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41258. private _rayLength;
  41259. private _useCustomVRButton;
  41260. private _teleportationRequested;
  41261. private _teleportActive;
  41262. private _floorMeshName;
  41263. private _floorMeshesCollection;
  41264. private _rotationAllowed;
  41265. private _teleportBackwardsVector;
  41266. private _teleportationTarget;
  41267. private _isDefaultTeleportationTarget;
  41268. private _postProcessMove;
  41269. private _teleportationFillColor;
  41270. private _teleportationBorderColor;
  41271. private _rotationAngle;
  41272. private _haloCenter;
  41273. private _cameraGazer;
  41274. private _padSensibilityUp;
  41275. private _padSensibilityDown;
  41276. private _leftController;
  41277. private _rightController;
  41278. /**
  41279. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41280. */
  41281. onNewMeshSelected: Observable<AbstractMesh>;
  41282. /**
  41283. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41284. */
  41285. onNewMeshPicked: Observable<PickingInfo>;
  41286. private _circleEase;
  41287. /**
  41288. * Observable raised before camera teleportation
  41289. */
  41290. onBeforeCameraTeleport: Observable<Vector3>;
  41291. /**
  41292. * Observable raised after camera teleportation
  41293. */
  41294. onAfterCameraTeleport: Observable<Vector3>;
  41295. /**
  41296. * Observable raised when current selected mesh gets unselected
  41297. */
  41298. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41299. private _raySelectionPredicate;
  41300. /**
  41301. * To be optionaly changed by user to define custom ray selection
  41302. */
  41303. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41304. /**
  41305. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41306. */
  41307. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41308. /**
  41309. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41310. */
  41311. teleportationEnabled: boolean;
  41312. private _defaultHeight;
  41313. private _teleportationInitialized;
  41314. private _interactionsEnabled;
  41315. private _interactionsRequested;
  41316. private _displayGaze;
  41317. private _displayLaserPointer;
  41318. /**
  41319. * The mesh used to display where the user is going to teleport.
  41320. */
  41321. /**
  41322. * Sets the mesh to be used to display where the user is going to teleport.
  41323. */
  41324. teleportationTarget: Mesh;
  41325. /**
  41326. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  41327. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41328. * See http://doc.babylonjs.com/resources/baking_transformations
  41329. */
  41330. gazeTrackerMesh: Mesh;
  41331. /**
  41332. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41333. */
  41334. updateGazeTrackerScale: boolean;
  41335. /**
  41336. * The gaze tracking mesh corresponding to the left controller
  41337. */
  41338. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41339. /**
  41340. * The gaze tracking mesh corresponding to the right controller
  41341. */
  41342. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41343. /**
  41344. * If the ray of the gaze should be displayed.
  41345. */
  41346. /**
  41347. * Sets if the ray of the gaze should be displayed.
  41348. */
  41349. displayGaze: boolean;
  41350. /**
  41351. * If the ray of the LaserPointer should be displayed.
  41352. */
  41353. /**
  41354. * Sets if the ray of the LaserPointer should be displayed.
  41355. */
  41356. displayLaserPointer: boolean;
  41357. /**
  41358. * The deviceOrientationCamera used as the camera when not in VR.
  41359. */
  41360. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41361. /**
  41362. * Based on the current WebVR support, returns the current VR camera used.
  41363. */
  41364. readonly currentVRCamera: Nullable<Camera>;
  41365. /**
  41366. * The webVRCamera which is used when in VR.
  41367. */
  41368. readonly webVRCamera: WebVRFreeCamera;
  41369. /**
  41370. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41371. */
  41372. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41373. private readonly _teleportationRequestInitiated;
  41374. /**
  41375. * Instantiates a VRExperienceHelper.
  41376. * Helps to quickly add VR support to an existing scene.
  41377. * @param scene The scene the VRExperienceHelper belongs to.
  41378. * @param webVROptions Options to modify the vr experience helper's behavior.
  41379. */
  41380. constructor(scene: Scene,
  41381. /** Options to modify the vr experience helper's behavior. */
  41382. webVROptions?: VRExperienceHelperOptions);
  41383. private _onDefaultMeshLoaded;
  41384. private _onResize;
  41385. private _onFullscreenChange;
  41386. /**
  41387. * Gets a value indicating if we are currently in VR mode.
  41388. */
  41389. readonly isInVRMode: boolean;
  41390. private onVrDisplayPresentChange;
  41391. private onVRDisplayChanged;
  41392. private moveButtonToBottomRight;
  41393. private displayVRButton;
  41394. private updateButtonVisibility;
  41395. /**
  41396. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41397. * Otherwise, will use the fullscreen API.
  41398. */
  41399. enterVR(): void;
  41400. /**
  41401. * Attempt to exit VR, or fullscreen.
  41402. */
  41403. exitVR(): void;
  41404. /**
  41405. * The position of the vr experience helper.
  41406. */
  41407. /**
  41408. * Sets the position of the vr experience helper.
  41409. */
  41410. position: Vector3;
  41411. /**
  41412. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41413. */
  41414. enableInteractions(): void;
  41415. private readonly _noControllerIsActive;
  41416. private beforeRender;
  41417. private _isTeleportationFloor;
  41418. /**
  41419. * Adds a floor mesh to be used for teleportation.
  41420. * @param floorMesh the mesh to be used for teleportation.
  41421. */
  41422. addFloorMesh(floorMesh: Mesh): void;
  41423. /**
  41424. * Removes a floor mesh from being used for teleportation.
  41425. * @param floorMesh the mesh to be removed.
  41426. */
  41427. removeFloorMesh(floorMesh: Mesh): void;
  41428. /**
  41429. * Enables interactions and teleportation using the VR controllers and gaze.
  41430. * @param vrTeleportationOptions options to modify teleportation behavior.
  41431. */
  41432. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41433. private _onNewGamepadConnected;
  41434. private _tryEnableInteractionOnController;
  41435. private _onNewGamepadDisconnected;
  41436. private _enableInteractionOnController;
  41437. private _checkTeleportWithRay;
  41438. private _checkRotate;
  41439. private _checkTeleportBackwards;
  41440. private _enableTeleportationOnController;
  41441. private _createTeleportationCircles;
  41442. private _displayTeleportationTarget;
  41443. private _hideTeleportationTarget;
  41444. private _rotateCamera;
  41445. private _moveTeleportationSelectorTo;
  41446. private _workingVector;
  41447. private _workingQuaternion;
  41448. private _workingMatrix;
  41449. /**
  41450. * Teleports the users feet to the desired location
  41451. * @param location The location where the user's feet should be placed
  41452. */
  41453. teleportCamera(location: Vector3): void;
  41454. private _convertNormalToDirectionOfRay;
  41455. private _castRayAndSelectObject;
  41456. private _notifySelectedMeshUnselected;
  41457. /**
  41458. * Sets the color of the laser ray from the vr controllers.
  41459. * @param color new color for the ray.
  41460. */
  41461. changeLaserColor(color: Color3): void;
  41462. /**
  41463. * Sets the color of the ray from the vr headsets gaze.
  41464. * @param color new color for the ray.
  41465. */
  41466. changeGazeColor(color: Color3): void;
  41467. /**
  41468. * Exits VR and disposes of the vr experience helper
  41469. */
  41470. dispose(): void;
  41471. /**
  41472. * Gets the name of the VRExperienceHelper class
  41473. * @returns "VRExperienceHelper"
  41474. */
  41475. getClassName(): string;
  41476. }
  41477. }
  41478. declare module BABYLON {
  41479. /**
  41480. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  41481. * IMPORTANT!! The data is right-hand data.
  41482. * @export
  41483. * @interface DevicePose
  41484. */
  41485. interface DevicePose {
  41486. /**
  41487. * The position of the device, values in array are [x,y,z].
  41488. */
  41489. readonly position: Nullable<Float32Array>;
  41490. /**
  41491. * The linearVelocity of the device, values in array are [x,y,z].
  41492. */
  41493. readonly linearVelocity: Nullable<Float32Array>;
  41494. /**
  41495. * The linearAcceleration of the device, values in array are [x,y,z].
  41496. */
  41497. readonly linearAcceleration: Nullable<Float32Array>;
  41498. /**
  41499. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  41500. */
  41501. readonly orientation: Nullable<Float32Array>;
  41502. /**
  41503. * The angularVelocity of the device, values in array are [x,y,z].
  41504. */
  41505. readonly angularVelocity: Nullable<Float32Array>;
  41506. /**
  41507. * The angularAcceleration of the device, values in array are [x,y,z].
  41508. */
  41509. readonly angularAcceleration: Nullable<Float32Array>;
  41510. }
  41511. /**
  41512. * Interface representing a pose controlled object in Babylon.
  41513. * A pose controlled object has both regular pose values as well as pose values
  41514. * from an external device such as a VR head mounted display
  41515. */
  41516. interface PoseControlled {
  41517. /**
  41518. * The position of the object in babylon space.
  41519. */
  41520. position: Vector3;
  41521. /**
  41522. * The rotation quaternion of the object in babylon space.
  41523. */
  41524. rotationQuaternion: Quaternion;
  41525. /**
  41526. * The position of the device in babylon space.
  41527. */
  41528. devicePosition?: Vector3;
  41529. /**
  41530. * The rotation quaternion of the device in babylon space.
  41531. */
  41532. deviceRotationQuaternion: Quaternion;
  41533. /**
  41534. * The raw pose coming from the device.
  41535. */
  41536. rawPose: Nullable<DevicePose>;
  41537. /**
  41538. * The scale of the device to be used when translating from device space to babylon space.
  41539. */
  41540. deviceScaleFactor: number;
  41541. /**
  41542. * Updates the poseControlled values based on the input device pose.
  41543. * @param poseData the pose data to update the object with
  41544. */
  41545. updateFromDevice(poseData: DevicePose): void;
  41546. }
  41547. /**
  41548. * Set of options to customize the webVRCamera
  41549. */
  41550. interface WebVROptions {
  41551. /**
  41552. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  41553. */
  41554. trackPosition?: boolean;
  41555. /**
  41556. * Sets the scale of the vrDevice in babylon space. (default: 1)
  41557. */
  41558. positionScale?: number;
  41559. /**
  41560. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  41561. */
  41562. displayName?: string;
  41563. /**
  41564. * Should the native controller meshes be initialized. (default: true)
  41565. */
  41566. controllerMeshes?: boolean;
  41567. /**
  41568. * Creating a default HemiLight only on controllers. (default: true)
  41569. */
  41570. defaultLightingOnControllers?: boolean;
  41571. /**
  41572. * If you don't want to use the default VR button of the helper. (default: false)
  41573. */
  41574. useCustomVRButton?: boolean;
  41575. /**
  41576. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  41577. */
  41578. customVRButton?: HTMLButtonElement;
  41579. /**
  41580. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  41581. */
  41582. rayLength?: number;
  41583. /**
  41584. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  41585. */
  41586. defaultHeight?: number;
  41587. }
  41588. /**
  41589. * This represents a WebVR camera.
  41590. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  41591. * @example http://doc.babylonjs.com/how_to/webvr_camera
  41592. */
  41593. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  41594. private webVROptions;
  41595. /**
  41596. * @hidden
  41597. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  41598. */
  41599. _vrDevice: any;
  41600. /**
  41601. * The rawPose of the vrDevice.
  41602. */
  41603. rawPose: Nullable<DevicePose>;
  41604. private _onVREnabled;
  41605. private _specsVersion;
  41606. private _attached;
  41607. private _frameData;
  41608. protected _descendants: Array<Node>;
  41609. private _deviceRoomPosition;
  41610. /** @hidden */
  41611. _deviceRoomRotationQuaternion: Quaternion;
  41612. private _standingMatrix;
  41613. /**
  41614. * Represents device position in babylon space.
  41615. */
  41616. devicePosition: Vector3;
  41617. /**
  41618. * Represents device rotation in babylon space.
  41619. */
  41620. deviceRotationQuaternion: Quaternion;
  41621. /**
  41622. * The scale of the device to be used when translating from device space to babylon space.
  41623. */
  41624. deviceScaleFactor: number;
  41625. private _deviceToWorld;
  41626. private _worldToDevice;
  41627. /**
  41628. * References to the webVR controllers for the vrDevice.
  41629. */
  41630. controllers: Array<WebVRController>;
  41631. /**
  41632. * Emits an event when a controller is attached.
  41633. */
  41634. onControllersAttachedObservable: Observable<WebVRController[]>;
  41635. /**
  41636. * Emits an event when a controller's mesh has been loaded;
  41637. */
  41638. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41639. /**
  41640. * Emits an event when the HMD's pose has been updated.
  41641. */
  41642. onPoseUpdatedFromDeviceObservable: Observable<any>;
  41643. private _poseSet;
  41644. /**
  41645. * If the rig cameras be used as parent instead of this camera.
  41646. */
  41647. rigParenting: boolean;
  41648. private _lightOnControllers;
  41649. private _defaultHeight?;
  41650. /**
  41651. * Instantiates a WebVRFreeCamera.
  41652. * @param name The name of the WebVRFreeCamera
  41653. * @param position The starting anchor position for the camera
  41654. * @param scene The scene the camera belongs to
  41655. * @param webVROptions a set of customizable options for the webVRCamera
  41656. */
  41657. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  41658. /**
  41659. * Gets the device distance from the ground in meters.
  41660. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  41661. */
  41662. deviceDistanceToRoomGround(): number;
  41663. /**
  41664. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  41665. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  41666. */
  41667. useStandingMatrix(callback?: (bool: boolean) => void): void;
  41668. /**
  41669. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  41670. * @returns A promise with a boolean set to if the standing matrix is supported.
  41671. */
  41672. useStandingMatrixAsync(): Promise<boolean>;
  41673. /**
  41674. * Disposes the camera
  41675. */
  41676. dispose(): void;
  41677. /**
  41678. * Gets a vrController by name.
  41679. * @param name The name of the controller to retreive
  41680. * @returns the controller matching the name specified or null if not found
  41681. */
  41682. getControllerByName(name: string): Nullable<WebVRController>;
  41683. private _leftController;
  41684. /**
  41685. * The controller corrisponding to the users left hand.
  41686. */
  41687. readonly leftController: Nullable<WebVRController>;
  41688. private _rightController;
  41689. /**
  41690. * The controller corrisponding to the users right hand.
  41691. */
  41692. readonly rightController: Nullable<WebVRController>;
  41693. /**
  41694. * Casts a ray forward from the vrCamera's gaze.
  41695. * @param length Length of the ray (default: 100)
  41696. * @returns the ray corrisponding to the gaze
  41697. */
  41698. getForwardRay(length?: number): Ray;
  41699. /**
  41700. * @hidden
  41701. * Updates the camera based on device's frame data
  41702. */
  41703. _checkInputs(): void;
  41704. /**
  41705. * Updates the poseControlled values based on the input device pose.
  41706. * @param poseData Pose coming from the device
  41707. */
  41708. updateFromDevice(poseData: DevicePose): void;
  41709. private _htmlElementAttached;
  41710. private _detachIfAttached;
  41711. /**
  41712. * WebVR's attach control will start broadcasting frames to the device.
  41713. * Note that in certain browsers (chrome for example) this function must be called
  41714. * within a user-interaction callback. Example:
  41715. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  41716. *
  41717. * @param element html element to attach the vrDevice to
  41718. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  41719. */
  41720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41721. /**
  41722. * Detaches the camera from the html element and disables VR
  41723. *
  41724. * @param element html element to detach from
  41725. */
  41726. detachControl(element: HTMLElement): void;
  41727. /**
  41728. * @returns the name of this class
  41729. */
  41730. getClassName(): string;
  41731. /**
  41732. * Calls resetPose on the vrDisplay
  41733. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  41734. */
  41735. resetToCurrentRotation(): void;
  41736. /**
  41737. * @hidden
  41738. * Updates the rig cameras (left and right eye)
  41739. */
  41740. _updateRigCameras(): void;
  41741. private _workingVector;
  41742. private _oneVector;
  41743. private _workingMatrix;
  41744. private updateCacheCalled;
  41745. private _correctPositionIfNotTrackPosition;
  41746. /**
  41747. * @hidden
  41748. * Updates the cached values of the camera
  41749. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  41750. */
  41751. _updateCache(ignoreParentClass?: boolean): void;
  41752. /**
  41753. * @hidden
  41754. * Get current device position in babylon world
  41755. */
  41756. _computeDevicePosition(): void;
  41757. /**
  41758. * Updates the current device position and rotation in the babylon world
  41759. */
  41760. update(): void;
  41761. /**
  41762. * @hidden
  41763. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  41764. * @returns an identity matrix
  41765. */
  41766. _getViewMatrix(): Matrix;
  41767. private _tmpMatrix;
  41768. /**
  41769. * This function is called by the two RIG cameras.
  41770. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  41771. */
  41772. protected _getWebVRViewMatrix(): Matrix;
  41773. protected _getWebVRProjectionMatrix(): Matrix;
  41774. private _onGamepadConnectedObserver;
  41775. private _onGamepadDisconnectedObserver;
  41776. private _updateCacheWhenTrackingDisabledObserver;
  41777. /**
  41778. * Initializes the controllers and their meshes
  41779. */
  41780. initControllers(): void;
  41781. }
  41782. }
  41783. declare module BABYLON {
  41784. /** @hidden */
  41785. class _OcclusionDataStorage {
  41786. /** @hidden */
  41787. occlusionInternalRetryCounter: number;
  41788. /** @hidden */
  41789. isOcclusionQueryInProgress: boolean;
  41790. /** @hidden */
  41791. isOccluded: boolean;
  41792. /** @hidden */
  41793. occlusionRetryCount: number;
  41794. /** @hidden */
  41795. occlusionType: number;
  41796. /** @hidden */
  41797. occlusionQueryAlgorithmType: number;
  41798. }
  41799. interface Engine {
  41800. /**
  41801. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41802. * @return the new query
  41803. */
  41804. createQuery(): WebGLQuery;
  41805. /**
  41806. * Delete and release a webGL query
  41807. * @param query defines the query to delete
  41808. * @return the current engine
  41809. */
  41810. deleteQuery(query: WebGLQuery): Engine;
  41811. /**
  41812. * Check if a given query has resolved and got its value
  41813. * @param query defines the query to check
  41814. * @returns true if the query got its value
  41815. */
  41816. isQueryResultAvailable(query: WebGLQuery): boolean;
  41817. /**
  41818. * Gets the value of a given query
  41819. * @param query defines the query to check
  41820. * @returns the value of the query
  41821. */
  41822. getQueryResult(query: WebGLQuery): number;
  41823. /**
  41824. * Initiates an occlusion query
  41825. * @param algorithmType defines the algorithm to use
  41826. * @param query defines the query to use
  41827. * @returns the current engine
  41828. * @see http://doc.babylonjs.com/features/occlusionquery
  41829. */
  41830. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41831. /**
  41832. * Ends an occlusion query
  41833. * @see http://doc.babylonjs.com/features/occlusionquery
  41834. * @param algorithmType defines the algorithm to use
  41835. * @returns the current engine
  41836. */
  41837. endOcclusionQuery(algorithmType: number): Engine;
  41838. /**
  41839. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41840. * Please note that only one query can be issued at a time
  41841. * @returns a time token used to track the time span
  41842. */
  41843. startTimeQuery(): Nullable<_TimeToken>;
  41844. /**
  41845. * Ends a time query
  41846. * @param token defines the token used to measure the time span
  41847. * @returns the time spent (in ns)
  41848. */
  41849. endTimeQuery(token: _TimeToken): int;
  41850. /** @hidden */
  41851. _currentNonTimestampToken: Nullable<_TimeToken>;
  41852. /** @hidden */
  41853. _createTimeQuery(): WebGLQuery;
  41854. /** @hidden */
  41855. _deleteTimeQuery(query: WebGLQuery): void;
  41856. /** @hidden */
  41857. _getGlAlgorithmType(algorithmType: number): number;
  41858. /** @hidden */
  41859. _getTimeQueryResult(query: WebGLQuery): any;
  41860. /** @hidden */
  41861. _getTimeQueryAvailability(query: WebGLQuery): any;
  41862. }
  41863. interface AbstractMesh {
  41864. /**
  41865. * Backing filed
  41866. * @hidden
  41867. */
  41868. __occlusionDataStorage: _OcclusionDataStorage;
  41869. /**
  41870. * Access property
  41871. * @hidden
  41872. */
  41873. _occlusionDataStorage: _OcclusionDataStorage;
  41874. /**
  41875. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  41876. * The default value is -1 which means don't break the query and wait till the result
  41877. * @see http://doc.babylonjs.com/features/occlusionquery
  41878. */
  41879. occlusionRetryCount: number;
  41880. /**
  41881. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  41882. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41883. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41884. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  41885. * @see http://doc.babylonjs.com/features/occlusionquery
  41886. */
  41887. occlusionType: number;
  41888. /**
  41889. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41890. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41891. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  41892. * @see http://doc.babylonjs.com/features/occlusionquery
  41893. */
  41894. occlusionQueryAlgorithmType: number;
  41895. /**
  41896. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  41897. * @see http://doc.babylonjs.com/features/occlusionquery
  41898. */
  41899. isOccluded: boolean;
  41900. /**
  41901. * Flag to check the progress status of the query
  41902. * @see http://doc.babylonjs.com/features/occlusionquery
  41903. */
  41904. isOcclusionQueryInProgress: boolean;
  41905. }
  41906. }
  41907. declare module BABYLON {
  41908. interface Engine {
  41909. /**
  41910. * Creates a webGL transform feedback object
  41911. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41912. * @returns the webGL transform feedback object
  41913. */
  41914. createTransformFeedback(): WebGLTransformFeedback;
  41915. /**
  41916. * Delete a webGL transform feedback object
  41917. * @param value defines the webGL transform feedback object to delete
  41918. */
  41919. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41920. /**
  41921. * Bind a webGL transform feedback object to the webgl context
  41922. * @param value defines the webGL transform feedback object to bind
  41923. */
  41924. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41925. /**
  41926. * Begins a transform feedback operation
  41927. * @param usePoints defines if points or triangles must be used
  41928. */
  41929. beginTransformFeedback(usePoints: boolean): void;
  41930. /**
  41931. * Ends a transform feedback operation
  41932. */
  41933. endTransformFeedback(): void;
  41934. /**
  41935. * Specify the varyings to use with transform feedback
  41936. * @param program defines the associated webGL program
  41937. * @param value defines the list of strings representing the varying names
  41938. */
  41939. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41940. /**
  41941. * Bind a webGL buffer for a transform feedback operation
  41942. * @param value defines the webGL buffer to bind
  41943. */
  41944. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41945. }
  41946. }
  41947. declare module BABYLON {
  41948. /**
  41949. * Contains an array of blocks representing the octree
  41950. */
  41951. interface IOctreeContainer<T> {
  41952. /**
  41953. * Blocks within the octree
  41954. */
  41955. blocks: Array<OctreeBlock<T>>;
  41956. }
  41957. /**
  41958. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41959. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41960. */
  41961. class Octree<T> {
  41962. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  41963. maxDepth: number;
  41964. /**
  41965. * Blocks within the octree containing objects
  41966. */
  41967. blocks: Array<OctreeBlock<T>>;
  41968. /**
  41969. * Content stored in the octree
  41970. */
  41971. dynamicContent: T[];
  41972. private _maxBlockCapacity;
  41973. private _selectionContent;
  41974. private _creationFunc;
  41975. /**
  41976. * Creates a octree
  41977. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41978. * @param creationFunc function to be used to instatiate the octree
  41979. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41980. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  41981. */
  41982. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41983. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  41984. maxDepth?: number);
  41985. /**
  41986. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41987. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  41988. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  41989. * @param entries meshes to be added to the octree blocks
  41990. */
  41991. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41992. /**
  41993. * Adds a mesh to the octree
  41994. * @param entry Mesh to add to the octree
  41995. */
  41996. addMesh(entry: T): void;
  41997. /**
  41998. * Selects an array of meshes within the frustum
  41999. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42000. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42001. * @returns array of meshes within the frustum
  42002. */
  42003. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42004. /**
  42005. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42006. * @param sphereCenter defines the bounding sphere center
  42007. * @param sphereRadius defines the bounding sphere radius
  42008. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42009. * @returns an array of objects that intersect the sphere
  42010. */
  42011. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42012. /**
  42013. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42014. * @param ray defines the ray to test with
  42015. * @returns array of intersected objects
  42016. */
  42017. intersectsRay(ray: Ray): SmartArray<T>;
  42018. /**
  42019. * @hidden
  42020. */
  42021. 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;
  42022. /**
  42023. * Adds a mesh into the octree block if it intersects the block
  42024. */
  42025. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42026. /**
  42027. * Adds a submesh into the octree block if it intersects the block
  42028. */
  42029. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42030. }
  42031. }
  42032. declare module BABYLON {
  42033. /**
  42034. * Class used to store a cell in an octree
  42035. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42036. */
  42037. class OctreeBlock<T> {
  42038. /**
  42039. * Gets the content of the current block
  42040. */
  42041. entries: T[];
  42042. /**
  42043. * Gets the list of block children
  42044. */
  42045. blocks: Array<OctreeBlock<T>>;
  42046. private _depth;
  42047. private _maxDepth;
  42048. private _capacity;
  42049. private _minPoint;
  42050. private _maxPoint;
  42051. private _boundingVectors;
  42052. private _creationFunc;
  42053. /**
  42054. * Creates a new block
  42055. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42056. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42057. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42058. * @param depth defines the current depth of this block in the octree
  42059. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42060. * @param creationFunc defines a callback to call when an element is added to the block
  42061. */
  42062. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42063. /**
  42064. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42065. */
  42066. readonly capacity: number;
  42067. /**
  42068. * Gets the minimum vector (in world space) of the block's bounding box
  42069. */
  42070. readonly minPoint: Vector3;
  42071. /**
  42072. * Gets the maximum vector (in world space) of the block's bounding box
  42073. */
  42074. readonly maxPoint: Vector3;
  42075. /**
  42076. * Add a new element to this block
  42077. * @param entry defines the element to add
  42078. */
  42079. addEntry(entry: T): void;
  42080. /**
  42081. * Add an array of elements to this block
  42082. * @param entries defines the array of elements to add
  42083. */
  42084. addEntries(entries: T[]): void;
  42085. /**
  42086. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42087. * @param frustumPlanes defines the frustum planes to test
  42088. * @param selection defines the array to store current content if selection is positive
  42089. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42090. */
  42091. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42092. /**
  42093. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42094. * @param sphereCenter defines the bounding sphere center
  42095. * @param sphereRadius defines the bounding sphere radius
  42096. * @param selection defines the array to store current content if selection is positive
  42097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42098. */
  42099. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42100. /**
  42101. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42102. * @param ray defines the ray to test with
  42103. * @param selection defines the array to store current content if selection is positive
  42104. */
  42105. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42106. /**
  42107. * Subdivide the content into child blocks (this block will then be empty)
  42108. */
  42109. createInnerBlocks(): void;
  42110. }
  42111. }
  42112. declare module BABYLON {
  42113. interface Scene {
  42114. /**
  42115. * @hidden
  42116. * Backing Filed
  42117. */
  42118. _selectionOctree: Octree<AbstractMesh>;
  42119. /**
  42120. * Gets the octree used to boost mesh selection (picking)
  42121. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42122. */
  42123. selectionOctree: Octree<AbstractMesh>;
  42124. /**
  42125. * Creates or updates the octree used to boost selection (picking)
  42126. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42127. * @param maxCapacity defines the maximum capacity per leaf
  42128. * @param maxDepth defines the maximum depth of the octree
  42129. * @returns an octree of AbstractMesh
  42130. */
  42131. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42132. }
  42133. interface AbstractMesh {
  42134. /**
  42135. * @hidden
  42136. * Backing Field
  42137. */
  42138. _submeshesOctree: Octree<SubMesh>;
  42139. /**
  42140. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42141. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42142. * @param maxCapacity defines the maximum size of each block (64 by default)
  42143. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42144. * @returns the new octree
  42145. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42146. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42147. */
  42148. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42149. }
  42150. /**
  42151. * Defines the octree scene component responsible to manage any octrees
  42152. * in a given scene.
  42153. */
  42154. class OctreeSceneComponent {
  42155. /**
  42156. * The component name helpfull to identify the component in the list of scene components.
  42157. */
  42158. readonly name: string;
  42159. /**
  42160. * The scene the component belongs to.
  42161. */
  42162. scene: Scene;
  42163. /**
  42164. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42165. */
  42166. readonly checksIsEnabled: boolean;
  42167. /**
  42168. * Creates a new instance of the component for the given scene
  42169. * @param scene Defines the scene to register the component in
  42170. */
  42171. constructor(scene: Scene);
  42172. /**
  42173. * Registers the component in a given scene
  42174. */
  42175. register(): void;
  42176. /**
  42177. * Return the list of active meshes
  42178. * @returns the list of active meshes
  42179. */
  42180. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42181. /**
  42182. * Return the list of active sub meshes
  42183. * @param mesh The mesh to get the candidates sub meshes from
  42184. * @returns the list of active sub meshes
  42185. */
  42186. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42187. private _tempRay;
  42188. /**
  42189. * Return the list of sub meshes intersecting with a given local ray
  42190. * @param mesh defines the mesh to find the submesh for
  42191. * @param localRay defines the ray in local space
  42192. * @returns the list of intersecting sub meshes
  42193. */
  42194. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42195. /**
  42196. * Return the list of sub meshes colliding with a collider
  42197. * @param mesh defines the mesh to find the submesh for
  42198. * @param collider defines the collider to evaluate the collision against
  42199. * @returns the list of colliding sub meshes
  42200. */
  42201. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42202. /**
  42203. * Rebuilds the elements related to this component in case of
  42204. * context lost for instance.
  42205. */
  42206. rebuild(): void;
  42207. /**
  42208. * Disposes the component and the associated ressources.
  42209. */
  42210. dispose(): void;
  42211. }
  42212. }
  42213. declare module BABYLON {
  42214. /**
  42215. * Google Daydream controller
  42216. */
  42217. class DaydreamController extends WebVRController {
  42218. /**
  42219. * Base Url for the controller model.
  42220. */
  42221. static MODEL_BASE_URL: string;
  42222. /**
  42223. * File name for the controller model.
  42224. */
  42225. static MODEL_FILENAME: string;
  42226. /**
  42227. * Gamepad Id prefix used to identify Daydream Controller.
  42228. */
  42229. static readonly GAMEPAD_ID_PREFIX: string;
  42230. /**
  42231. * Creates a new DaydreamController from a gamepad
  42232. * @param vrGamepad the gamepad that the controller should be created from
  42233. */
  42234. constructor(vrGamepad: any);
  42235. /**
  42236. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42237. * @param scene scene in which to add meshes
  42238. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42239. */
  42240. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42241. /**
  42242. * Called once for each button that changed state since the last frame
  42243. * @param buttonIdx Which button index changed
  42244. * @param state New state of the button
  42245. * @param changes Which properties on the state changed since last frame
  42246. */
  42247. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42248. }
  42249. }
  42250. declare module BABYLON {
  42251. /**
  42252. * Gear VR Controller
  42253. */
  42254. class GearVRController extends WebVRController {
  42255. /**
  42256. * Base Url for the controller model.
  42257. */
  42258. static MODEL_BASE_URL: string;
  42259. /**
  42260. * File name for the controller model.
  42261. */
  42262. static MODEL_FILENAME: string;
  42263. /**
  42264. * Gamepad Id prefix used to identify this controller.
  42265. */
  42266. static readonly GAMEPAD_ID_PREFIX: string;
  42267. private readonly _buttonIndexToObservableNameMap;
  42268. /**
  42269. * Creates a new GearVRController from a gamepad
  42270. * @param vrGamepad the gamepad that the controller should be created from
  42271. */
  42272. constructor(vrGamepad: any);
  42273. /**
  42274. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42275. * @param scene scene in which to add meshes
  42276. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42277. */
  42278. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42279. /**
  42280. * Called once for each button that changed state since the last frame
  42281. * @param buttonIdx Which button index changed
  42282. * @param state New state of the button
  42283. * @param changes Which properties on the state changed since last frame
  42284. */
  42285. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42286. }
  42287. }
  42288. declare module BABYLON {
  42289. /**
  42290. * Generic Controller
  42291. */
  42292. class GenericController extends WebVRController {
  42293. /**
  42294. * Base Url for the controller model.
  42295. */
  42296. static readonly MODEL_BASE_URL: string;
  42297. /**
  42298. * File name for the controller model.
  42299. */
  42300. static readonly MODEL_FILENAME: string;
  42301. /**
  42302. * Creates a new GenericController from a gamepad
  42303. * @param vrGamepad the gamepad that the controller should be created from
  42304. */
  42305. constructor(vrGamepad: any);
  42306. /**
  42307. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42308. * @param scene scene in which to add meshes
  42309. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42310. */
  42311. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42312. /**
  42313. * Called once for each button that changed state since the last frame
  42314. * @param buttonIdx Which button index changed
  42315. * @param state New state of the button
  42316. * @param changes Which properties on the state changed since last frame
  42317. */
  42318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42319. }
  42320. }
  42321. declare module BABYLON {
  42322. /**
  42323. * Oculus Touch Controller
  42324. */
  42325. class OculusTouchController extends WebVRController {
  42326. /**
  42327. * Base Url for the controller model.
  42328. */
  42329. static MODEL_BASE_URL: string;
  42330. /**
  42331. * File name for the left controller model.
  42332. */
  42333. static MODEL_LEFT_FILENAME: string;
  42334. /**
  42335. * File name for the right controller model.
  42336. */
  42337. static MODEL_RIGHT_FILENAME: string;
  42338. /**
  42339. * Fired when the secondary trigger on this controller is modified
  42340. */
  42341. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42342. /**
  42343. * Fired when the thumb rest on this controller is modified
  42344. */
  42345. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42346. /**
  42347. * Creates a new OculusTouchController from a gamepad
  42348. * @param vrGamepad the gamepad that the controller should be created from
  42349. */
  42350. constructor(vrGamepad: any);
  42351. /**
  42352. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42353. * @param scene scene in which to add meshes
  42354. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42355. */
  42356. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42357. /**
  42358. * Fired when the A button on this controller is modified
  42359. */
  42360. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42361. /**
  42362. * Fired when the B button on this controller is modified
  42363. */
  42364. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42365. /**
  42366. * Fired when the X button on this controller is modified
  42367. */
  42368. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42369. /**
  42370. * Fired when the Y button on this controller is modified
  42371. */
  42372. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42373. /**
  42374. * Called once for each button that changed state since the last frame
  42375. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42376. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42377. * 2) secondary trigger (same)
  42378. * 3) A (right) X (left), touch, pressed = value
  42379. * 4) B / Y
  42380. * 5) thumb rest
  42381. * @param buttonIdx Which button index changed
  42382. * @param state New state of the button
  42383. * @param changes Which properties on the state changed since last frame
  42384. */
  42385. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42386. }
  42387. }
  42388. declare module BABYLON {
  42389. /**
  42390. * Defines the types of pose enabled controllers that are supported
  42391. */
  42392. enum PoseEnabledControllerType {
  42393. /**
  42394. * HTC Vive
  42395. */
  42396. VIVE = 0,
  42397. /**
  42398. * Oculus Rift
  42399. */
  42400. OCULUS = 1,
  42401. /**
  42402. * Windows mixed reality
  42403. */
  42404. WINDOWS = 2,
  42405. /**
  42406. * Samsung gear VR
  42407. */
  42408. GEAR_VR = 3,
  42409. /**
  42410. * Google Daydream
  42411. */
  42412. DAYDREAM = 4,
  42413. /**
  42414. * Generic
  42415. */
  42416. GENERIC = 5
  42417. }
  42418. /**
  42419. * Defines the MutableGamepadButton interface for the state of a gamepad button
  42420. */
  42421. interface MutableGamepadButton {
  42422. /**
  42423. * Value of the button/trigger
  42424. */
  42425. value: number;
  42426. /**
  42427. * If the button/trigger is currently touched
  42428. */
  42429. touched: boolean;
  42430. /**
  42431. * If the button/trigger is currently pressed
  42432. */
  42433. pressed: boolean;
  42434. }
  42435. /**
  42436. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  42437. * @hidden
  42438. */
  42439. interface ExtendedGamepadButton extends GamepadButton {
  42440. /**
  42441. * If the button/trigger is currently pressed
  42442. */
  42443. readonly pressed: boolean;
  42444. /**
  42445. * If the button/trigger is currently touched
  42446. */
  42447. readonly touched: boolean;
  42448. /**
  42449. * Value of the button/trigger
  42450. */
  42451. readonly value: number;
  42452. }
  42453. /**
  42454. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  42455. */
  42456. class PoseEnabledControllerHelper {
  42457. /**
  42458. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  42459. * @param vrGamepad the gamepad to initialized
  42460. * @returns a vr controller of the type the gamepad identified as
  42461. */
  42462. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  42463. }
  42464. /**
  42465. * Defines the PoseEnabledController object that contains state of a vr capable controller
  42466. */
  42467. class PoseEnabledController extends Gamepad implements PoseControlled {
  42468. private _deviceRoomPosition;
  42469. private _deviceRoomRotationQuaternion;
  42470. /**
  42471. * The device position in babylon space
  42472. */
  42473. devicePosition: Vector3;
  42474. /**
  42475. * The device rotation in babylon space
  42476. */
  42477. deviceRotationQuaternion: Quaternion;
  42478. /**
  42479. * The scale factor of the device in babylon space
  42480. */
  42481. deviceScaleFactor: number;
  42482. /**
  42483. * (Likely devicePosition should be used instead) The device position in its room space
  42484. */
  42485. position: Vector3;
  42486. /**
  42487. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  42488. */
  42489. rotationQuaternion: Quaternion;
  42490. /**
  42491. * The type of controller (Eg. Windows mixed reality)
  42492. */
  42493. controllerType: PoseEnabledControllerType;
  42494. protected _calculatedPosition: Vector3;
  42495. private _calculatedRotation;
  42496. /**
  42497. * The raw pose from the device
  42498. */
  42499. rawPose: DevicePose;
  42500. private _trackPosition;
  42501. private _maxRotationDistFromHeadset;
  42502. private _draggedRoomRotation;
  42503. /**
  42504. * @hidden
  42505. */
  42506. _disableTrackPosition(fixedPosition: Vector3): void;
  42507. /**
  42508. * Internal, the mesh attached to the controller
  42509. * @hidden
  42510. */
  42511. _mesh: Nullable<AbstractMesh>;
  42512. private _poseControlledCamera;
  42513. private _leftHandSystemQuaternion;
  42514. /**
  42515. * Internal, matrix used to convert room space to babylon space
  42516. * @hidden
  42517. */
  42518. _deviceToWorld: Matrix;
  42519. /**
  42520. * Node to be used when casting a ray from the controller
  42521. * @hidden
  42522. */
  42523. _pointingPoseNode: Nullable<AbstractMesh>;
  42524. /**
  42525. * Name of the child mesh that can be used to cast a ray from the controller
  42526. */
  42527. static readonly POINTING_POSE: string;
  42528. /**
  42529. * Creates a new PoseEnabledController from a gamepad
  42530. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  42531. */
  42532. constructor(browserGamepad: any);
  42533. private _workingMatrix;
  42534. /**
  42535. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  42536. */
  42537. update(): void;
  42538. /**
  42539. * Updates only the pose device and mesh without doing any button event checking
  42540. */
  42541. protected _updatePoseAndMesh(): void;
  42542. /**
  42543. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  42544. * @param poseData raw pose fromthe device
  42545. */
  42546. updateFromDevice(poseData: DevicePose): void;
  42547. /**
  42548. * @hidden
  42549. */
  42550. _meshAttachedObservable: Observable<AbstractMesh>;
  42551. /**
  42552. * Attaches a mesh to the controller
  42553. * @param mesh the mesh to be attached
  42554. */
  42555. attachToMesh(mesh: AbstractMesh): void;
  42556. /**
  42557. * Attaches the controllers mesh to a camera
  42558. * @param camera the camera the mesh should be attached to
  42559. */
  42560. attachToPoseControlledCamera(camera: TargetCamera): void;
  42561. /**
  42562. * Disposes of the controller
  42563. */
  42564. dispose(): void;
  42565. /**
  42566. * The mesh that is attached to the controller
  42567. */
  42568. readonly mesh: Nullable<AbstractMesh>;
  42569. /**
  42570. * Gets the ray of the controller in the direction the controller is pointing
  42571. * @param length the length the resulting ray should be
  42572. * @returns a ray in the direction the controller is pointing
  42573. */
  42574. getForwardRay(length?: number): Ray;
  42575. }
  42576. }
  42577. declare module BABYLON {
  42578. /**
  42579. * Vive Controller
  42580. */
  42581. class ViveController extends WebVRController {
  42582. /**
  42583. * Base Url for the controller model.
  42584. */
  42585. static MODEL_BASE_URL: string;
  42586. /**
  42587. * File name for the controller model.
  42588. */
  42589. static MODEL_FILENAME: string;
  42590. /**
  42591. * Creates a new ViveController from a gamepad
  42592. * @param vrGamepad the gamepad that the controller should be created from
  42593. */
  42594. constructor(vrGamepad: any);
  42595. /**
  42596. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42597. * @param scene scene in which to add meshes
  42598. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42599. */
  42600. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42601. /**
  42602. * Fired when the left button on this controller is modified
  42603. */
  42604. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42605. /**
  42606. * Fired when the right button on this controller is modified
  42607. */
  42608. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42609. /**
  42610. * Fired when the menu button on this controller is modified
  42611. */
  42612. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42613. /**
  42614. * Called once for each button that changed state since the last frame
  42615. * Vive mapping:
  42616. * 0: touchpad
  42617. * 1: trigger
  42618. * 2: left AND right buttons
  42619. * 3: menu button
  42620. * @param buttonIdx Which button index changed
  42621. * @param state New state of the button
  42622. * @param changes Which properties on the state changed since last frame
  42623. */
  42624. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42625. }
  42626. }
  42627. declare module BABYLON {
  42628. /**
  42629. * Defines the WebVRController object that represents controllers tracked in 3D space
  42630. */
  42631. abstract class WebVRController extends PoseEnabledController {
  42632. /**
  42633. * Internal, the default controller model for the controller
  42634. */
  42635. protected _defaultModel: AbstractMesh;
  42636. /**
  42637. * Fired when the trigger state has changed
  42638. */
  42639. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42640. /**
  42641. * Fired when the main button state has changed
  42642. */
  42643. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42644. /**
  42645. * Fired when the secondary button state has changed
  42646. */
  42647. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42648. /**
  42649. * Fired when the pad state has changed
  42650. */
  42651. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  42652. /**
  42653. * Fired when controllers stick values have changed
  42654. */
  42655. onPadValuesChangedObservable: Observable<StickValues>;
  42656. /**
  42657. * Array of button availible on the controller
  42658. */
  42659. protected _buttons: Array<MutableGamepadButton>;
  42660. private _onButtonStateChange;
  42661. /**
  42662. * Fired when a controller button's state has changed
  42663. * @param callback the callback containing the button that was modified
  42664. */
  42665. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  42666. /**
  42667. * X and Y axis corrisponding to the controllers joystick
  42668. */
  42669. pad: StickValues;
  42670. /**
  42671. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  42672. */
  42673. hand: string;
  42674. /**
  42675. * The default controller model for the controller
  42676. */
  42677. readonly defaultModel: AbstractMesh;
  42678. /**
  42679. * Creates a new WebVRController from a gamepad
  42680. * @param vrGamepad the gamepad that the WebVRController should be created from
  42681. */
  42682. constructor(vrGamepad: any);
  42683. /**
  42684. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  42685. */
  42686. update(): void;
  42687. /**
  42688. * Function to be called when a button is modified
  42689. */
  42690. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42691. /**
  42692. * Loads a mesh and attaches it to the controller
  42693. * @param scene the scene the mesh should be added to
  42694. * @param meshLoaded callback for when the mesh has been loaded
  42695. */
  42696. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42697. private _setButtonValue;
  42698. private _changes;
  42699. private _checkChanges;
  42700. /**
  42701. * Disposes of th webVRCOntroller
  42702. */
  42703. dispose(): void;
  42704. }
  42705. }
  42706. declare module BABYLON {
  42707. /**
  42708. * Defines the WindowsMotionController object that the state of the windows motion controller
  42709. */
  42710. class WindowsMotionController extends WebVRController {
  42711. /**
  42712. * The base url used to load the left and right controller models
  42713. */
  42714. static MODEL_BASE_URL: string;
  42715. /**
  42716. * The name of the left controller model file
  42717. */
  42718. static MODEL_LEFT_FILENAME: string;
  42719. /**
  42720. * The name of the right controller model file
  42721. */
  42722. static MODEL_RIGHT_FILENAME: string;
  42723. /**
  42724. * The controller name prefix for this controller type
  42725. */
  42726. static readonly GAMEPAD_ID_PREFIX: string;
  42727. /**
  42728. * The controller id pattern for this controller type
  42729. */
  42730. private static readonly GAMEPAD_ID_PATTERN;
  42731. private _loadedMeshInfo;
  42732. private readonly _mapping;
  42733. /**
  42734. * Fired when the trackpad on this controller is clicked
  42735. */
  42736. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42737. /**
  42738. * Fired when the trackpad on this controller is modified
  42739. */
  42740. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42741. /**
  42742. * The current x and y values of this controller's trackpad
  42743. */
  42744. trackpad: StickValues;
  42745. /**
  42746. * Creates a new WindowsMotionController from a gamepad
  42747. * @param vrGamepad the gamepad that the controller should be created from
  42748. */
  42749. constructor(vrGamepad: any);
  42750. /**
  42751. * Fired when the trigger on this controller is modified
  42752. */
  42753. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42754. /**
  42755. * Fired when the menu button on this controller is modified
  42756. */
  42757. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42758. /**
  42759. * Fired when the grip button on this controller is modified
  42760. */
  42761. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42762. /**
  42763. * Fired when the thumbstick button on this controller is modified
  42764. */
  42765. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42766. /**
  42767. * Fired when the touchpad button on this controller is modified
  42768. */
  42769. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42770. /**
  42771. * Fired when the touchpad values on this controller are modified
  42772. */
  42773. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42774. private _updateTrackpad;
  42775. /**
  42776. * Called once per frame by the engine.
  42777. */
  42778. update(): void;
  42779. /**
  42780. * Called once for each button that changed state since the last frame
  42781. * @param buttonIdx Which button index changed
  42782. * @param state New state of the button
  42783. * @param changes Which properties on the state changed since last frame
  42784. */
  42785. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42786. /**
  42787. * Moves the buttons on the controller mesh based on their current state
  42788. * @param buttonName the name of the button to move
  42789. * @param buttonValue the value of the button which determines the buttons new position
  42790. */
  42791. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42792. /**
  42793. * Moves the axis on the controller mesh based on its current state
  42794. * @param axis the index of the axis
  42795. * @param axisValue the value of the axis which determines the meshes new position
  42796. * @hidden
  42797. */
  42798. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42799. /**
  42800. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42801. * @param scene scene in which to add meshes
  42802. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42803. */
  42804. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42805. /**
  42806. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42807. * can be transformed by button presses and axes values, based on this._mapping.
  42808. *
  42809. * @param scene scene in which the meshes exist
  42810. * @param meshes list of meshes that make up the controller model to process
  42811. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42812. */
  42813. private processModel;
  42814. private createMeshInfo;
  42815. /**
  42816. * Gets the ray of the controller in the direction the controller is pointing
  42817. * @param length the length the resulting ray should be
  42818. * @returns a ray in the direction the controller is pointing
  42819. */
  42820. getForwardRay(length?: number): Ray;
  42821. /**
  42822. * Disposes of the controller
  42823. */
  42824. dispose(): void;
  42825. }
  42826. }
  42827. declare module BABYLON {
  42828. /**
  42829. * Interface to implement to create a shadow generator compatible with BJS.
  42830. */
  42831. interface IShadowGenerator {
  42832. /**
  42833. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  42834. * @returns The render target texture if present otherwise, null
  42835. */
  42836. getShadowMap(): Nullable<RenderTargetTexture>;
  42837. /**
  42838. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  42839. * @returns The render target texture if the shadow map is present otherwise, null
  42840. */
  42841. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  42842. /**
  42843. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  42844. * @param subMesh The submesh we want to render in the shadow map
  42845. * @param useInstances Defines wether will draw in the map using instances
  42846. * @returns true if ready otherwise, false
  42847. */
  42848. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  42849. /**
  42850. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  42851. * @param defines Defines of the material we want to update
  42852. * @param lightIndex Index of the light in the enabled light list of the material
  42853. */
  42854. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  42855. /**
  42856. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  42857. * defined in the generator but impacting the effect).
  42858. * It implies the unifroms available on the materials are the standard BJS ones.
  42859. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  42860. * @param effect The effect we are binfing the information for
  42861. */
  42862. bindShadowLight(lightIndex: string, effect: Effect): void;
  42863. /**
  42864. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  42865. * (eq to shadow prjection matrix * light transform matrix)
  42866. * @returns The transform matrix used to create the shadow map
  42867. */
  42868. getTransformMatrix(): Matrix;
  42869. /**
  42870. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  42871. * Cube and 2D textures for instance.
  42872. */
  42873. recreateShadowMap(): void;
  42874. /**
  42875. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  42876. * @param onCompiled Callback triggered at the and of the effects compilation
  42877. * @param options Sets of optional options forcing the compilation with different modes
  42878. */
  42879. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  42880. useInstances: boolean;
  42881. }>): void;
  42882. /**
  42883. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  42884. * @param options Sets of optional options forcing the compilation with different modes
  42885. * @returns A promise that resolves when the compilation completes
  42886. */
  42887. forceCompilationAsync(options?: Partial<{
  42888. useInstances: boolean;
  42889. }>): Promise<void>;
  42890. /**
  42891. * Serializes the shadow generator setup to a json object.
  42892. * @returns The serialized JSON object
  42893. */
  42894. serialize(): any;
  42895. /**
  42896. * Disposes the Shadow map and related Textures and effects.
  42897. */
  42898. dispose(): void;
  42899. }
  42900. /**
  42901. * Default implementation IShadowGenerator.
  42902. * This is the main object responsible of generating shadows in the framework.
  42903. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  42904. */
  42905. class ShadowGenerator implements IShadowGenerator {
  42906. /**
  42907. * Shadow generator mode None: no filtering applied.
  42908. */
  42909. static readonly FILTER_NONE: number;
  42910. /**
  42911. * Shadow generator mode ESM: Exponential Shadow Mapping.
  42912. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42913. */
  42914. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  42915. /**
  42916. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  42917. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  42918. */
  42919. static readonly FILTER_POISSONSAMPLING: number;
  42920. /**
  42921. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  42922. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42923. */
  42924. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  42925. /**
  42926. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  42927. * edge artifacts on steep falloff.
  42928. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42929. */
  42930. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  42931. /**
  42932. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  42933. * edge artifacts on steep falloff.
  42934. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  42935. */
  42936. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  42937. /**
  42938. * Shadow generator mode PCF: Percentage Closer Filtering
  42939. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  42940. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  42941. */
  42942. static readonly FILTER_PCF: number;
  42943. /**
  42944. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  42945. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  42946. * Contact Hardening
  42947. */
  42948. static readonly FILTER_PCSS: number;
  42949. /**
  42950. * Reserved for PCF and PCSS
  42951. * Highest Quality.
  42952. *
  42953. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  42954. *
  42955. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  42956. */
  42957. static readonly QUALITY_HIGH: number;
  42958. /**
  42959. * Reserved for PCF and PCSS
  42960. * Good tradeoff for quality/perf cross devices
  42961. *
  42962. * Execute PCF on a 3*3 kernel.
  42963. *
  42964. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  42965. */
  42966. static readonly QUALITY_MEDIUM: number;
  42967. /**
  42968. * Reserved for PCF and PCSS
  42969. * The lowest quality but the fastest.
  42970. *
  42971. * Execute PCF on a 1*1 kernel.
  42972. *
  42973. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  42974. */
  42975. static readonly QUALITY_LOW: number;
  42976. private _bias;
  42977. /**
  42978. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  42979. */
  42980. /**
  42981. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  42982. */
  42983. bias: number;
  42984. private _normalBias;
  42985. /**
  42986. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  42987. */
  42988. /**
  42989. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  42990. */
  42991. normalBias: number;
  42992. private _blurBoxOffset;
  42993. /**
  42994. * Gets the blur box offset: offset applied during the blur pass.
  42995. * Only usefull if useKernelBlur = false
  42996. */
  42997. /**
  42998. * Sets the blur box offset: offset applied during the blur pass.
  42999. * Only usefull if useKernelBlur = false
  43000. */
  43001. blurBoxOffset: number;
  43002. private _blurScale;
  43003. /**
  43004. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43005. * 2 means half of the size.
  43006. */
  43007. /**
  43008. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43009. * 2 means half of the size.
  43010. */
  43011. blurScale: number;
  43012. private _blurKernel;
  43013. /**
  43014. * Gets the blur kernel: kernel size of the blur pass.
  43015. * Only usefull if useKernelBlur = true
  43016. */
  43017. /**
  43018. * Sets the blur kernel: kernel size of the blur pass.
  43019. * Only usefull if useKernelBlur = true
  43020. */
  43021. blurKernel: number;
  43022. private _useKernelBlur;
  43023. /**
  43024. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43025. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43026. */
  43027. /**
  43028. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43029. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43030. */
  43031. useKernelBlur: boolean;
  43032. private _depthScale;
  43033. /**
  43034. * Gets the depth scale used in ESM mode.
  43035. */
  43036. /**
  43037. * Sets the depth scale used in ESM mode.
  43038. * This can override the scale stored on the light.
  43039. */
  43040. depthScale: number;
  43041. private _filter;
  43042. /**
  43043. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43044. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43045. */
  43046. /**
  43047. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43048. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43049. */
  43050. filter: number;
  43051. /**
  43052. * Gets if the current filter is set to Poisson Sampling.
  43053. */
  43054. /**
  43055. * Sets the current filter to Poisson Sampling.
  43056. */
  43057. usePoissonSampling: boolean;
  43058. /**
  43059. * Gets if the current filter is set to VSM.
  43060. * DEPRECATED. Should use useExponentialShadowMap instead.
  43061. */
  43062. /**
  43063. * Sets the current filter is to VSM.
  43064. * DEPRECATED. Should use useExponentialShadowMap instead.
  43065. */
  43066. useVarianceShadowMap: boolean;
  43067. /**
  43068. * Gets if the current filter is set to blurred VSM.
  43069. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43070. */
  43071. /**
  43072. * Sets the current filter is to blurred VSM.
  43073. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43074. */
  43075. useBlurVarianceShadowMap: boolean;
  43076. /**
  43077. * Gets if the current filter is set to ESM.
  43078. */
  43079. /**
  43080. * Sets the current filter is to ESM.
  43081. */
  43082. useExponentialShadowMap: boolean;
  43083. /**
  43084. * Gets if the current filter is set to filtered ESM.
  43085. */
  43086. /**
  43087. * Gets if the current filter is set to filtered ESM.
  43088. */
  43089. useBlurExponentialShadowMap: boolean;
  43090. /**
  43091. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43092. * exponential to prevent steep falloff artifacts).
  43093. */
  43094. /**
  43095. * Sets the current filter to "close ESM" (using the inverse of the
  43096. * exponential to prevent steep falloff artifacts).
  43097. */
  43098. useCloseExponentialShadowMap: boolean;
  43099. /**
  43100. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43101. * exponential to prevent steep falloff artifacts).
  43102. */
  43103. /**
  43104. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43105. * exponential to prevent steep falloff artifacts).
  43106. */
  43107. useBlurCloseExponentialShadowMap: boolean;
  43108. /**
  43109. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43110. */
  43111. /**
  43112. * Sets the current filter to "PCF" (percentage closer filtering).
  43113. */
  43114. usePercentageCloserFiltering: boolean;
  43115. private _filteringQuality;
  43116. /**
  43117. * Gets the PCF or PCSS Quality.
  43118. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43119. */
  43120. /**
  43121. * Sets the PCF or PCSS Quality.
  43122. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43123. */
  43124. filteringQuality: number;
  43125. /**
  43126. * Gets if the current filter is set to "PCSS" (contact hardening).
  43127. */
  43128. /**
  43129. * Sets the current filter to "PCSS" (contact hardening).
  43130. */
  43131. useContactHardeningShadow: boolean;
  43132. private _contactHardeningLightSizeUVRatio;
  43133. /**
  43134. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43135. * Using a ratio helps keeping shape stability independently of the map size.
  43136. *
  43137. * It does not account for the light projection as it was having too much
  43138. * instability during the light setup or during light position changes.
  43139. *
  43140. * Only valid if useContactHardeningShadow is true.
  43141. */
  43142. /**
  43143. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43144. * Using a ratio helps keeping shape stability independently of the map size.
  43145. *
  43146. * It does not account for the light projection as it was having too much
  43147. * instability during the light setup or during light position changes.
  43148. *
  43149. * Only valid if useContactHardeningShadow is true.
  43150. */
  43151. contactHardeningLightSizeUVRatio: number;
  43152. private _darkness;
  43153. /**
  43154. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43155. * 0 means strongest and 1 would means no shadow.
  43156. * @returns the darkness.
  43157. */
  43158. getDarkness(): number;
  43159. /**
  43160. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43161. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43162. * @returns the shadow generator allowing fluent coding.
  43163. */
  43164. setDarkness(darkness: number): ShadowGenerator;
  43165. private _transparencyShadow;
  43166. /**
  43167. * Sets the ability to have transparent shadow (boolean).
  43168. * @param transparent True if transparent else False
  43169. * @returns the shadow generator allowing fluent coding
  43170. */
  43171. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  43172. private _shadowMap;
  43173. private _shadowMap2;
  43174. /**
  43175. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43176. * @returns The render target texture if present otherwise, null
  43177. */
  43178. getShadowMap(): Nullable<RenderTargetTexture>;
  43179. /**
  43180. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43181. * @returns The render target texture if the shadow map is present otherwise, null
  43182. */
  43183. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43184. /**
  43185. * Helper function to add a mesh and its descendants to the list of shadow casters.
  43186. * @param mesh Mesh to add
  43187. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  43188. * @returns the Shadow Generator itself
  43189. */
  43190. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43191. /**
  43192. * Helper function to remove a mesh and its descendants from the list of shadow casters
  43193. * @param mesh Mesh to remove
  43194. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  43195. * @returns the Shadow Generator itself
  43196. */
  43197. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43198. /**
  43199. * Controls the extent to which the shadows fade out at the edge of the frustum
  43200. * Used only by directionals and spots
  43201. */
  43202. frustumEdgeFalloff: number;
  43203. private _light;
  43204. /**
  43205. * Returns the associated light object.
  43206. * @returns the light generating the shadow
  43207. */
  43208. getLight(): IShadowLight;
  43209. /**
  43210. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43211. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43212. * It might on the other hand introduce peter panning.
  43213. */
  43214. forceBackFacesOnly: boolean;
  43215. private _scene;
  43216. private _lightDirection;
  43217. private _effect;
  43218. private _viewMatrix;
  43219. private _projectionMatrix;
  43220. private _transformMatrix;
  43221. private _cachedPosition;
  43222. private _cachedDirection;
  43223. private _cachedDefines;
  43224. private _currentRenderID;
  43225. private _boxBlurPostprocess;
  43226. private _kernelBlurXPostprocess;
  43227. private _kernelBlurYPostprocess;
  43228. private _blurPostProcesses;
  43229. private _mapSize;
  43230. private _currentFaceIndex;
  43231. private _currentFaceIndexCache;
  43232. private _textureType;
  43233. private _defaultTextureMatrix;
  43234. /**
  43235. * Creates a ShadowGenerator object.
  43236. * A ShadowGenerator is the required tool to use the shadows.
  43237. * Each light casting shadows needs to use its own ShadowGenerator.
  43238. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  43239. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43240. * @param light The light object generating the shadows.
  43241. * @param useFullFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  43242. */
  43243. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  43244. private _initializeGenerator;
  43245. private _initializeShadowMap;
  43246. private _initializeBlurRTTAndPostProcesses;
  43247. private _renderForShadowMap;
  43248. private _renderSubMeshForShadowMap;
  43249. private _applyFilterValues;
  43250. /**
  43251. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43252. * @param onCompiled Callback triggered at the and of the effects compilation
  43253. * @param options Sets of optional options forcing the compilation with different modes
  43254. */
  43255. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43256. useInstances: boolean;
  43257. }>): void;
  43258. /**
  43259. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43260. * @param options Sets of optional options forcing the compilation with different modes
  43261. * @returns A promise that resolves when the compilation completes
  43262. */
  43263. forceCompilationAsync(options?: Partial<{
  43264. useInstances: boolean;
  43265. }>): Promise<void>;
  43266. /**
  43267. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43268. * @param subMesh The submesh we want to render in the shadow map
  43269. * @param useInstances Defines wether will draw in the map using instances
  43270. * @returns true if ready otherwise, false
  43271. */
  43272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43273. /**
  43274. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43275. * @param defines Defines of the material we want to update
  43276. * @param lightIndex Index of the light in the enabled light list of the material
  43277. */
  43278. prepareDefines(defines: any, lightIndex: number): void;
  43279. /**
  43280. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43281. * defined in the generator but impacting the effect).
  43282. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43283. * @param effect The effect we are binfing the information for
  43284. */
  43285. bindShadowLight(lightIndex: string, effect: Effect): void;
  43286. /**
  43287. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43288. * (eq to shadow prjection matrix * light transform matrix)
  43289. * @returns The transform matrix used to create the shadow map
  43290. */
  43291. getTransformMatrix(): Matrix;
  43292. /**
  43293. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43294. * Cube and 2D textures for instance.
  43295. */
  43296. recreateShadowMap(): void;
  43297. private _disposeBlurPostProcesses;
  43298. private _disposeRTTandPostProcesses;
  43299. /**
  43300. * Disposes the ShadowGenerator.
  43301. * Returns nothing.
  43302. */
  43303. dispose(): void;
  43304. /**
  43305. * Serializes the shadow generator setup to a json object.
  43306. * @returns The serialized JSON object
  43307. */
  43308. serialize(): any;
  43309. /**
  43310. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  43311. * @param parsedShadowGenerator The JSON object to parse
  43312. * @param scene The scene to create the shadow map for
  43313. * @returns The parsed shadow generator
  43314. */
  43315. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  43316. }
  43317. }
  43318. declare module BABYLON {
  43319. /**
  43320. * Defines the shadow generator component responsible to manage any shadow generators
  43321. * in a given scene.
  43322. */
  43323. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43324. /**
  43325. * The component name helpfull to identify the component in the list of scene components.
  43326. */
  43327. readonly name: string;
  43328. /**
  43329. * The scene the component belongs to.
  43330. */
  43331. scene: Scene;
  43332. /**
  43333. * Creates a new instance of the component for the given scene
  43334. * @param scene Defines the scene to register the component in
  43335. */
  43336. constructor(scene: Scene);
  43337. /**
  43338. * Registers the component in a given scene
  43339. */
  43340. register(): void;
  43341. /**
  43342. * Rebuilds the elements related to this component in case of
  43343. * context lost for instance.
  43344. */
  43345. rebuild(): void;
  43346. /**
  43347. * Serializes the component data to the specified json object
  43348. * @param serializationObject The object to serialize to
  43349. */
  43350. serialize(serializationObject: any): void;
  43351. /**
  43352. * Adds all the element from the container to the scene
  43353. * @param container the container holding the elements
  43354. */
  43355. addFromContainer(container: AbstractScene): void;
  43356. /**
  43357. * Removes all the elements in the container from the scene
  43358. * @param container contains the elements to remove
  43359. */
  43360. removeFromContainer(container: AbstractScene): void;
  43361. /**
  43362. * Rebuilds the elements related to this component in case of
  43363. * context lost for instance.
  43364. */
  43365. dispose(): void;
  43366. private _gatherRenderTargets;
  43367. }
  43368. }
  43369. declare module BABYLON {
  43370. }
  43371. declare module BABYLON {
  43372. /**
  43373. * Background material used to create an efficient environement around your scene.
  43374. */
  43375. class BackgroundMaterial extends PushMaterial {
  43376. /**
  43377. * Standard reflectance value at parallel view angle.
  43378. */
  43379. static StandardReflectance0: number;
  43380. /**
  43381. * Standard reflectance value at grazing angle.
  43382. */
  43383. static StandardReflectance90: number;
  43384. protected _primaryColor: Color3;
  43385. /**
  43386. * Key light Color (multiply against the environement texture)
  43387. */
  43388. primaryColor: Color3;
  43389. protected __perceptualColor: Nullable<Color3>;
  43390. /**
  43391. * Experimental Internal Use Only.
  43392. *
  43393. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43394. * This acts as a helper to set the primary color to a more "human friendly" value.
  43395. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43396. * output color as close as possible from the chosen value.
  43397. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43398. * part of lighting setup.)
  43399. */
  43400. _perceptualColor: Nullable<Color3>;
  43401. protected _primaryColorShadowLevel: float;
  43402. /**
  43403. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43404. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43405. */
  43406. primaryColorShadowLevel: float;
  43407. protected _primaryColorHighlightLevel: float;
  43408. /**
  43409. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43410. * The primary color is used at the level chosen to define what the white area would look.
  43411. */
  43412. primaryColorHighlightLevel: float;
  43413. protected _reflectionTexture: Nullable<BaseTexture>;
  43414. /**
  43415. * Reflection Texture used in the material.
  43416. * Should be author in a specific way for the best result (refer to the documentation).
  43417. */
  43418. reflectionTexture: Nullable<BaseTexture>;
  43419. protected _reflectionBlur: float;
  43420. /**
  43421. * Reflection Texture level of blur.
  43422. *
  43423. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43424. * texture twice.
  43425. */
  43426. reflectionBlur: float;
  43427. protected _diffuseTexture: Nullable<BaseTexture>;
  43428. /**
  43429. * Diffuse Texture used in the material.
  43430. * Should be author in a specific way for the best result (refer to the documentation).
  43431. */
  43432. diffuseTexture: Nullable<BaseTexture>;
  43433. protected _shadowLights: Nullable<IShadowLight[]>;
  43434. /**
  43435. * Specify the list of lights casting shadow on the material.
  43436. * All scene shadow lights will be included if null.
  43437. */
  43438. shadowLights: Nullable<IShadowLight[]>;
  43439. protected _shadowLevel: float;
  43440. /**
  43441. * Helps adjusting the shadow to a softer level if required.
  43442. * 0 means black shadows and 1 means no shadows.
  43443. */
  43444. shadowLevel: float;
  43445. protected _sceneCenter: Vector3;
  43446. /**
  43447. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43448. * It is usually zero but might be interesting to modify according to your setup.
  43449. */
  43450. sceneCenter: Vector3;
  43451. protected _opacityFresnel: boolean;
  43452. /**
  43453. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43454. * This helps ensuring a nice transition when the camera goes under the ground.
  43455. */
  43456. opacityFresnel: boolean;
  43457. protected _reflectionFresnel: boolean;
  43458. /**
  43459. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43460. * This helps adding a mirror texture on the ground.
  43461. */
  43462. reflectionFresnel: boolean;
  43463. protected _reflectionFalloffDistance: number;
  43464. /**
  43465. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43466. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43467. */
  43468. reflectionFalloffDistance: number;
  43469. protected _reflectionAmount: number;
  43470. /**
  43471. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43472. */
  43473. reflectionAmount: number;
  43474. protected _reflectionReflectance0: number;
  43475. /**
  43476. * This specifies the weight of the reflection at grazing angle.
  43477. */
  43478. reflectionReflectance0: number;
  43479. protected _reflectionReflectance90: number;
  43480. /**
  43481. * This specifies the weight of the reflection at a perpendicular point of view.
  43482. */
  43483. reflectionReflectance90: number;
  43484. /**
  43485. * Sets the reflection reflectance fresnel values according to the default standard
  43486. * empirically know to work well :-)
  43487. */
  43488. reflectionStandardFresnelWeight: number;
  43489. protected _useRGBColor: boolean;
  43490. /**
  43491. * Helps to directly use the maps channels instead of their level.
  43492. */
  43493. useRGBColor: boolean;
  43494. protected _enableNoise: boolean;
  43495. /**
  43496. * This helps reducing the banding effect that could occur on the background.
  43497. */
  43498. enableNoise: boolean;
  43499. /**
  43500. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43501. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43502. * Recommended to be keep at 1.0 except for special cases.
  43503. */
  43504. fovMultiplier: number;
  43505. private _fovMultiplier;
  43506. /**
  43507. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43508. */
  43509. useEquirectangularFOV: boolean;
  43510. private _maxSimultaneousLights;
  43511. /**
  43512. * Number of Simultaneous lights allowed on the material.
  43513. */
  43514. maxSimultaneousLights: int;
  43515. /**
  43516. * Default configuration related to image processing available in the Background Material.
  43517. */
  43518. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43519. /**
  43520. * Keep track of the image processing observer to allow dispose and replace.
  43521. */
  43522. private _imageProcessingObserver;
  43523. /**
  43524. * Attaches a new image processing configuration to the PBR Material.
  43525. * @param configuration (if null the scene configuration will be use)
  43526. */
  43527. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43528. /**
  43529. * Gets the image processing configuration used either in this material.
  43530. */
  43531. /**
  43532. * Sets the Default image processing configuration used either in the this material.
  43533. *
  43534. * If sets to null, the scene one is in use.
  43535. */
  43536. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43537. /**
  43538. * Gets wether the color curves effect is enabled.
  43539. */
  43540. /**
  43541. * Sets wether the color curves effect is enabled.
  43542. */
  43543. cameraColorCurvesEnabled: boolean;
  43544. /**
  43545. * Gets wether the color grading effect is enabled.
  43546. */
  43547. /**
  43548. * Gets wether the color grading effect is enabled.
  43549. */
  43550. cameraColorGradingEnabled: boolean;
  43551. /**
  43552. * Gets wether tonemapping is enabled or not.
  43553. */
  43554. /**
  43555. * Sets wether tonemapping is enabled or not
  43556. */
  43557. cameraToneMappingEnabled: boolean;
  43558. /**
  43559. * The camera exposure used on this material.
  43560. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43561. * This corresponds to a photographic exposure.
  43562. */
  43563. /**
  43564. * The camera exposure used on this material.
  43565. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43566. * This corresponds to a photographic exposure.
  43567. */
  43568. cameraExposure: float;
  43569. /**
  43570. * Gets The camera contrast used on this material.
  43571. */
  43572. /**
  43573. * Sets The camera contrast used on this material.
  43574. */
  43575. cameraContrast: float;
  43576. /**
  43577. * Gets the Color Grading 2D Lookup Texture.
  43578. */
  43579. /**
  43580. * Sets the Color Grading 2D Lookup Texture.
  43581. */
  43582. cameraColorGradingTexture: Nullable<BaseTexture>;
  43583. /**
  43584. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43585. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43586. * 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;
  43587. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43588. */
  43589. /**
  43590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43592. * 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;
  43593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43594. */
  43595. cameraColorCurves: Nullable<ColorCurves>;
  43596. /**
  43597. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43598. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43599. */
  43600. switchToBGR: boolean;
  43601. private _renderTargets;
  43602. private _reflectionControls;
  43603. private _white;
  43604. private _primaryShadowColor;
  43605. private _primaryHighlightColor;
  43606. /**
  43607. * Instantiates a Background Material in the given scene
  43608. * @param name The friendly name of the material
  43609. * @param scene The scene to add the material to
  43610. */
  43611. constructor(name: string, scene: Scene);
  43612. /**
  43613. * Gets a boolean indicating that current material needs to register RTT
  43614. */
  43615. readonly hasRenderTargetTextures: boolean;
  43616. /**
  43617. * The entire material has been created in order to prevent overdraw.
  43618. * @returns false
  43619. */
  43620. needAlphaTesting(): boolean;
  43621. /**
  43622. * The entire material has been created in order to prevent overdraw.
  43623. * @returns true if blending is enable
  43624. */
  43625. needAlphaBlending(): boolean;
  43626. /**
  43627. * Checks wether the material is ready to be rendered for a given mesh.
  43628. * @param mesh The mesh to render
  43629. * @param subMesh The submesh to check against
  43630. * @param useInstances Specify wether or not the material is used with instances
  43631. * @returns true if all the dependencies are ready (Textures, Effects...)
  43632. */
  43633. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43634. /**
  43635. * Compute the primary color according to the chosen perceptual color.
  43636. */
  43637. private _computePrimaryColorFromPerceptualColor;
  43638. /**
  43639. * Compute the highlights and shadow colors according to their chosen levels.
  43640. */
  43641. private _computePrimaryColors;
  43642. /**
  43643. * Build the uniform buffer used in the material.
  43644. */
  43645. buildUniformLayout(): void;
  43646. /**
  43647. * Unbind the material.
  43648. */
  43649. unbind(): void;
  43650. /**
  43651. * Bind only the world matrix to the material.
  43652. * @param world The world matrix to bind.
  43653. */
  43654. bindOnlyWorldMatrix(world: Matrix): void;
  43655. /**
  43656. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43657. * @param world The world matrix to bind.
  43658. * @param subMesh The submesh to bind for.
  43659. */
  43660. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43661. /**
  43662. * Dispose the material.
  43663. * @param forceDisposeEffect Force disposal of the associated effect.
  43664. * @param forceDisposeTextures Force disposal of the associated textures.
  43665. */
  43666. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43667. /**
  43668. * Clones the material.
  43669. * @param name The cloned name.
  43670. * @returns The cloned material.
  43671. */
  43672. clone(name: string): BackgroundMaterial;
  43673. /**
  43674. * Serializes the current material to its JSON representation.
  43675. * @returns The JSON representation.
  43676. */
  43677. serialize(): any;
  43678. /**
  43679. * Gets the class name of the material
  43680. * @returns "BackgroundMaterial"
  43681. */
  43682. getClassName(): string;
  43683. /**
  43684. * Parse a JSON input to create back a background material.
  43685. * @param source The JSON data to parse
  43686. * @param scene The scene to create the parsed material in
  43687. * @param rootUrl The root url of the assets the material depends upon
  43688. * @returns the instantiated BackgroundMaterial.
  43689. */
  43690. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43691. }
  43692. }
  43693. declare module BABYLON {
  43694. /**
  43695. * The Physically based material base class of BJS.
  43696. *
  43697. * This offers the main features of a standard PBR material.
  43698. * For more information, please refer to the documentation :
  43699. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43700. */
  43701. abstract class PBRBaseMaterial extends PushMaterial {
  43702. /**
  43703. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43704. */
  43705. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43706. /**
  43707. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43708. * to enhance interoperability with other engines.
  43709. */
  43710. static readonly LIGHTFALLOFF_GLTF: number;
  43711. /**
  43712. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43713. * to enhance interoperability with other materials.
  43714. */
  43715. static readonly LIGHTFALLOFF_STANDARD: number;
  43716. /**
  43717. * Intensity of the direct lights e.g. the four lights available in your scene.
  43718. * This impacts both the direct diffuse and specular highlights.
  43719. */
  43720. protected _directIntensity: number;
  43721. /**
  43722. * Intensity of the emissive part of the material.
  43723. * This helps controlling the emissive effect without modifying the emissive color.
  43724. */
  43725. protected _emissiveIntensity: number;
  43726. /**
  43727. * Intensity of the environment e.g. how much the environment will light the object
  43728. * either through harmonics for rough material or through the refelction for shiny ones.
  43729. */
  43730. protected _environmentIntensity: number;
  43731. /**
  43732. * This is a special control allowing the reduction of the specular highlights coming from the
  43733. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43734. */
  43735. protected _specularIntensity: number;
  43736. /**
  43737. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43738. */
  43739. private _lightingInfos;
  43740. /**
  43741. * Debug Control allowing disabling the bump map on this material.
  43742. */
  43743. protected _disableBumpMap: boolean;
  43744. /**
  43745. * AKA Diffuse Texture in standard nomenclature.
  43746. */
  43747. protected _albedoTexture: BaseTexture;
  43748. /**
  43749. * AKA Occlusion Texture in other nomenclature.
  43750. */
  43751. protected _ambientTexture: BaseTexture;
  43752. /**
  43753. * AKA Occlusion Texture Intensity in other nomenclature.
  43754. */
  43755. protected _ambientTextureStrength: number;
  43756. /**
  43757. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43758. * 1 means it completely occludes it
  43759. * 0 mean it has no impact
  43760. */
  43761. protected _ambientTextureImpactOnAnalyticalLights: number;
  43762. /**
  43763. * Stores the alpha values in a texture.
  43764. */
  43765. protected _opacityTexture: BaseTexture;
  43766. /**
  43767. * Stores the reflection values in a texture.
  43768. */
  43769. protected _reflectionTexture: BaseTexture;
  43770. /**
  43771. * Stores the refraction values in a texture.
  43772. */
  43773. protected _refractionTexture: BaseTexture;
  43774. /**
  43775. * Stores the emissive values in a texture.
  43776. */
  43777. protected _emissiveTexture: BaseTexture;
  43778. /**
  43779. * AKA Specular texture in other nomenclature.
  43780. */
  43781. protected _reflectivityTexture: BaseTexture;
  43782. /**
  43783. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43784. */
  43785. protected _metallicTexture: BaseTexture;
  43786. /**
  43787. * Specifies the metallic scalar of the metallic/roughness workflow.
  43788. * Can also be used to scale the metalness values of the metallic texture.
  43789. */
  43790. protected _metallic: Nullable<number>;
  43791. /**
  43792. * Specifies the roughness scalar of the metallic/roughness workflow.
  43793. * Can also be used to scale the roughness values of the metallic texture.
  43794. */
  43795. protected _roughness: Nullable<number>;
  43796. /**
  43797. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43798. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43799. */
  43800. protected _microSurfaceTexture: BaseTexture;
  43801. /**
  43802. * Stores surface normal data used to displace a mesh in a texture.
  43803. */
  43804. protected _bumpTexture: BaseTexture;
  43805. /**
  43806. * Stores the pre-calculated light information of a mesh in a texture.
  43807. */
  43808. protected _lightmapTexture: BaseTexture;
  43809. /**
  43810. * The color of a material in ambient lighting.
  43811. */
  43812. protected _ambientColor: Color3;
  43813. /**
  43814. * AKA Diffuse Color in other nomenclature.
  43815. */
  43816. protected _albedoColor: Color3;
  43817. /**
  43818. * AKA Specular Color in other nomenclature.
  43819. */
  43820. protected _reflectivityColor: Color3;
  43821. /**
  43822. * The color applied when light is reflected from a material.
  43823. */
  43824. protected _reflectionColor: Color3;
  43825. /**
  43826. * The color applied when light is emitted from a material.
  43827. */
  43828. protected _emissiveColor: Color3;
  43829. /**
  43830. * AKA Glossiness in other nomenclature.
  43831. */
  43832. protected _microSurface: number;
  43833. /**
  43834. * source material index of refraction (IOR)' / 'destination material IOR.
  43835. */
  43836. protected _indexOfRefraction: number;
  43837. /**
  43838. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  43839. */
  43840. protected _invertRefractionY: boolean;
  43841. /**
  43842. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43843. * Materials half opaque for instance using refraction could benefit from this control.
  43844. */
  43845. protected _linkRefractionWithTransparency: boolean;
  43846. /**
  43847. * Specifies that the material will use the light map as a show map.
  43848. */
  43849. protected _useLightmapAsShadowmap: boolean;
  43850. /**
  43851. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43852. * makes the reflect vector face the model (under horizon).
  43853. */
  43854. protected _useHorizonOcclusion: boolean;
  43855. /**
  43856. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43857. * too much the area relying on ambient texture to define their ambient occlusion.
  43858. */
  43859. protected _useRadianceOcclusion: boolean;
  43860. /**
  43861. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43862. */
  43863. protected _useAlphaFromAlbedoTexture: boolean;
  43864. /**
  43865. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  43866. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43867. */
  43868. protected _useSpecularOverAlpha: boolean;
  43869. /**
  43870. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43871. */
  43872. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43873. /**
  43874. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43875. */
  43876. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  43877. /**
  43878. * Specifies if the metallic texture contains the roughness information in its green channel.
  43879. */
  43880. protected _useRoughnessFromMetallicTextureGreen: boolean;
  43881. /**
  43882. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43883. */
  43884. protected _useMetallnessFromMetallicTextureBlue: boolean;
  43885. /**
  43886. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43887. */
  43888. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  43889. /**
  43890. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43891. */
  43892. protected _useAmbientInGrayScale: boolean;
  43893. /**
  43894. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43895. * The material will try to infer what glossiness each pixel should be.
  43896. */
  43897. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  43898. /**
  43899. * Defines the falloff type used in this material.
  43900. * It by default is Physical.
  43901. */
  43902. protected _lightFalloff: number;
  43903. /**
  43904. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43905. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43906. */
  43907. protected _useRadianceOverAlpha: boolean;
  43908. /**
  43909. * Allows using an object space normal map (instead of tangent space).
  43910. */
  43911. protected _useObjectSpaceNormalMap: boolean;
  43912. /**
  43913. * Allows using the bump map in parallax mode.
  43914. */
  43915. protected _useParallax: boolean;
  43916. /**
  43917. * Allows using the bump map in parallax occlusion mode.
  43918. */
  43919. protected _useParallaxOcclusion: boolean;
  43920. /**
  43921. * Controls the scale bias of the parallax mode.
  43922. */
  43923. protected _parallaxScaleBias: number;
  43924. /**
  43925. * If sets to true, disables all the lights affecting the material.
  43926. */
  43927. protected _disableLighting: boolean;
  43928. /**
  43929. * Number of Simultaneous lights allowed on the material.
  43930. */
  43931. protected _maxSimultaneousLights: number;
  43932. /**
  43933. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43934. */
  43935. protected _invertNormalMapX: boolean;
  43936. /**
  43937. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43938. */
  43939. protected _invertNormalMapY: boolean;
  43940. /**
  43941. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43942. */
  43943. protected _twoSidedLighting: boolean;
  43944. /**
  43945. * Defines the alpha limits in alpha test mode.
  43946. */
  43947. protected _alphaCutOff: number;
  43948. /**
  43949. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43950. */
  43951. protected _forceAlphaTest: boolean;
  43952. /**
  43953. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43954. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43955. */
  43956. protected _useAlphaFresnel: boolean;
  43957. /**
  43958. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43959. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43960. */
  43961. protected _useLinearAlphaFresnel: boolean;
  43962. /**
  43963. * The transparency mode of the material.
  43964. */
  43965. protected _transparencyMode: Nullable<number>;
  43966. /**
  43967. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  43968. * from cos thetav and roughness:
  43969. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  43970. */
  43971. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  43972. /**
  43973. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43974. */
  43975. protected _forceIrradianceInFragment: boolean;
  43976. /**
  43977. * Force normal to face away from face.
  43978. */
  43979. protected _forceNormalForward: boolean;
  43980. /**
  43981. * Enables specular anti aliasing in the PBR shader.
  43982. * It will both interacts on the Geometry for analytical and IBL lighting.
  43983. * It also prefilter the roughness map based on the bump values.
  43984. */
  43985. protected _enableSpecularAntiAliasing: boolean;
  43986. /**
  43987. * Default configuration related to image processing available in the PBR Material.
  43988. */
  43989. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43990. /**
  43991. * Keep track of the image processing observer to allow dispose and replace.
  43992. */
  43993. private _imageProcessingObserver;
  43994. /**
  43995. * Attaches a new image processing configuration to the PBR Material.
  43996. * @param configuration
  43997. */
  43998. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43999. /**
  44000. * Stores the available render targets.
  44001. */
  44002. private _renderTargets;
  44003. /**
  44004. * Sets the global ambient color for the material used in lighting calculations.
  44005. */
  44006. private _globalAmbientColor;
  44007. /**
  44008. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44009. */
  44010. private _useLogarithmicDepth;
  44011. /**
  44012. * If set to true, no lighting calculations will be applied.
  44013. */
  44014. private _unlit;
  44015. /**
  44016. * Instantiates a new PBRMaterial instance.
  44017. *
  44018. * @param name The material name
  44019. * @param scene The scene the material will be use in.
  44020. */
  44021. constructor(name: string, scene: Scene);
  44022. /**
  44023. * Gets a boolean indicating that current material needs to register RTT
  44024. */
  44025. readonly hasRenderTargetTextures: boolean;
  44026. /**
  44027. * Gets the name of the material class.
  44028. */
  44029. getClassName(): string;
  44030. /**
  44031. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44032. */
  44033. /**
  44034. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44035. */
  44036. useLogarithmicDepth: boolean;
  44037. /**
  44038. * Gets the current transparency mode.
  44039. */
  44040. /**
  44041. * Sets the transparency mode of the material.
  44042. *
  44043. * | Value | Type | Description |
  44044. * | ----- | ----------------------------------- | ----------- |
  44045. * | 0 | OPAQUE | |
  44046. * | 1 | ALPHATEST | |
  44047. * | 2 | ALPHABLEND | |
  44048. * | 3 | ALPHATESTANDBLEND | |
  44049. *
  44050. */
  44051. transparencyMode: Nullable<number>;
  44052. /**
  44053. * Returns true if alpha blending should be disabled.
  44054. */
  44055. private readonly _disableAlphaBlending;
  44056. /**
  44057. * Specifies whether or not this material should be rendered in alpha blend mode.
  44058. */
  44059. needAlphaBlending(): boolean;
  44060. /**
  44061. * Specifies if the mesh will require alpha blending.
  44062. * @param mesh - BJS mesh.
  44063. */
  44064. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44065. /**
  44066. * Specifies whether or not this material should be rendered in alpha test mode.
  44067. */
  44068. needAlphaTesting(): boolean;
  44069. /**
  44070. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44071. */
  44072. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44073. /**
  44074. * Gets the texture used for the alpha test.
  44075. */
  44076. getAlphaTestTexture(): BaseTexture;
  44077. /**
  44078. * Stores the reflectivity values based on metallic roughness workflow.
  44079. */
  44080. private static _scaledReflectivity;
  44081. /**
  44082. * Specifies that the submesh is ready to be used.
  44083. * @param mesh - BJS mesh.
  44084. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44085. * @param useInstances - Specifies that instances should be used.
  44086. * @returns - boolean indicating that the submesh is ready or not.
  44087. */
  44088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44089. /**
  44090. * Specifies if the material uses metallic roughness workflow.
  44091. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44092. */
  44093. isMetallicWorkflow(): boolean;
  44094. private _prepareEffect;
  44095. private _prepareDefines;
  44096. /**
  44097. * Force shader compilation
  44098. */
  44099. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44100. clipPlane: boolean;
  44101. }>): void;
  44102. /**
  44103. * Initializes the uniform buffer layout for the shader.
  44104. */
  44105. buildUniformLayout(): void;
  44106. /**
  44107. * Unbinds the textures.
  44108. */
  44109. unbind(): void;
  44110. /**
  44111. * Binds the submesh data.
  44112. * @param world - The world matrix.
  44113. * @param mesh - The BJS mesh.
  44114. * @param subMesh - A submesh of the BJS mesh.
  44115. */
  44116. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44117. /**
  44118. * Returns the animatable textures.
  44119. * @returns - Array of animatable textures.
  44120. */
  44121. getAnimatables(): IAnimatable[];
  44122. /**
  44123. * Returns the texture used for reflections.
  44124. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44125. */
  44126. private _getReflectionTexture;
  44127. /**
  44128. * Returns the texture used for refraction or null if none is used.
  44129. * @returns - Refection texture if present. If no refraction texture and refraction
  44130. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44131. */
  44132. private _getRefractionTexture;
  44133. /**
  44134. * Disposes the resources of the material.
  44135. * @param forceDisposeEffect - Forces the disposal of effects.
  44136. * @param forceDisposeTextures - Forces the disposal of all textures.
  44137. */
  44138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44139. }
  44140. }
  44141. declare module BABYLON {
  44142. /**
  44143. * The Physically based simple base material of BJS.
  44144. *
  44145. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44146. * It is used as the base class for both the specGloss and metalRough conventions.
  44147. */
  44148. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44149. /**
  44150. * Number of Simultaneous lights allowed on the material.
  44151. */
  44152. maxSimultaneousLights: number;
  44153. /**
  44154. * If sets to true, disables all the lights affecting the material.
  44155. */
  44156. disableLighting: boolean;
  44157. /**
  44158. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44159. */
  44160. environmentTexture: BaseTexture;
  44161. /**
  44162. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44163. */
  44164. invertNormalMapX: boolean;
  44165. /**
  44166. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44167. */
  44168. invertNormalMapY: boolean;
  44169. /**
  44170. * Normal map used in the model.
  44171. */
  44172. normalTexture: BaseTexture;
  44173. /**
  44174. * Emissivie color used to self-illuminate the model.
  44175. */
  44176. emissiveColor: Color3;
  44177. /**
  44178. * Emissivie texture used to self-illuminate the model.
  44179. */
  44180. emissiveTexture: BaseTexture;
  44181. /**
  44182. * Occlusion Channel Strenght.
  44183. */
  44184. occlusionStrength: number;
  44185. /**
  44186. * Occlusion Texture of the material (adding extra occlusion effects).
  44187. */
  44188. occlusionTexture: BaseTexture;
  44189. /**
  44190. * Defines the alpha limits in alpha test mode.
  44191. */
  44192. alphaCutOff: number;
  44193. /**
  44194. * Gets the current double sided mode.
  44195. */
  44196. /**
  44197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44198. */
  44199. doubleSided: boolean;
  44200. /**
  44201. * Stores the pre-calculated light information of a mesh in a texture.
  44202. */
  44203. lightmapTexture: BaseTexture;
  44204. /**
  44205. * If true, the light map contains occlusion information instead of lighting info.
  44206. */
  44207. useLightmapAsShadowmap: boolean;
  44208. /**
  44209. * Return the active textures of the material.
  44210. */
  44211. getActiveTextures(): BaseTexture[];
  44212. hasTexture(texture: BaseTexture): boolean;
  44213. /**
  44214. * Instantiates a new PBRMaterial instance.
  44215. *
  44216. * @param name The material name
  44217. * @param scene The scene the material will be use in.
  44218. */
  44219. constructor(name: string, scene: Scene);
  44220. getClassName(): string;
  44221. }
  44222. }
  44223. declare module BABYLON {
  44224. /**
  44225. * The Physically based material of BJS.
  44226. *
  44227. * This offers the main features of a standard PBR material.
  44228. * For more information, please refer to the documentation :
  44229. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44230. */
  44231. class PBRMaterial extends PBRBaseMaterial {
  44232. /**
  44233. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44234. */
  44235. static readonly PBRMATERIAL_OPAQUE: number;
  44236. /**
  44237. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44238. */
  44239. static readonly PBRMATERIAL_ALPHATEST: number;
  44240. /**
  44241. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44242. */
  44243. static readonly PBRMATERIAL_ALPHABLEND: number;
  44244. /**
  44245. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44246. * They are also discarded below the alpha cutoff threshold to improve performances.
  44247. */
  44248. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44249. /**
  44250. * Defines the default value of how much AO map is occluding the analytical lights
  44251. * (point spot...).
  44252. */
  44253. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44254. /**
  44255. * Intensity of the direct lights e.g. the four lights available in your scene.
  44256. * This impacts both the direct diffuse and specular highlights.
  44257. */
  44258. directIntensity: number;
  44259. /**
  44260. * Intensity of the emissive part of the material.
  44261. * This helps controlling the emissive effect without modifying the emissive color.
  44262. */
  44263. emissiveIntensity: number;
  44264. /**
  44265. * Intensity of the environment e.g. how much the environment will light the object
  44266. * either through harmonics for rough material or through the refelction for shiny ones.
  44267. */
  44268. environmentIntensity: number;
  44269. /**
  44270. * This is a special control allowing the reduction of the specular highlights coming from the
  44271. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44272. */
  44273. specularIntensity: number;
  44274. /**
  44275. * Debug Control allowing disabling the bump map on this material.
  44276. */
  44277. disableBumpMap: boolean;
  44278. /**
  44279. * AKA Diffuse Texture in standard nomenclature.
  44280. */
  44281. albedoTexture: BaseTexture;
  44282. /**
  44283. * AKA Occlusion Texture in other nomenclature.
  44284. */
  44285. ambientTexture: BaseTexture;
  44286. /**
  44287. * AKA Occlusion Texture Intensity in other nomenclature.
  44288. */
  44289. ambientTextureStrength: number;
  44290. /**
  44291. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44292. * 1 means it completely occludes it
  44293. * 0 mean it has no impact
  44294. */
  44295. ambientTextureImpactOnAnalyticalLights: number;
  44296. /**
  44297. * Stores the alpha values in a texture.
  44298. */
  44299. opacityTexture: BaseTexture;
  44300. /**
  44301. * Stores the reflection values in a texture.
  44302. */
  44303. reflectionTexture: Nullable<BaseTexture>;
  44304. /**
  44305. * Stores the emissive values in a texture.
  44306. */
  44307. emissiveTexture: BaseTexture;
  44308. /**
  44309. * AKA Specular texture in other nomenclature.
  44310. */
  44311. reflectivityTexture: BaseTexture;
  44312. /**
  44313. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44314. */
  44315. metallicTexture: BaseTexture;
  44316. /**
  44317. * Specifies the metallic scalar of the metallic/roughness workflow.
  44318. * Can also be used to scale the metalness values of the metallic texture.
  44319. */
  44320. metallic: Nullable<number>;
  44321. /**
  44322. * Specifies the roughness scalar of the metallic/roughness workflow.
  44323. * Can also be used to scale the roughness values of the metallic texture.
  44324. */
  44325. roughness: Nullable<number>;
  44326. /**
  44327. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44328. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44329. */
  44330. microSurfaceTexture: BaseTexture;
  44331. /**
  44332. * Stores surface normal data used to displace a mesh in a texture.
  44333. */
  44334. bumpTexture: BaseTexture;
  44335. /**
  44336. * Stores the pre-calculated light information of a mesh in a texture.
  44337. */
  44338. lightmapTexture: BaseTexture;
  44339. /**
  44340. * Stores the refracted light information in a texture.
  44341. */
  44342. refractionTexture: BaseTexture;
  44343. /**
  44344. * The color of a material in ambient lighting.
  44345. */
  44346. ambientColor: Color3;
  44347. /**
  44348. * AKA Diffuse Color in other nomenclature.
  44349. */
  44350. albedoColor: Color3;
  44351. /**
  44352. * AKA Specular Color in other nomenclature.
  44353. */
  44354. reflectivityColor: Color3;
  44355. /**
  44356. * The color reflected from the material.
  44357. */
  44358. reflectionColor: Color3;
  44359. /**
  44360. * The color emitted from the material.
  44361. */
  44362. emissiveColor: Color3;
  44363. /**
  44364. * AKA Glossiness in other nomenclature.
  44365. */
  44366. microSurface: number;
  44367. /**
  44368. * source material index of refraction (IOR)' / 'destination material IOR.
  44369. */
  44370. indexOfRefraction: number;
  44371. /**
  44372. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44373. */
  44374. invertRefractionY: boolean;
  44375. /**
  44376. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44377. * Materials half opaque for instance using refraction could benefit from this control.
  44378. */
  44379. linkRefractionWithTransparency: boolean;
  44380. /**
  44381. * If true, the light map contains occlusion information instead of lighting info.
  44382. */
  44383. useLightmapAsShadowmap: boolean;
  44384. /**
  44385. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44386. */
  44387. useAlphaFromAlbedoTexture: boolean;
  44388. /**
  44389. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44390. */
  44391. forceAlphaTest: boolean;
  44392. /**
  44393. * Defines the alpha limits in alpha test mode.
  44394. */
  44395. alphaCutOff: number;
  44396. /**
  44397. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44398. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44399. */
  44400. useSpecularOverAlpha: boolean;
  44401. /**
  44402. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44403. */
  44404. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44405. /**
  44406. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44407. */
  44408. useRoughnessFromMetallicTextureAlpha: boolean;
  44409. /**
  44410. * Specifies if the metallic texture contains the roughness information in its green channel.
  44411. */
  44412. useRoughnessFromMetallicTextureGreen: boolean;
  44413. /**
  44414. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44415. */
  44416. useMetallnessFromMetallicTextureBlue: boolean;
  44417. /**
  44418. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44419. */
  44420. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44421. /**
  44422. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44423. */
  44424. useAmbientInGrayScale: boolean;
  44425. /**
  44426. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44427. * The material will try to infer what glossiness each pixel should be.
  44428. */
  44429. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44430. /**
  44431. * BJS is using an harcoded light falloff based on a manually sets up range.
  44432. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44433. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44434. */
  44435. /**
  44436. * BJS is using an harcoded light falloff based on a manually sets up range.
  44437. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44438. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44439. */
  44440. usePhysicalLightFalloff: boolean;
  44441. /**
  44442. * In order to support the falloff compatibility with gltf, a special mode has been added
  44443. * to reproduce the gltf light falloff.
  44444. */
  44445. /**
  44446. * In order to support the falloff compatibility with gltf, a special mode has been added
  44447. * to reproduce the gltf light falloff.
  44448. */
  44449. useGLTFLightFalloff: boolean;
  44450. /**
  44451. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44452. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44453. */
  44454. useRadianceOverAlpha: boolean;
  44455. /**
  44456. * Allows using an object space normal map (instead of tangent space).
  44457. */
  44458. useObjectSpaceNormalMap: boolean;
  44459. /**
  44460. * Allows using the bump map in parallax mode.
  44461. */
  44462. useParallax: boolean;
  44463. /**
  44464. * Allows using the bump map in parallax occlusion mode.
  44465. */
  44466. useParallaxOcclusion: boolean;
  44467. /**
  44468. * Controls the scale bias of the parallax mode.
  44469. */
  44470. parallaxScaleBias: number;
  44471. /**
  44472. * If sets to true, disables all the lights affecting the material.
  44473. */
  44474. disableLighting: boolean;
  44475. /**
  44476. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44477. */
  44478. forceIrradianceInFragment: boolean;
  44479. /**
  44480. * Number of Simultaneous lights allowed on the material.
  44481. */
  44482. maxSimultaneousLights: number;
  44483. /**
  44484. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44485. */
  44486. invertNormalMapX: boolean;
  44487. /**
  44488. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44489. */
  44490. invertNormalMapY: boolean;
  44491. /**
  44492. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44493. */
  44494. twoSidedLighting: boolean;
  44495. /**
  44496. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44497. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44498. */
  44499. useAlphaFresnel: boolean;
  44500. /**
  44501. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44502. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44503. */
  44504. useLinearAlphaFresnel: boolean;
  44505. /**
  44506. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44507. * And/Or occlude the blended part.
  44508. */
  44509. environmentBRDFTexture: Nullable<BaseTexture>;
  44510. /**
  44511. * Force normal to face away from face.
  44512. */
  44513. forceNormalForward: boolean;
  44514. /**
  44515. * Enables specular anti aliasing in the PBR shader.
  44516. * It will both interacts on the Geometry for analytical and IBL lighting.
  44517. * It also prefilter the roughness map based on the bump values.
  44518. */
  44519. enableSpecularAntiAliasing: boolean;
  44520. /**
  44521. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44522. * makes the reflect vector face the model (under horizon).
  44523. */
  44524. useHorizonOcclusion: boolean;
  44525. /**
  44526. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44527. * too much the area relying on ambient texture to define their ambient occlusion.
  44528. */
  44529. useRadianceOcclusion: boolean;
  44530. /**
  44531. * If set to true, no lighting calculations will be applied.
  44532. */
  44533. unlit: boolean;
  44534. /**
  44535. * Gets the image processing configuration used either in this material.
  44536. */
  44537. /**
  44538. * Sets the Default image processing configuration used either in the this material.
  44539. *
  44540. * If sets to null, the scene one is in use.
  44541. */
  44542. imageProcessingConfiguration: ImageProcessingConfiguration;
  44543. /**
  44544. * Gets wether the color curves effect is enabled.
  44545. */
  44546. /**
  44547. * Sets wether the color curves effect is enabled.
  44548. */
  44549. cameraColorCurvesEnabled: boolean;
  44550. /**
  44551. * Gets wether the color grading effect is enabled.
  44552. */
  44553. /**
  44554. * Gets wether the color grading effect is enabled.
  44555. */
  44556. cameraColorGradingEnabled: boolean;
  44557. /**
  44558. * Gets wether tonemapping is enabled or not.
  44559. */
  44560. /**
  44561. * Sets wether tonemapping is enabled or not
  44562. */
  44563. cameraToneMappingEnabled: boolean;
  44564. /**
  44565. * The camera exposure used on this material.
  44566. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44567. * This corresponds to a photographic exposure.
  44568. */
  44569. /**
  44570. * The camera exposure used on this material.
  44571. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44572. * This corresponds to a photographic exposure.
  44573. */
  44574. cameraExposure: number;
  44575. /**
  44576. * Gets The camera contrast used on this material.
  44577. */
  44578. /**
  44579. * Sets The camera contrast used on this material.
  44580. */
  44581. cameraContrast: number;
  44582. /**
  44583. * Gets the Color Grading 2D Lookup Texture.
  44584. */
  44585. /**
  44586. * Sets the Color Grading 2D Lookup Texture.
  44587. */
  44588. cameraColorGradingTexture: Nullable<BaseTexture>;
  44589. /**
  44590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44592. * 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;
  44593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44594. */
  44595. /**
  44596. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44597. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44598. * 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;
  44599. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44600. */
  44601. cameraColorCurves: Nullable<ColorCurves>;
  44602. /**
  44603. * Instantiates a new PBRMaterial instance.
  44604. *
  44605. * @param name The material name
  44606. * @param scene The scene the material will be use in.
  44607. */
  44608. constructor(name: string, scene: Scene);
  44609. /**
  44610. * Returns the name of this material class.
  44611. */
  44612. getClassName(): string;
  44613. /**
  44614. * Returns an array of the actively used textures.
  44615. * @returns - Array of BaseTextures
  44616. */
  44617. getActiveTextures(): BaseTexture[];
  44618. /**
  44619. * Checks to see if a texture is used in the material.
  44620. * @param texture - Base texture to use.
  44621. * @returns - Boolean specifying if a texture is used in the material.
  44622. */
  44623. hasTexture(texture: BaseTexture): boolean;
  44624. /**
  44625. * Makes a duplicate of the current material.
  44626. * @param name - name to use for the new material.
  44627. */
  44628. clone(name: string): PBRMaterial;
  44629. /**
  44630. * Serializes this PBR Material.
  44631. * @returns - An object with the serialized material.
  44632. */
  44633. serialize(): any;
  44634. /**
  44635. * Parses a PBR Material from a serialized object.
  44636. * @param source - Serialized object.
  44637. * @param scene - BJS scene instance.
  44638. * @param rootUrl - url for the scene object
  44639. * @returns - PBRMaterial
  44640. */
  44641. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44642. }
  44643. }
  44644. declare module BABYLON {
  44645. /**
  44646. * The PBR material of BJS following the metal roughness convention.
  44647. *
  44648. * This fits to the PBR convention in the GLTF definition:
  44649. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  44650. */
  44651. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  44652. /**
  44653. * The base color has two different interpretations depending on the value of metalness.
  44654. * When the material is a metal, the base color is the specific measured reflectance value
  44655. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  44656. * of the material.
  44657. */
  44658. baseColor: Color3;
  44659. /**
  44660. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  44661. * well as opacity information in the alpha channel.
  44662. */
  44663. baseTexture: BaseTexture;
  44664. /**
  44665. * Specifies the metallic scalar value of the material.
  44666. * Can also be used to scale the metalness values of the metallic texture.
  44667. */
  44668. metallic: number;
  44669. /**
  44670. * Specifies the roughness scalar value of the material.
  44671. * Can also be used to scale the roughness values of the metallic texture.
  44672. */
  44673. roughness: number;
  44674. /**
  44675. * Texture containing both the metallic value in the B channel and the
  44676. * roughness value in the G channel to keep better precision.
  44677. */
  44678. metallicRoughnessTexture: BaseTexture;
  44679. /**
  44680. * Instantiates a new PBRMetalRoughnessMaterial instance.
  44681. *
  44682. * @param name The material name
  44683. * @param scene The scene the material will be use in.
  44684. */
  44685. constructor(name: string, scene: Scene);
  44686. /**
  44687. * Return the currrent class name of the material.
  44688. */
  44689. getClassName(): string;
  44690. /**
  44691. * Return the active textures of the material.
  44692. */
  44693. getActiveTextures(): BaseTexture[];
  44694. /**
  44695. * Checks to see if a texture is used in the material.
  44696. * @param texture - Base texture to use.
  44697. * @returns - Boolean specifying if a texture is used in the material.
  44698. */
  44699. hasTexture(texture: BaseTexture): boolean;
  44700. /**
  44701. * Makes a duplicate of the current material.
  44702. * @param name - name to use for the new material.
  44703. */
  44704. clone(name: string): PBRMetallicRoughnessMaterial;
  44705. /**
  44706. * Serialize the material to a parsable JSON object.
  44707. */
  44708. serialize(): any;
  44709. /**
  44710. * Parses a JSON object correponding to the serialize function.
  44711. */
  44712. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  44713. }
  44714. }
  44715. declare module BABYLON {
  44716. /**
  44717. * The PBR material of BJS following the specular glossiness convention.
  44718. *
  44719. * This fits to the PBR convention in the GLTF definition:
  44720. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  44721. */
  44722. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  44723. /**
  44724. * Specifies the diffuse color of the material.
  44725. */
  44726. diffuseColor: Color3;
  44727. /**
  44728. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  44729. * channel.
  44730. */
  44731. diffuseTexture: BaseTexture;
  44732. /**
  44733. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  44734. */
  44735. specularColor: Color3;
  44736. /**
  44737. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  44738. */
  44739. glossiness: number;
  44740. /**
  44741. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  44742. */
  44743. specularGlossinessTexture: BaseTexture;
  44744. /**
  44745. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  44746. *
  44747. * @param name The material name
  44748. * @param scene The scene the material will be use in.
  44749. */
  44750. constructor(name: string, scene: Scene);
  44751. /**
  44752. * Return the currrent class name of the material.
  44753. */
  44754. getClassName(): string;
  44755. /**
  44756. * Return the active textures of the material.
  44757. */
  44758. getActiveTextures(): BaseTexture[];
  44759. /**
  44760. * Checks to see if a texture is used in the material.
  44761. * @param texture - Base texture to use.
  44762. * @returns - Boolean specifying if a texture is used in the material.
  44763. */
  44764. hasTexture(texture: BaseTexture): boolean;
  44765. /**
  44766. * Makes a duplicate of the current material.
  44767. * @param name - name to use for the new material.
  44768. */
  44769. clone(name: string): PBRSpecularGlossinessMaterial;
  44770. /**
  44771. * Serialize the material to a parsable JSON object.
  44772. */
  44773. serialize(): any;
  44774. /**
  44775. * Parses a JSON object correponding to the serialize function.
  44776. */
  44777. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  44778. }
  44779. }
  44780. declare module BABYLON {
  44781. /**
  44782. * Base class of all the textures in babylon.
  44783. * It groups all the common properties the materials, post process, lights... might need
  44784. * in order to make a correct use of the texture.
  44785. */
  44786. class BaseTexture {
  44787. /**
  44788. * Default anisotropic filtering level for the application.
  44789. * It is set to 4 as a good tradeoff between perf and quality.
  44790. */
  44791. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  44792. /**
  44793. * Define the name of the texture.
  44794. */
  44795. name: string;
  44796. private _hasAlpha;
  44797. /**
  44798. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  44799. */
  44800. hasAlpha: boolean;
  44801. /**
  44802. * Defines if the alpha value should be determined via the rgb values.
  44803. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  44804. */
  44805. getAlphaFromRGB: boolean;
  44806. /**
  44807. * Intensity or strength of the texture.
  44808. * It is commonly used by materials to fine tune the intensity of the texture
  44809. */
  44810. level: number;
  44811. /**
  44812. * Define the UV chanel to use starting from 0 and defaulting to 0.
  44813. * This is part of the texture as textures usually maps to one uv set.
  44814. */
  44815. coordinatesIndex: number;
  44816. private _coordinatesMode;
  44817. /**
  44818. * How a texture is mapped.
  44819. *
  44820. * | Value | Type | Description |
  44821. * | ----- | ----------------------------------- | ----------- |
  44822. * | 0 | EXPLICIT_MODE | |
  44823. * | 1 | SPHERICAL_MODE | |
  44824. * | 2 | PLANAR_MODE | |
  44825. * | 3 | CUBIC_MODE | |
  44826. * | 4 | PROJECTION_MODE | |
  44827. * | 5 | SKYBOX_MODE | |
  44828. * | 6 | INVCUBIC_MODE | |
  44829. * | 7 | EQUIRECTANGULAR_MODE | |
  44830. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  44831. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  44832. */
  44833. coordinatesMode: number;
  44834. /**
  44835. * | Value | Type | Description |
  44836. * | ----- | ------------------ | ----------- |
  44837. * | 0 | CLAMP_ADDRESSMODE | |
  44838. * | 1 | WRAP_ADDRESSMODE | |
  44839. * | 2 | MIRROR_ADDRESSMODE | |
  44840. */
  44841. wrapU: number;
  44842. /**
  44843. * | Value | Type | Description |
  44844. * | ----- | ------------------ | ----------- |
  44845. * | 0 | CLAMP_ADDRESSMODE | |
  44846. * | 1 | WRAP_ADDRESSMODE | |
  44847. * | 2 | MIRROR_ADDRESSMODE | |
  44848. */
  44849. wrapV: number;
  44850. /**
  44851. * | Value | Type | Description |
  44852. * | ----- | ------------------ | ----------- |
  44853. * | 0 | CLAMP_ADDRESSMODE | |
  44854. * | 1 | WRAP_ADDRESSMODE | |
  44855. * | 2 | MIRROR_ADDRESSMODE | |
  44856. */
  44857. wrapR: number;
  44858. /**
  44859. * With compliant hardware and browser (supporting anisotropic filtering)
  44860. * this defines the level of anisotropic filtering in the texture.
  44861. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  44862. */
  44863. anisotropicFilteringLevel: number;
  44864. /**
  44865. * Define if the texture is a cube texture or if false a 2d texture.
  44866. */
  44867. isCube: boolean;
  44868. /**
  44869. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  44870. */
  44871. is3D: boolean;
  44872. /**
  44873. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  44874. * HDR texture are usually stored in linear space.
  44875. * This only impacts the PBR and Background materials
  44876. */
  44877. gammaSpace: boolean;
  44878. /**
  44879. * Gets whether or not the texture contains RGBD data.
  44880. */
  44881. readonly isRGBD: boolean;
  44882. /**
  44883. * Is Z inverted in the texture (useful in a cube texture).
  44884. */
  44885. invertZ: boolean;
  44886. /**
  44887. * @hidden
  44888. */
  44889. lodLevelInAlpha: boolean;
  44890. /**
  44891. * With prefiltered texture, defined the offset used during the prefiltering steps.
  44892. */
  44893. lodGenerationOffset: number;
  44894. /**
  44895. * With prefiltered texture, defined the scale used during the prefiltering steps.
  44896. */
  44897. lodGenerationScale: number;
  44898. /**
  44899. * Define if the texture is a render target.
  44900. */
  44901. isRenderTarget: boolean;
  44902. /**
  44903. * Define the unique id of the texture in the scene.
  44904. */
  44905. readonly uid: string;
  44906. /**
  44907. * Return a string representation of the texture.
  44908. * @returns the texture as a string
  44909. */
  44910. toString(): string;
  44911. /**
  44912. * Get the class name of the texture.
  44913. * @returns "BaseTexture"
  44914. */
  44915. getClassName(): string;
  44916. /**
  44917. * Define the list of animation attached to the texture.
  44918. */
  44919. animations: Animation[];
  44920. /**
  44921. * An event triggered when the texture is disposed.
  44922. */
  44923. onDisposeObservable: Observable<BaseTexture>;
  44924. private _onDisposeObserver;
  44925. /**
  44926. * Callback triggered when the texture has been disposed.
  44927. * Kept for back compatibility, you can use the onDisposeObservable instead.
  44928. */
  44929. onDispose: () => void;
  44930. /**
  44931. * Define the current state of the loading sequence when in delayed load mode.
  44932. */
  44933. delayLoadState: number;
  44934. private _scene;
  44935. /** @hidden */
  44936. _texture: Nullable<InternalTexture>;
  44937. private _uid;
  44938. /**
  44939. * Define if the texture is preventinga material to render or not.
  44940. * If not and the texture is not ready, the engine will use a default black texture instead.
  44941. */
  44942. readonly isBlocking: boolean;
  44943. /**
  44944. * Instantiates a new BaseTexture.
  44945. * Base class of all the textures in babylon.
  44946. * It groups all the common properties the materials, post process, lights... might need
  44947. * in order to make a correct use of the texture.
  44948. * @param scene Define the scene the texture blongs to
  44949. */
  44950. constructor(scene: Nullable<Scene>);
  44951. /**
  44952. * Get the scene the texture belongs to.
  44953. * @returns the scene or null if undefined
  44954. */
  44955. getScene(): Nullable<Scene>;
  44956. /**
  44957. * Get the texture transform matrix used to offset tile the texture for istance.
  44958. * @returns the transformation matrix
  44959. */
  44960. getTextureMatrix(): Matrix;
  44961. /**
  44962. * Get the texture reflection matrix used to rotate/transform the reflection.
  44963. * @returns the reflection matrix
  44964. */
  44965. getReflectionTextureMatrix(): Matrix;
  44966. /**
  44967. * Get the underlying lower level texture from Babylon.
  44968. * @returns the insternal texture
  44969. */
  44970. getInternalTexture(): Nullable<InternalTexture>;
  44971. /**
  44972. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  44973. * @returns true if ready or not blocking
  44974. */
  44975. isReadyOrNotBlocking(): boolean;
  44976. /**
  44977. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  44978. * @returns true if fully ready
  44979. */
  44980. isReady(): boolean;
  44981. private _cachedSize;
  44982. /**
  44983. * Get the size of the texture.
  44984. * @returns the texture size.
  44985. */
  44986. getSize(): ISize;
  44987. /**
  44988. * Get the base size of the texture.
  44989. * It can be different from the size if the texture has been resized for POT for instance
  44990. * @returns the base size
  44991. */
  44992. getBaseSize(): ISize;
  44993. /**
  44994. * Scales the texture if is `canRescale()`
  44995. * @param ratio the resize factor we want to use to rescale
  44996. */
  44997. scale(ratio: number): void;
  44998. /**
  44999. * Get if the texture can rescale.
  45000. */
  45001. readonly canRescale: boolean;
  45002. /** @hidden */
  45003. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  45004. /** @hidden */
  45005. _rebuild(): void;
  45006. /**
  45007. * Triggers the load sequence in delayed load mode.
  45008. */
  45009. delayLoad(): void;
  45010. /**
  45011. * Clones the texture.
  45012. * @returns the cloned texture
  45013. */
  45014. clone(): Nullable<BaseTexture>;
  45015. /**
  45016. * Get the texture underlying type (INT, FLOAT...)
  45017. */
  45018. readonly textureType: number;
  45019. /**
  45020. * Get the texture underlying format (RGB, RGBA...)
  45021. */
  45022. readonly textureFormat: number;
  45023. /**
  45024. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  45025. * This will returns an RGBA array buffer containing either in values (0-255) or
  45026. * float values (0-1) depending of the underlying buffer type.
  45027. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  45028. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  45029. * @param buffer defines a user defined buffer to fill with data (can be null)
  45030. * @returns The Array buffer containing the pixels data.
  45031. */
  45032. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  45033. /**
  45034. * Release and destroy the underlying lower level texture aka internalTexture.
  45035. */
  45036. releaseInternalTexture(): void;
  45037. /**
  45038. * Get the polynomial representation of the texture data.
  45039. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45040. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45041. */
  45042. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45043. /** @hidden */
  45044. readonly _lodTextureHigh: Nullable<BaseTexture>;
  45045. /** @hidden */
  45046. readonly _lodTextureMid: Nullable<BaseTexture>;
  45047. /** @hidden */
  45048. readonly _lodTextureLow: Nullable<BaseTexture>;
  45049. /**
  45050. * Dispose the texture and release its associated resources.
  45051. */
  45052. dispose(): void;
  45053. /**
  45054. * Serialize the texture into a JSON representation that can be parsed later on.
  45055. * @returns the JSON representation of the texture
  45056. */
  45057. serialize(): any;
  45058. /**
  45059. * Helper function to be called back once a list of texture contains only ready textures.
  45060. * @param textures Define the list of textures to wait for
  45061. * @param callback Define the callback triggered once the entire list will be ready
  45062. */
  45063. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  45064. }
  45065. }
  45066. declare module BABYLON {
  45067. /**
  45068. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45069. * It can help converting any input color in a desired output one. This can then be used to create effects
  45070. * from sepia, black and white to sixties or futuristic rendering...
  45071. *
  45072. * The only supported format is currently 3dl.
  45073. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45074. */
  45075. class ColorGradingTexture extends BaseTexture {
  45076. /**
  45077. * The current texture matrix. (will always be identity in color grading texture)
  45078. */
  45079. private _textureMatrix;
  45080. /**
  45081. * The texture URL.
  45082. */
  45083. url: string;
  45084. /**
  45085. * Empty line regex stored for GC.
  45086. */
  45087. private static _noneEmptyLineRegex;
  45088. private _engine;
  45089. /**
  45090. * Instantiates a ColorGradingTexture from the following parameters.
  45091. *
  45092. * @param url The location of the color gradind data (currently only supporting 3dl)
  45093. * @param scene The scene the texture will be used in
  45094. */
  45095. constructor(url: string, scene: Scene);
  45096. /**
  45097. * Returns the texture matrix used in most of the material.
  45098. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45099. */
  45100. getTextureMatrix(): Matrix;
  45101. /**
  45102. * Occurs when the file being loaded is a .3dl LUT file.
  45103. */
  45104. private load3dlTexture;
  45105. /**
  45106. * Starts the loading process of the texture.
  45107. */
  45108. private loadTexture;
  45109. /**
  45110. * Clones the color gradind texture.
  45111. */
  45112. clone(): ColorGradingTexture;
  45113. /**
  45114. * Called during delayed load for textures.
  45115. */
  45116. delayLoad(): void;
  45117. /**
  45118. * Parses a color grading texture serialized by Babylon.
  45119. * @param parsedTexture The texture information being parsedTexture
  45120. * @param scene The scene to load the texture in
  45121. * @param rootUrl The root url of the data assets to load
  45122. * @return A color gradind texture
  45123. */
  45124. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  45125. /**
  45126. * Serializes the LUT texture to json format.
  45127. */
  45128. serialize(): any;
  45129. }
  45130. }
  45131. declare module BABYLON {
  45132. /**
  45133. * Class for creating a cube texture
  45134. */
  45135. class CubeTexture extends BaseTexture {
  45136. /**
  45137. * The url of the texture
  45138. */
  45139. url: string;
  45140. /**
  45141. * Gets or sets the center of the bounding box associated with the cube texture.
  45142. * It must define where the camera used to render the texture was set
  45143. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45144. */
  45145. boundingBoxPosition: Vector3;
  45146. private _boundingBoxSize;
  45147. /**
  45148. * Gets or sets the size of the bounding box associated with the cube texture
  45149. * When defined, the cubemap will switch to local mode
  45150. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45151. * @example https://www.babylonjs-playground.com/#RNASML
  45152. */
  45153. /**
  45154. * Returns the bounding box size
  45155. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45156. */
  45157. boundingBoxSize: Vector3;
  45158. protected _rotationY: number;
  45159. /**
  45160. * Sets texture matrix rotation angle around Y axis in radians.
  45161. */
  45162. /**
  45163. * Gets texture matrix rotation angle around Y axis radians.
  45164. */
  45165. rotationY: number;
  45166. private _noMipmap;
  45167. private _files;
  45168. private _extensions;
  45169. private _textureMatrix;
  45170. private _format;
  45171. private _createPolynomials;
  45172. /** @hidden */
  45173. readonly _prefiltered: boolean;
  45174. /**
  45175. * Creates a cube texture from an array of image urls
  45176. * @param files defines an array of image urls
  45177. * @param scene defines the hosting scene
  45178. * @param noMipmap specifies if mip maps are not used
  45179. * @returns a cube texture
  45180. */
  45181. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  45182. /**
  45183. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  45184. * @param url defines the url of the prefiltered texture
  45185. * @param scene defines the scene the texture is attached to
  45186. * @param forcedExtension defines the extension of the file if different from the url
  45187. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45188. * @return the prefiltered texture
  45189. */
  45190. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  45191. /**
  45192. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  45193. * as prefiltered data.
  45194. * @param rootUrl defines the url of the texture or the root name of the six images
  45195. * @param scene defines the scene the texture is attached to
  45196. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  45197. * @param noMipmap defines if mipmaps should be created or not
  45198. * @param files defines the six files to load for the different faces
  45199. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  45200. * @param onError defines a callback triggered in case of error during load
  45201. * @param format defines the internal format to use for the texture once loaded
  45202. * @param prefiltered defines whether or not the texture is created from prefiltered data
  45203. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  45204. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45205. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45206. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45207. * @return the cube texture
  45208. */
  45209. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  45210. /**
  45211. * Delays loading of the cube texture
  45212. */
  45213. delayLoad(): void;
  45214. /**
  45215. * Returns the reflection texture matrix
  45216. * @returns the reflection texture matrix
  45217. */
  45218. getReflectionTextureMatrix(): Matrix;
  45219. /**
  45220. * Sets the reflection texture matrix
  45221. * @param value Reflection texture matrix
  45222. */
  45223. setReflectionTextureMatrix(value: Matrix): void;
  45224. /**
  45225. * Parses text to create a cube texture
  45226. * @param parsedTexture define the serialized text to read from
  45227. * @param scene defines the hosting scene
  45228. * @param rootUrl defines the root url of the cube texture
  45229. * @returns a cube texture
  45230. */
  45231. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  45232. /**
  45233. * Makes a clone, or deep copy, of the cube texture
  45234. * @returns a new cube texture
  45235. */
  45236. clone(): CubeTexture;
  45237. }
  45238. }
  45239. declare module BABYLON {
  45240. /**
  45241. * A class extending Texture allowing drawing on a texture
  45242. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45243. */
  45244. class DynamicTexture extends Texture {
  45245. private _generateMipMaps;
  45246. private _canvas;
  45247. private _context;
  45248. private _engine;
  45249. /**
  45250. * Creates a DynamicTexture
  45251. * @param name defines the name of the texture
  45252. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  45253. * @param scene defines the scene where you want the texture
  45254. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45255. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45256. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  45257. */
  45258. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45259. /**
  45260. * Gets the current state of canRescale
  45261. */
  45262. readonly canRescale: boolean;
  45263. private _recreate;
  45264. /**
  45265. * Scales the texture
  45266. * @param ratio the scale factor to apply to both width and height
  45267. */
  45268. scale(ratio: number): void;
  45269. /**
  45270. * Resizes the texture
  45271. * @param width the new width
  45272. * @param height the new height
  45273. */
  45274. scaleTo(width: number, height: number): void;
  45275. /**
  45276. * Gets the context of the canvas used by the texture
  45277. * @returns the canvas context of the dynamic texture
  45278. */
  45279. getContext(): CanvasRenderingContext2D;
  45280. /**
  45281. * Clears the texture
  45282. */
  45283. clear(): void;
  45284. /**
  45285. * Updates the texture
  45286. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45287. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45288. */
  45289. update(invertY?: boolean, premulAlpha?: boolean): void;
  45290. /**
  45291. * Draws text onto the texture
  45292. * @param text defines the text to be drawn
  45293. * @param x defines the placement of the text from the left
  45294. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45295. * @param font defines the font to be used with font-style, font-size, font-name
  45296. * @param color defines the color used for the text
  45297. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45298. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45299. * @param update defines whether texture is immediately update (default is true)
  45300. */
  45301. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  45302. /**
  45303. * Clones the texture
  45304. * @returns the clone of the texture.
  45305. */
  45306. clone(): DynamicTexture;
  45307. /**
  45308. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45309. * @returns a serialized dynamic texture object
  45310. */
  45311. serialize(): any;
  45312. /** @hidden */
  45313. _rebuild(): void;
  45314. }
  45315. }
  45316. declare module BABYLON {
  45317. /**
  45318. * This represents a texture coming from an HDR input.
  45319. *
  45320. * The only supported format is currently panorama picture stored in RGBE format.
  45321. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45322. */
  45323. class HDRCubeTexture extends BaseTexture {
  45324. private static _facesMapping;
  45325. private _generateHarmonics;
  45326. private _noMipmap;
  45327. private _textureMatrix;
  45328. private _size;
  45329. private _onLoad;
  45330. private _onError;
  45331. /**
  45332. * The texture URL.
  45333. */
  45334. url: string;
  45335. /**
  45336. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45337. */
  45338. coordinatesMode: number;
  45339. protected _isBlocking: boolean;
  45340. /**
  45341. * Sets wether or not the texture is blocking during loading.
  45342. */
  45343. /**
  45344. * Gets wether or not the texture is blocking during loading.
  45345. */
  45346. isBlocking: boolean;
  45347. protected _rotationY: number;
  45348. /**
  45349. * Sets texture matrix rotation angle around Y axis in radians.
  45350. */
  45351. /**
  45352. * Gets texture matrix rotation angle around Y axis radians.
  45353. */
  45354. rotationY: number;
  45355. /**
  45356. * Gets or sets the center of the bounding box associated with the cube texture
  45357. * It must define where the camera used to render the texture was set
  45358. */
  45359. boundingBoxPosition: Vector3;
  45360. private _boundingBoxSize;
  45361. /**
  45362. * Gets or sets the size of the bounding box associated with the cube texture
  45363. * When defined, the cubemap will switch to local mode
  45364. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45365. * @example https://www.babylonjs-playground.com/#RNASML
  45366. */
  45367. boundingBoxSize: Vector3;
  45368. /**
  45369. * Instantiates an HDRTexture from the following parameters.
  45370. *
  45371. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45372. * @param scene The scene the texture will be used in
  45373. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45374. * @param noMipmap Forces to not generate the mipmap if true
  45375. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45376. * @param gammaSpace 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)
  45377. * @param reserved Reserved flag for internal use.
  45378. */
  45379. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  45380. /**
  45381. * Occurs when the file is raw .hdr file.
  45382. */
  45383. private loadTexture;
  45384. clone(): HDRCubeTexture;
  45385. delayLoad(): void;
  45386. /**
  45387. * Get the texture reflection matrix used to rotate/transform the reflection.
  45388. * @returns the reflection matrix
  45389. */
  45390. getReflectionTextureMatrix(): Matrix;
  45391. /**
  45392. * Set the texture reflection matrix used to rotate/transform the reflection.
  45393. * @param value Define the reflection matrix to set
  45394. */
  45395. setReflectionTextureMatrix(value: Matrix): void;
  45396. /**
  45397. * Parses a JSON representation of an HDR Texture in order to create the texture
  45398. * @param parsedTexture Define the JSON representation
  45399. * @param scene Define the scene the texture should be created in
  45400. * @param rootUrl Define the root url in case we need to load relative dependencies
  45401. * @returns the newly created texture after parsing
  45402. */
  45403. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45404. serialize(): any;
  45405. }
  45406. }
  45407. declare module BABYLON {
  45408. /**
  45409. * Class used to store data associated with WebGL texture data for the engine
  45410. * This class should not be used directly
  45411. */
  45412. class InternalTexture implements IInternalTextureTracker {
  45413. /**
  45414. * The source of the texture data is unknown
  45415. */
  45416. static DATASOURCE_UNKNOWN: number;
  45417. /**
  45418. * Texture data comes from an URL
  45419. */
  45420. static DATASOURCE_URL: number;
  45421. /**
  45422. * Texture data is only used for temporary storage
  45423. */
  45424. static DATASOURCE_TEMP: number;
  45425. /**
  45426. * Texture data comes from raw data (ArrayBuffer)
  45427. */
  45428. static DATASOURCE_RAW: number;
  45429. /**
  45430. * Texture content is dynamic (video or dynamic texture)
  45431. */
  45432. static DATASOURCE_DYNAMIC: number;
  45433. /**
  45434. * Texture content is generated by rendering to it
  45435. */
  45436. static DATASOURCE_RENDERTARGET: number;
  45437. /**
  45438. * Texture content is part of a multi render target process
  45439. */
  45440. static DATASOURCE_MULTIRENDERTARGET: number;
  45441. /**
  45442. * Texture data comes from a cube data file
  45443. */
  45444. static DATASOURCE_CUBE: number;
  45445. /**
  45446. * Texture data comes from a raw cube data
  45447. */
  45448. static DATASOURCE_CUBERAW: number;
  45449. /**
  45450. * Texture data come from a prefiltered cube data file
  45451. */
  45452. static DATASOURCE_CUBEPREFILTERED: number;
  45453. /**
  45454. * Texture content is raw 3D data
  45455. */
  45456. static DATASOURCE_RAW3D: number;
  45457. /**
  45458. * Texture content is a depth texture
  45459. */
  45460. static DATASOURCE_DEPTHTEXTURE: number;
  45461. /**
  45462. * Texture data comes from a raw cube data encoded with RGBD
  45463. */
  45464. static DATASOURCE_CUBERAW_RGBD: number;
  45465. /**
  45466. * Defines if the texture is ready
  45467. */
  45468. isReady: boolean;
  45469. /**
  45470. * Defines if the texture is a cube texture
  45471. */
  45472. isCube: boolean;
  45473. /**
  45474. * Defines if the texture contains 3D data
  45475. */
  45476. is3D: boolean;
  45477. /**
  45478. * Gets the URL used to load this texture
  45479. */
  45480. url: string;
  45481. /**
  45482. * Gets the sampling mode of the texture
  45483. */
  45484. samplingMode: number;
  45485. /**
  45486. * Gets a boolean indicating if the texture needs mipmaps generation
  45487. */
  45488. generateMipMaps: boolean;
  45489. /**
  45490. * Gets the number of samples used by the texture (WebGL2+ only)
  45491. */
  45492. samples: number;
  45493. /**
  45494. * Gets the type of the texture (int, float...)
  45495. */
  45496. type: number;
  45497. /**
  45498. * Gets the format of the texture (RGB, RGBA...)
  45499. */
  45500. format: number;
  45501. /**
  45502. * Observable called when the texture is loaded
  45503. */
  45504. onLoadedObservable: Observable<InternalTexture>;
  45505. /**
  45506. * Gets the width of the texture
  45507. */
  45508. width: number;
  45509. /**
  45510. * Gets the height of the texture
  45511. */
  45512. height: number;
  45513. /**
  45514. * Gets the depth of the texture
  45515. */
  45516. depth: number;
  45517. /**
  45518. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  45519. */
  45520. baseWidth: number;
  45521. /**
  45522. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  45523. */
  45524. baseHeight: number;
  45525. /**
  45526. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  45527. */
  45528. baseDepth: number;
  45529. /**
  45530. * Gets a boolean indicating if the texture is inverted on Y axis
  45531. */
  45532. invertY: boolean;
  45533. /**
  45534. * Gets or set the previous tracker in the list
  45535. */
  45536. previous: Nullable<IInternalTextureTracker>;
  45537. /**
  45538. * Gets or set the next tracker in the list
  45539. */
  45540. next: Nullable<IInternalTextureTracker>;
  45541. /** @hidden */
  45542. _initialSlot: number;
  45543. /** @hidden */
  45544. _designatedSlot: number;
  45545. /** @hidden */
  45546. _dataSource: number;
  45547. /** @hidden */
  45548. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  45549. /** @hidden */
  45550. _bufferView: Nullable<ArrayBufferView>;
  45551. /** @hidden */
  45552. _bufferViewArray: Nullable<ArrayBufferView[]>;
  45553. /** @hidden */
  45554. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  45555. /** @hidden */
  45556. _size: number;
  45557. /** @hidden */
  45558. _extension: string;
  45559. /** @hidden */
  45560. _files: Nullable<string[]>;
  45561. /** @hidden */
  45562. _workingCanvas: HTMLCanvasElement;
  45563. /** @hidden */
  45564. _workingContext: CanvasRenderingContext2D;
  45565. /** @hidden */
  45566. _framebuffer: Nullable<WebGLFramebuffer>;
  45567. /** @hidden */
  45568. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  45569. /** @hidden */
  45570. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  45571. /** @hidden */
  45572. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  45573. /** @hidden */
  45574. _attachments: Nullable<number[]>;
  45575. /** @hidden */
  45576. _cachedCoordinatesMode: Nullable<number>;
  45577. /** @hidden */
  45578. _cachedWrapU: Nullable<number>;
  45579. /** @hidden */
  45580. _cachedWrapV: Nullable<number>;
  45581. /** @hidden */
  45582. _cachedWrapR: Nullable<number>;
  45583. /** @hidden */
  45584. _cachedAnisotropicFilteringLevel: Nullable<number>;
  45585. /** @hidden */
  45586. _isDisabled: boolean;
  45587. /** @hidden */
  45588. _compression: Nullable<string>;
  45589. /** @hidden */
  45590. _generateStencilBuffer: boolean;
  45591. /** @hidden */
  45592. _generateDepthBuffer: boolean;
  45593. /** @hidden */
  45594. _comparisonFunction: number;
  45595. /** @hidden */
  45596. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  45597. /** @hidden */
  45598. _lodGenerationScale: number;
  45599. /** @hidden */
  45600. _lodGenerationOffset: number;
  45601. /** @hidden */
  45602. _lodTextureHigh: BaseTexture;
  45603. /** @hidden */
  45604. _lodTextureMid: BaseTexture;
  45605. /** @hidden */
  45606. _lodTextureLow: BaseTexture;
  45607. /** @hidden */
  45608. _isRGBD: boolean;
  45609. /** @hidden */
  45610. _webGLTexture: Nullable<WebGLTexture>;
  45611. /** @hidden */
  45612. _references: number;
  45613. private _engine;
  45614. /**
  45615. * Gets the Engine the texture belongs to.
  45616. * @returns The babylon engine
  45617. */
  45618. getEngine(): Engine;
  45619. /**
  45620. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  45621. */
  45622. readonly dataSource: number;
  45623. /**
  45624. * Creates a new InternalTexture
  45625. * @param engine defines the engine to use
  45626. * @param dataSource defines the type of data that will be used
  45627. */
  45628. constructor(engine: Engine, dataSource: number);
  45629. /**
  45630. * Increments the number of references (ie. the number of Texture that point to it)
  45631. */
  45632. incrementReferences(): void;
  45633. /**
  45634. * Change the size of the texture (not the size of the content)
  45635. * @param width defines the new width
  45636. * @param height defines the new height
  45637. * @param depth defines the new depth (1 by default)
  45638. */
  45639. updateSize(width: int, height: int, depth?: int): void;
  45640. /** @hidden */
  45641. _rebuild(): void;
  45642. /** @hidden */
  45643. _swapAndDie(target: InternalTexture): void;
  45644. /**
  45645. * Dispose the current allocated resources
  45646. */
  45647. dispose(): void;
  45648. }
  45649. }
  45650. declare module BABYLON {
  45651. /**
  45652. * This represents the required contract to create a new type of texture loader.
  45653. */
  45654. interface IInternalTextureLoader {
  45655. /**
  45656. * Defines wether the loader supports cascade loading the different faces.
  45657. */
  45658. supportCascades: boolean;
  45659. /**
  45660. * This returns if the loader support the current file information.
  45661. * @param extension defines the file extension of the file being loaded
  45662. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45663. * @param fallback defines the fallback internal texture if any
  45664. * @param isBase64 defines whether the texture is encoded as a base64
  45665. * @param isBuffer defines whether the texture data are stored as a buffer
  45666. * @returns true if the loader can load the specified file
  45667. */
  45668. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45669. /**
  45670. * Transform the url before loading if required.
  45671. * @param rootUrl the url of the texture
  45672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45673. * @returns the transformed texture
  45674. */
  45675. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45676. /**
  45677. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45678. * @param rootUrl the url of the texture
  45679. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45680. * @returns the fallback texture
  45681. */
  45682. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45683. /**
  45684. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45685. * @param data contains the texture data
  45686. * @param texture defines the BabylonJS internal texture
  45687. * @param createPolynomials will be true if polynomials have been requested
  45688. * @param onLoad defines the callback to trigger once the texture is ready
  45689. * @param onError defines the callback to trigger in case of error
  45690. */
  45691. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45692. /**
  45693. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45694. * @param data contains the texture data
  45695. * @param texture defines the BabylonJS internal texture
  45696. * @param callback defines the method to call once ready to upload
  45697. */
  45698. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45699. }
  45700. }
  45701. declare module BABYLON {
  45702. /**
  45703. * Internal interface used to track InternalTexture already bound to the GL context
  45704. */
  45705. interface IInternalTextureTracker {
  45706. /**
  45707. * Gets or set the previous tracker in the list
  45708. */
  45709. previous: Nullable<IInternalTextureTracker>;
  45710. /**
  45711. * Gets or set the next tracker in the list
  45712. */
  45713. next: Nullable<IInternalTextureTracker>;
  45714. }
  45715. /**
  45716. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  45717. */
  45718. class DummyInternalTextureTracker {
  45719. /**
  45720. * Gets or set the previous tracker in the list
  45721. */
  45722. previous: Nullable<IInternalTextureTracker>;
  45723. /**
  45724. * Gets or set the next tracker in the list
  45725. */
  45726. next: Nullable<IInternalTextureTracker>;
  45727. }
  45728. }
  45729. declare module BABYLON {
  45730. /**
  45731. * Mirror texture can be used to simulate the view from a mirror in a scene.
  45732. * It will dynamically be rendered every frame to adapt to the camera point of view.
  45733. * You can then easily use it as a reflectionTexture on a flat surface.
  45734. * In case the surface is not a plane, please consider relying on reflection probes.
  45735. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45736. */
  45737. class MirrorTexture extends RenderTargetTexture {
  45738. private scene;
  45739. /**
  45740. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  45741. * It is possible to directly set the mirrorPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  45742. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45743. */
  45744. mirrorPlane: Plane;
  45745. /**
  45746. * Define the blur ratio used to blur the reflection if needed.
  45747. */
  45748. blurRatio: number;
  45749. /**
  45750. * Define the adaptive blur kernel used to blur the reflection if needed.
  45751. * This will autocompute the closest best match for the `blurKernel`
  45752. */
  45753. adaptiveBlurKernel: number;
  45754. /**
  45755. * Define the blur kernel used to blur the reflection if needed.
  45756. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45757. */
  45758. blurKernel: number;
  45759. /**
  45760. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  45761. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45762. */
  45763. blurKernelX: number;
  45764. /**
  45765. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  45766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  45767. */
  45768. blurKernelY: number;
  45769. private _autoComputeBlurKernel;
  45770. protected _onRatioRescale(): void;
  45771. private _updateGammaSpace;
  45772. private _imageProcessingConfigChangeObserver;
  45773. private _transformMatrix;
  45774. private _mirrorMatrix;
  45775. private _savedViewMatrix;
  45776. private _blurX;
  45777. private _blurY;
  45778. private _adaptiveBlurKernel;
  45779. private _blurKernelX;
  45780. private _blurKernelY;
  45781. private _blurRatio;
  45782. /**
  45783. * Instantiates a Mirror Texture.
  45784. * Mirror texture can be used to simulate the view from a mirror in a scene.
  45785. * It will dynamically be rendered every frame to adapt to the camera point of view.
  45786. * You can then easily use it as a reflectionTexture on a flat surface.
  45787. * In case the surface is not a plane, please consider relying on reflection probes.
  45788. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  45789. * @param name
  45790. * @param size
  45791. * @param scene
  45792. * @param generateMipMaps
  45793. * @param type
  45794. * @param samplingMode
  45795. * @param generateDepthBuffer
  45796. */
  45797. constructor(name: string, size: number | {
  45798. width: number;
  45799. height: number;
  45800. } | {
  45801. ratio: number;
  45802. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  45803. private _preparePostProcesses;
  45804. /**
  45805. * Clone the mirror texture.
  45806. * @returns the cloned texture
  45807. */
  45808. clone(): MirrorTexture;
  45809. /**
  45810. * Serialize the texture to a JSON representation you could use in Parse later on
  45811. * @returns the serialized JSON representation
  45812. */
  45813. serialize(): any;
  45814. /**
  45815. * Dispose the texture and release its associated resources.
  45816. */
  45817. dispose(): void;
  45818. }
  45819. }
  45820. declare module BABYLON {
  45821. /**
  45822. * Creation options of the multi render target texture.
  45823. */
  45824. interface IMultiRenderTargetOptions {
  45825. /**
  45826. * Define if the texture needs to create mip maps after render.
  45827. */
  45828. generateMipMaps?: boolean;
  45829. /**
  45830. * Define the types of all the draw buffers we want to create
  45831. */
  45832. types?: number[];
  45833. /**
  45834. * Define the sampling modes of all the draw buffers we want to create
  45835. */
  45836. samplingModes?: number[];
  45837. /**
  45838. * Define if a depth buffer is required
  45839. */
  45840. generateDepthBuffer?: boolean;
  45841. /**
  45842. * Define if a stencil buffer is required
  45843. */
  45844. generateStencilBuffer?: boolean;
  45845. /**
  45846. * Define if a depth texture is required instead of a depth buffer
  45847. */
  45848. generateDepthTexture?: boolean;
  45849. /**
  45850. * Define the number of desired draw buffers
  45851. */
  45852. textureCount?: number;
  45853. /**
  45854. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45855. */
  45856. doNotChangeAspectRatio?: boolean;
  45857. /**
  45858. * Define the default type of the buffers we are creating
  45859. */
  45860. defaultType?: number;
  45861. }
  45862. /**
  45863. * A multi render target, like a render target provides the ability to render to a texture.
  45864. * Unlike the render target, it can render to several draw buffers in one draw.
  45865. * This is specially interesting in deferred rendering or for any effects requiring more than
  45866. * just one color from a single pass.
  45867. */
  45868. class MultiRenderTarget extends RenderTargetTexture {
  45869. private _internalTextures;
  45870. private _textures;
  45871. private _multiRenderTargetOptions;
  45872. /**
  45873. * Get if draw buffers are currently supported by the used hardware and browser.
  45874. */
  45875. readonly isSupported: boolean;
  45876. /**
  45877. * Get the list of textures generated by the multi render target.
  45878. */
  45879. readonly textures: Texture[];
  45880. /**
  45881. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45882. */
  45883. readonly depthTexture: Texture;
  45884. /**
  45885. * Set the wrapping mode on U of all the textures we are rendering to.
  45886. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45887. */
  45888. wrapU: number;
  45889. /**
  45890. * Set the wrapping mode on V of all the textures we are rendering to.
  45891. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45892. */
  45893. wrapV: number;
  45894. /**
  45895. * Instantiate a new multi render target texture.
  45896. * A multi render target, like a render target provides the ability to render to a texture.
  45897. * Unlike the render target, it can render to several draw buffers in one draw.
  45898. * This is specially interesting in deferred rendering or for any effects requiring more than
  45899. * just one color from a single pass.
  45900. * @param name Define the name of the texture
  45901. * @param size Define the size of the buffers to render to
  45902. * @param count Define the number of target we are rendering into
  45903. * @param scene Define the scene the texture belongs to
  45904. * @param options Define the options used to create the multi render target
  45905. */
  45906. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45907. /** @hidden */
  45908. _rebuild(): void;
  45909. private _createInternalTextures;
  45910. private _createTextures;
  45911. /**
  45912. * Define the number of samples used if MSAA is enabled.
  45913. */
  45914. samples: number;
  45915. /**
  45916. * Resize all the textures in the multi render target.
  45917. * Be carrefull as it will recreate all the data in the new texture.
  45918. * @param size Define the new size
  45919. */
  45920. resize(size: any): void;
  45921. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45922. /**
  45923. * Dispose the render targets and their associated resources
  45924. */
  45925. dispose(): void;
  45926. /**
  45927. * Release all the underlying texture used as draw buffers.
  45928. */
  45929. releaseInternalTextures(): void;
  45930. }
  45931. }
  45932. declare module BABYLON {
  45933. /**
  45934. * Raw cube texture where the raw buffers are passed in
  45935. */
  45936. class RawCubeTexture extends CubeTexture {
  45937. /**
  45938. * Creates a cube texture where the raw buffers are passed in.
  45939. * @param scene defines the scene the texture is attached to
  45940. * @param data defines the array of data to use to create each face
  45941. * @param size defines the size of the textures
  45942. * @param format defines the format of the data
  45943. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  45944. * @param generateMipMaps defines if the engine should generate the mip levels
  45945. * @param invertY defines if data must be stored with Y axis inverted
  45946. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  45947. * @param compression defines the compression used (null by default)
  45948. */
  45949. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  45950. /**
  45951. * Updates the raw cube texture.
  45952. * @param data defines the data to store
  45953. * @param format defines the data format
  45954. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45955. * @param invertY defines if data must be stored with Y axis inverted
  45956. * @param compression defines the compression used (null by default)
  45957. * @param level defines which level of the texture to update
  45958. */
  45959. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45960. /**
  45961. * Updates a raw cube texture with RGBD encoded data.
  45962. * @param data defines the array of data [mipmap][face] to use to create each face
  45963. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  45964. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45965. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45966. * @returns a promsie that resolves when the operation is complete
  45967. */
  45968. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  45969. /**
  45970. * Clones the raw cube texture.
  45971. * @return a new cube texture
  45972. */
  45973. clone(): CubeTexture;
  45974. /** @hidden */
  45975. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45976. }
  45977. }
  45978. declare module BABYLON {
  45979. /**
  45980. * Raw texture can help creating a texture directly from an array of data.
  45981. * This can be super useful if you either get the data from an uncompressed source or
  45982. * if you wish to create your texture pixel by pixel.
  45983. */
  45984. class RawTexture extends Texture {
  45985. /**
  45986. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  45987. */
  45988. format: number;
  45989. private _engine;
  45990. /**
  45991. * Instantiates a new RawTexture.
  45992. * Raw texture can help creating a texture directly from an array of data.
  45993. * This can be super useful if you either get the data from an uncompressed source or
  45994. * if you wish to create your texture pixel by pixel.
  45995. * @param data define the array of data to use to create the texture
  45996. * @param width define the width of the texture
  45997. * @param height define the height of the texture
  45998. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  45999. * @param scene define the scene the texture belongs to
  46000. * @param generateMipMaps define whether mip maps should be generated or not
  46001. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46002. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46003. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46004. */
  46005. constructor(data: ArrayBufferView, width: number, height: number,
  46006. /**
  46007. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46008. */
  46009. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  46010. /**
  46011. * Updates the texture underlying data.
  46012. * @param data Define the new data of the texture
  46013. */
  46014. update(data: ArrayBufferView): void;
  46015. /**
  46016. * Creates a luminance texture from some data.
  46017. * @param data Define the texture data
  46018. * @param width Define the width of the texture
  46019. * @param height Define the height of the texture
  46020. * @param scene Define the scene the texture belongs to
  46021. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46022. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46023. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46024. * @returns the luminance texture
  46025. */
  46026. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46027. /**
  46028. * Creates a luminance alpha texture from some data.
  46029. * @param data Define the texture data
  46030. * @param width Define the width of the texture
  46031. * @param height Define the height of the texture
  46032. * @param scene Define the scene the texture belongs to
  46033. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46034. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46035. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46036. * @returns the luminance alpha texture
  46037. */
  46038. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46039. /**
  46040. * Creates an alpha texture from some data.
  46041. * @param data Define the texture data
  46042. * @param width Define the width of the texture
  46043. * @param height Define the height of the texture
  46044. * @param scene Define the scene the texture belongs to
  46045. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46046. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46047. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46048. * @returns the alpha texture
  46049. */
  46050. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46051. /**
  46052. * Creates a RGB texture from some data.
  46053. * @param data Define the texture data
  46054. * @param width Define the width of the texture
  46055. * @param height Define the height of the texture
  46056. * @param scene Define the scene the texture belongs to
  46057. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46058. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46059. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46060. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46061. * @returns the RGB alpha texture
  46062. */
  46063. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46064. /**
  46065. * Creates a RGBA texture from some data.
  46066. * @param data Define the texture data
  46067. * @param width Define the width of the texture
  46068. * @param height Define the height of the texture
  46069. * @param scene Define the scene the texture belongs to
  46070. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46071. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46072. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46073. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46074. * @returns the RGBA texture
  46075. */
  46076. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46077. /**
  46078. * Creates a R texture from some data.
  46079. * @param data Define the texture data
  46080. * @param width Define the width of the texture
  46081. * @param height Define the height of the texture
  46082. * @param scene Define the scene the texture belongs to
  46083. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46084. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46085. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46086. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46087. * @returns the R texture
  46088. */
  46089. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46090. }
  46091. }
  46092. declare module BABYLON {
  46093. /**
  46094. * Class used to store 3D textures containing user data
  46095. */
  46096. class RawTexture3D extends Texture {
  46097. /** Gets or sets the texture format to use */
  46098. format: number;
  46099. private _engine;
  46100. /**
  46101. * Create a new RawTexture3D
  46102. * @param data defines the data of the texture
  46103. * @param width defines the width of the texture
  46104. * @param height defines the height of the texture
  46105. * @param depth defines the depth of the texture
  46106. * @param format defines the texture format to use
  46107. * @param scene defines the hosting scene
  46108. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46109. * @param invertY defines if texture must be stored with Y axis inverted
  46110. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  46111. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46112. */
  46113. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46114. /** Gets or sets the texture format to use */
  46115. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46116. /**
  46117. * Update the texture with new data
  46118. * @param data defines the data to store in the texture
  46119. */
  46120. update(data: ArrayBufferView): void;
  46121. }
  46122. }
  46123. declare module BABYLON {
  46124. /**
  46125. * Creates a refraction texture used by refraction channel of the standard material.
  46126. * It is like a mirror but to see through a material.
  46127. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46128. */
  46129. class RefractionTexture extends RenderTargetTexture {
  46130. /**
  46131. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46132. * It is possible to directly set the refractionPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  46133. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46134. */
  46135. refractionPlane: Plane;
  46136. /**
  46137. * Define how deep under the surface we should see.
  46138. */
  46139. depth: number;
  46140. /**
  46141. * Creates a refraction texture used by refraction channel of the standard material.
  46142. * It is like a mirror but to see through a material.
  46143. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46144. * @param name Define the texture name
  46145. * @param size Define the size of the underlying texture
  46146. * @param scene Define the scene the refraction belongs to
  46147. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46148. */
  46149. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46150. /**
  46151. * Clone the refraction texture.
  46152. * @returns the cloned texture
  46153. */
  46154. clone(): RefractionTexture;
  46155. /**
  46156. * Serialize the texture to a JSON representation you could use in Parse later on
  46157. * @returns the serialized JSON representation
  46158. */
  46159. serialize(): any;
  46160. }
  46161. }
  46162. declare module BABYLON {
  46163. /**
  46164. * This Helps creating a texture that will be created from a camera in your scene.
  46165. * It is basically a dynamic texture that could be used to create special effects for instance.
  46166. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  46167. */
  46168. class RenderTargetTexture extends Texture {
  46169. isCube: boolean;
  46170. /**
  46171. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  46172. */
  46173. static readonly REFRESHRATE_RENDER_ONCE: number;
  46174. /**
  46175. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  46176. */
  46177. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  46178. /**
  46179. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  46180. * the central point of your effect and can save a lot of performances.
  46181. */
  46182. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  46183. /**
  46184. * Use this predicate to dynamically define the list of mesh you want to render.
  46185. * If set, the renderList property will be overwritten.
  46186. */
  46187. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  46188. private _renderList;
  46189. /**
  46190. * Use this list to define the list of mesh you want to render.
  46191. */
  46192. renderList: Nullable<Array<AbstractMesh>>;
  46193. private _hookArray;
  46194. /**
  46195. * Define if particles should be rendered in your texture.
  46196. */
  46197. renderParticles: boolean;
  46198. /**
  46199. * Define if sprites should be rendered in your texture.
  46200. */
  46201. renderSprites: boolean;
  46202. /**
  46203. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  46204. */
  46205. coordinatesMode: number;
  46206. /**
  46207. * Define the camera used to render the texture.
  46208. */
  46209. activeCamera: Nullable<Camera>;
  46210. /**
  46211. * Override the render function of the texture with your own one.
  46212. */
  46213. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  46214. /**
  46215. * Define if camera post processes should be use while rendering the texture.
  46216. */
  46217. useCameraPostProcesses: boolean;
  46218. /**
  46219. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  46220. */
  46221. ignoreCameraViewport: boolean;
  46222. private _postProcessManager;
  46223. private _postProcesses;
  46224. private _resizeObserver;
  46225. /**
  46226. * An event triggered when the texture is unbind.
  46227. */
  46228. onBeforeBindObservable: Observable<RenderTargetTexture>;
  46229. /**
  46230. * An event triggered when the texture is unbind.
  46231. */
  46232. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  46233. private _onAfterUnbindObserver;
  46234. /**
  46235. * Set a after unbind callback in the texture.
  46236. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  46237. */
  46238. onAfterUnbind: () => void;
  46239. /**
  46240. * An event triggered before rendering the texture
  46241. */
  46242. onBeforeRenderObservable: Observable<number>;
  46243. private _onBeforeRenderObserver;
  46244. /**
  46245. * Set a before render callback in the texture.
  46246. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  46247. */
  46248. onBeforeRender: (faceIndex: number) => void;
  46249. /**
  46250. * An event triggered after rendering the texture
  46251. */
  46252. onAfterRenderObservable: Observable<number>;
  46253. private _onAfterRenderObserver;
  46254. /**
  46255. * Set a after render callback in the texture.
  46256. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  46257. */
  46258. onAfterRender: (faceIndex: number) => void;
  46259. /**
  46260. * An event triggered after the texture clear
  46261. */
  46262. onClearObservable: Observable<Engine>;
  46263. private _onClearObserver;
  46264. /**
  46265. * Set a clear callback in the texture.
  46266. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  46267. */
  46268. onClear: (Engine: Engine) => void;
  46269. /**
  46270. * Define the clear color of the Render Target if it should be different from the scene.
  46271. */
  46272. clearColor: Color4;
  46273. protected _size: number | {
  46274. width: number;
  46275. height: number;
  46276. };
  46277. protected _initialSizeParameter: number | {
  46278. width: number;
  46279. height: number;
  46280. } | {
  46281. ratio: number;
  46282. };
  46283. protected _sizeRatio: Nullable<number>;
  46284. /** @hidden */
  46285. _generateMipMaps: boolean;
  46286. protected _renderingManager: RenderingManager;
  46287. /** @hidden */
  46288. _waitingRenderList: string[];
  46289. protected _doNotChangeAspectRatio: boolean;
  46290. protected _currentRefreshId: number;
  46291. protected _refreshRate: number;
  46292. protected _textureMatrix: Matrix;
  46293. protected _samples: number;
  46294. protected _renderTargetOptions: RenderTargetCreationOptions;
  46295. /**
  46296. * Gets render target creation options that were used.
  46297. */
  46298. readonly renderTargetOptions: RenderTargetCreationOptions;
  46299. protected _engine: Engine;
  46300. protected _onRatioRescale(): void;
  46301. /**
  46302. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  46303. * It must define where the camera used to render the texture is set
  46304. */
  46305. boundingBoxPosition: Vector3;
  46306. private _boundingBoxSize;
  46307. /**
  46308. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  46309. * When defined, the cubemap will switch to local mode
  46310. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46311. * @example https://www.babylonjs-playground.com/#RNASML
  46312. */
  46313. boundingBoxSize: Vector3;
  46314. /**
  46315. * In case the RTT has been created with a depth texture, get the associated
  46316. * depth texture.
  46317. * Otherwise, return null.
  46318. */
  46319. depthStencilTexture: Nullable<InternalTexture>;
  46320. /**
  46321. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  46322. * or used a shadow, depth texture...
  46323. * @param name The friendly name of the texture
  46324. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  46325. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  46326. * @param generateMipMaps True if mip maps need to be generated after render.
  46327. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  46328. * @param type The type of the buffer in the RTT (int, half float, float...)
  46329. * @param isCube True if a cube texture needs to be created
  46330. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  46331. * @param generateDepthBuffer True to generate a depth buffer
  46332. * @param generateStencilBuffer True to generate a stencil buffer
  46333. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  46334. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  46335. */
  46336. constructor(name: string, size: number | {
  46337. width: number;
  46338. height: number;
  46339. } | {
  46340. ratio: number;
  46341. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  46342. /**
  46343. * Creates a depth stencil texture.
  46344. * This is only available in WebGL 2 or with the depth texture extension available.
  46345. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  46346. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  46347. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  46348. */
  46349. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  46350. private _processSizeParameter;
  46351. /**
  46352. * Define the number of samples to use in case of MSAA.
  46353. * It defaults to one meaning no MSAA has been enabled.
  46354. */
  46355. samples: number;
  46356. /**
  46357. * Resets the refresh counter of the texture and start bak from scratch.
  46358. * Could be usefull to regenerate the texture if it is setup to render only once.
  46359. */
  46360. resetRefreshCounter(): void;
  46361. /**
  46362. * Define the refresh rate of the texture or the rendering frequency.
  46363. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  46364. */
  46365. refreshRate: number;
  46366. /**
  46367. * Adds a post process to the render target rendering passes.
  46368. * @param postProcess define the post process to add
  46369. */
  46370. addPostProcess(postProcess: PostProcess): void;
  46371. /**
  46372. * Clear all the post processes attached to the render target
  46373. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  46374. */
  46375. clearPostProcesses(dispose?: boolean): void;
  46376. /**
  46377. * Remove one of the post process from the list of attached post processes to the texture
  46378. * @param postProcess define the post process to remove from the list
  46379. */
  46380. removePostProcess(postProcess: PostProcess): void;
  46381. /** @hidden */
  46382. _shouldRender(): boolean;
  46383. /**
  46384. * Gets the actual render size of the texture.
  46385. * @returns the width of the render size
  46386. */
  46387. getRenderSize(): number;
  46388. /**
  46389. * Gets the actual render width of the texture.
  46390. * @returns the width of the render size
  46391. */
  46392. getRenderWidth(): number;
  46393. /**
  46394. * Gets the actual render height of the texture.
  46395. * @returns the height of the render size
  46396. */
  46397. getRenderHeight(): number;
  46398. /**
  46399. * Get if the texture can be rescaled or not.
  46400. */
  46401. readonly canRescale: boolean;
  46402. /**
  46403. * Resize the texture using a ratio.
  46404. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  46405. */
  46406. scale(ratio: number): void;
  46407. /**
  46408. * Get the texture reflection matrix used to rotate/transform the reflection.
  46409. * @returns the reflection matrix
  46410. */
  46411. getReflectionTextureMatrix(): Matrix;
  46412. /**
  46413. * Resize the texture to a new desired size.
  46414. * Be carrefull as it will recreate all the data in the new texture.
  46415. * @param size Define the new size. It can be:
  46416. * - a number for squared texture,
  46417. * - an object containing { width: number, height: number }
  46418. * - or an object containing a ratio { ratio: number }
  46419. */
  46420. resize(size: number | {
  46421. width: number;
  46422. height: number;
  46423. } | {
  46424. ratio: number;
  46425. }): void;
  46426. /**
  46427. * Renders all the objects from the render list into the texture.
  46428. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  46429. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  46430. */
  46431. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  46432. private _bestReflectionRenderTargetDimension;
  46433. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46434. private renderToTarget;
  46435. /**
  46436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46437. * This allowed control for front to back rendering or reversly depending of the special needs.
  46438. *
  46439. * @param renderingGroupId The rendering group id corresponding to its index
  46440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46443. */
  46444. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  46445. /**
  46446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46447. *
  46448. * @param renderingGroupId The rendering group id corresponding to its index
  46449. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46450. */
  46451. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  46452. /**
  46453. * Clones the texture.
  46454. * @returns the cloned texture
  46455. */
  46456. clone(): RenderTargetTexture;
  46457. /**
  46458. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  46459. * @returns The JSON representation of the texture
  46460. */
  46461. serialize(): any;
  46462. /**
  46463. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  46464. */
  46465. disposeFramebufferObjects(): void;
  46466. /**
  46467. * Dispose the texture and release its associated resources.
  46468. */
  46469. dispose(): void;
  46470. /** @hidden */
  46471. _rebuild(): void;
  46472. /**
  46473. * Clear the info related to rendering groups preventing retention point in material dispose.
  46474. */
  46475. freeRenderingGroups(): void;
  46476. }
  46477. }
  46478. declare module BABYLON {
  46479. /**
  46480. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  46481. * @see http://doc.babylonjs.com/babylon101/materials#texture
  46482. */
  46483. class Texture extends BaseTexture {
  46484. /** nearest is mag = nearest and min = nearest and mip = linear */
  46485. static readonly NEAREST_SAMPLINGMODE: number;
  46486. /** nearest is mag = nearest and min = nearest and mip = linear */
  46487. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  46488. /** Bilinear is mag = linear and min = linear and mip = nearest */
  46489. static readonly BILINEAR_SAMPLINGMODE: number;
  46490. /** Bilinear is mag = linear and min = linear and mip = nearest */
  46491. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  46492. /** Trilinear is mag = linear and min = linear and mip = linear */
  46493. static readonly TRILINEAR_SAMPLINGMODE: number;
  46494. /** Trilinear is mag = linear and min = linear and mip = linear */
  46495. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  46496. /** mag = nearest and min = nearest and mip = nearest */
  46497. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  46498. /** mag = nearest and min = linear and mip = nearest */
  46499. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  46500. /** mag = nearest and min = linear and mip = linear */
  46501. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  46502. /** mag = nearest and min = linear and mip = none */
  46503. static readonly NEAREST_LINEAR: number;
  46504. /** mag = nearest and min = nearest and mip = none */
  46505. static readonly NEAREST_NEAREST: number;
  46506. /** mag = linear and min = nearest and mip = nearest */
  46507. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  46508. /** mag = linear and min = nearest and mip = linear */
  46509. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  46510. /** mag = linear and min = linear and mip = none */
  46511. static readonly LINEAR_LINEAR: number;
  46512. /** mag = linear and min = nearest and mip = none */
  46513. static readonly LINEAR_NEAREST: number;
  46514. /** Explicit coordinates mode */
  46515. static readonly EXPLICIT_MODE: number;
  46516. /** Spherical coordinates mode */
  46517. static readonly SPHERICAL_MODE: number;
  46518. /** Planar coordinates mode */
  46519. static readonly PLANAR_MODE: number;
  46520. /** Cubic coordinates mode */
  46521. static readonly CUBIC_MODE: number;
  46522. /** Projection coordinates mode */
  46523. static readonly PROJECTION_MODE: number;
  46524. /** Inverse Cubic coordinates mode */
  46525. static readonly SKYBOX_MODE: number;
  46526. /** Inverse Cubic coordinates mode */
  46527. static readonly INVCUBIC_MODE: number;
  46528. /** Equirectangular coordinates mode */
  46529. static readonly EQUIRECTANGULAR_MODE: number;
  46530. /** Equirectangular Fixed coordinates mode */
  46531. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  46532. /** Equirectangular Fixed Mirrored coordinates mode */
  46533. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  46534. /** Texture is not repeating outside of 0..1 UVs */
  46535. static readonly CLAMP_ADDRESSMODE: number;
  46536. /** Texture is repeating outside of 0..1 UVs */
  46537. static readonly WRAP_ADDRESSMODE: number;
  46538. /** Texture is repeating and mirrored */
  46539. static readonly MIRROR_ADDRESSMODE: number;
  46540. /**
  46541. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  46542. */
  46543. static UseSerializedUrlIfAny: boolean;
  46544. /**
  46545. * Define the url of the texture.
  46546. */
  46547. url: Nullable<string>;
  46548. /**
  46549. * Define an offset on the texture to offset the u coordinates of the UVs
  46550. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  46551. */
  46552. uOffset: number;
  46553. /**
  46554. * Define an offset on the texture to offset the v coordinates of the UVs
  46555. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  46556. */
  46557. vOffset: number;
  46558. /**
  46559. * Define an offset on the texture to scale the u coordinates of the UVs
  46560. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  46561. */
  46562. uScale: number;
  46563. /**
  46564. * Define an offset on the texture to scale the v coordinates of the UVs
  46565. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  46566. */
  46567. vScale: number;
  46568. /**
  46569. * Define an offset on the texture to rotate around the u coordinates of the UVs
  46570. * @see http://doc.babylonjs.com/how_to/more_materials
  46571. */
  46572. uAng: number;
  46573. /**
  46574. * Define an offset on the texture to rotate around the v coordinates of the UVs
  46575. * @see http://doc.babylonjs.com/how_to/more_materials
  46576. */
  46577. vAng: number;
  46578. /**
  46579. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  46580. * @see http://doc.babylonjs.com/how_to/more_materials
  46581. */
  46582. wAng: number;
  46583. /**
  46584. * Defines the center of rotation (U)
  46585. */
  46586. uRotationCenter: number;
  46587. /**
  46588. * Defines the center of rotation (V)
  46589. */
  46590. vRotationCenter: number;
  46591. /**
  46592. * Defines the center of rotation (W)
  46593. */
  46594. wRotationCenter: number;
  46595. /**
  46596. * Are mip maps generated for this texture or not.
  46597. */
  46598. readonly noMipmap: boolean;
  46599. private _noMipmap;
  46600. /** @hidden */
  46601. _invertY: boolean;
  46602. private _rowGenerationMatrix;
  46603. private _cachedTextureMatrix;
  46604. private _projectionModeMatrix;
  46605. private _t0;
  46606. private _t1;
  46607. private _t2;
  46608. private _cachedUOffset;
  46609. private _cachedVOffset;
  46610. private _cachedUScale;
  46611. private _cachedVScale;
  46612. private _cachedUAng;
  46613. private _cachedVAng;
  46614. private _cachedWAng;
  46615. private _cachedProjectionMatrixId;
  46616. private _cachedCoordinatesMode;
  46617. /** @hidden */
  46618. _samplingMode: number;
  46619. /** @hidden */
  46620. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46621. private _deleteBuffer;
  46622. protected _format: Nullable<number>;
  46623. private _delayedOnLoad;
  46624. private _delayedOnError;
  46625. /**
  46626. * Observable triggered once the texture has been loaded.
  46627. */
  46628. onLoadObservable: Observable<Texture>;
  46629. protected _isBlocking: boolean;
  46630. /**
  46631. * Is the texture preventing material to render while loading.
  46632. * If false, a default texture will be used instead of the loading one during the preparation step.
  46633. */
  46634. isBlocking: boolean;
  46635. /**
  46636. * Get the current sampling mode associated with the texture.
  46637. */
  46638. readonly samplingMode: number;
  46639. /**
  46640. * Instantiates a new texture.
  46641. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  46642. * @see http://doc.babylonjs.com/babylon101/materials#texture
  46643. * @param url define the url of the picture to load as a texture
  46644. * @param scene define the scene the texture will belong to
  46645. * @param noMipmap define if the texture will require mip maps or not
  46646. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46647. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46648. * @param onLoad define a callback triggered when the texture has been loaded
  46649. * @param onError define a callback triggered when an error occurred during the loading session
  46650. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  46651. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  46652. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46653. */
  46654. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  46655. /**
  46656. * Update the url (and optional buffer) of this texture if url was null during construction.
  46657. * @param url the url of the texture
  46658. * @param buffer the buffer of the texture (defaults to null)
  46659. */
  46660. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  46661. /**
  46662. * Finish the loading sequence of a texture flagged as delayed load.
  46663. * @hidden
  46664. */
  46665. delayLoad(): void;
  46666. /**
  46667. * Update the sampling mode of the texture.
  46668. * Default is Trilinear mode.
  46669. *
  46670. * | Value | Type | Description |
  46671. * | ----- | ------------------ | ----------- |
  46672. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46673. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46674. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46675. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46676. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46677. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46678. * | 7 | NEAREST_LINEAR | |
  46679. * | 8 | NEAREST_NEAREST | |
  46680. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46681. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46682. * | 11 | LINEAR_LINEAR | |
  46683. * | 12 | LINEAR_NEAREST | |
  46684. *
  46685. * > _mag_: magnification filter (close to the viewer)
  46686. * > _min_: minification filter (far from the viewer)
  46687. * > _mip_: filter used between mip map levels
  46688. *@param samplingMode Define the new sampling mode of the texture
  46689. */
  46690. updateSamplingMode(samplingMode: number): void;
  46691. private _prepareRowForTextureGeneration;
  46692. /**
  46693. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  46694. * @returns the transform matrix of the texture.
  46695. */
  46696. getTextureMatrix(): Matrix;
  46697. /**
  46698. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  46699. * @returns The reflection texture transform
  46700. */
  46701. getReflectionTextureMatrix(): Matrix;
  46702. /**
  46703. * Clones the texture.
  46704. * @returns the cloned texture
  46705. */
  46706. clone(): Texture;
  46707. /**
  46708. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  46709. * @returns The JSON representation of the texture
  46710. */
  46711. serialize(): any;
  46712. /**
  46713. * Get the current class name of the texture usefull for serialization or dynamic coding.
  46714. * @returns "Texture"
  46715. */
  46716. getClassName(): string;
  46717. /**
  46718. * Dispose the texture and release its associated resources.
  46719. */
  46720. dispose(): void;
  46721. /**
  46722. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  46723. * @param parsedTexture Define the JSON representation of the texture
  46724. * @param scene Define the scene the parsed texture should be instantiated in
  46725. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  46726. * @returns The parsed texture if successful
  46727. */
  46728. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  46729. /**
  46730. * Creates a texture from its base 64 representation.
  46731. * @param data Define the base64 payload without the data: prefix
  46732. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  46733. * @param scene Define the scene the texture should belong to
  46734. * @param noMipmap Forces the texture to not create mip map information if true
  46735. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46736. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46737. * @param onLoad define a callback triggered when the texture has been loaded
  46738. * @param onError define a callback triggered when an error occurred during the loading session
  46739. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46740. * @returns the created texture
  46741. */
  46742. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  46743. /**
  46744. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  46745. * @param data Define the base64 payload without the data: prefix
  46746. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  46747. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  46748. * @param scene Define the scene the texture should belong to
  46749. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  46750. * @param noMipmap Forces the texture to not create mip map information if true
  46751. * @param invertY define if the texture needs to be inverted on the y axis during loading
  46752. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  46753. * @param onLoad define a callback triggered when the texture has been loaded
  46754. * @param onError define a callback triggered when an error occurred during the loading session
  46755. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  46756. * @returns the created texture
  46757. */
  46758. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  46759. }
  46760. }
  46761. declare module BABYLON {
  46762. /**
  46763. * Settings for finer control over video usage
  46764. */
  46765. interface VideoTextureSettings {
  46766. /**
  46767. * Applies `autoplay` to video, if specified
  46768. */
  46769. autoPlay?: boolean;
  46770. /**
  46771. * Applies `loop` to video, if specified
  46772. */
  46773. loop?: boolean;
  46774. /**
  46775. * Automatically updates internal texture from video at every frame in the render loop
  46776. */
  46777. autoUpdateTexture: boolean;
  46778. /**
  46779. * Image src displayed during the video loading or until the user interacts with the video.
  46780. */
  46781. poster?: string;
  46782. }
  46783. /**
  46784. * If you want to display a video in your scene, this is the special texture for that.
  46785. * This special texture works similar to other textures, with the exception of a few parameters.
  46786. * @see https://doc.babylonjs.com/how_to/video_texture
  46787. */
  46788. class VideoTexture extends Texture {
  46789. /**
  46790. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  46791. */
  46792. readonly autoUpdateTexture: boolean;
  46793. /**
  46794. * The video instance used by the texture internally
  46795. */
  46796. readonly video: HTMLVideoElement;
  46797. private _onUserActionRequestedObservable;
  46798. /**
  46799. * Event triggerd when a dom action is required by the user to play the video.
  46800. * This happens due to recent changes in browser policies preventing video to auto start.
  46801. */
  46802. readonly onUserActionRequestedObservable: Observable<Texture>;
  46803. private _generateMipMaps;
  46804. private _engine;
  46805. private _stillImageCaptured;
  46806. private _poster;
  46807. /**
  46808. * Creates a video texture.
  46809. * If you want to display a video in your scene, this is the special texture for that.
  46810. * This special texture works similar to other textures, with the exception of a few parameters.
  46811. * @see https://doc.babylonjs.com/how_to/video_texture
  46812. * @param name optional name, will detect from video source, if not defined
  46813. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  46814. * @param scene is obviously the current scene.
  46815. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  46816. * @param invertY is false by default but can be used to invert video on Y axis
  46817. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  46818. * @param settings allows finer control over video usage
  46819. */
  46820. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  46821. private _getName;
  46822. private _getVideo;
  46823. private _createInternalTexture;
  46824. private reset;
  46825. /**
  46826. * @hidden Internal method to initiate `update`.
  46827. */
  46828. _rebuild(): void;
  46829. /**
  46830. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  46831. */
  46832. update(): void;
  46833. /**
  46834. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  46835. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  46836. */
  46837. updateTexture(isVisible: boolean): void;
  46838. protected _updateInternalTexture: (e?: Event | undefined) => void;
  46839. /**
  46840. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  46841. * @param url New url.
  46842. */
  46843. updateURL(url: string): void;
  46844. /**
  46845. * Dispose the texture and release its associated resources.
  46846. */
  46847. dispose(): void;
  46848. /**
  46849. * Creates a video texture straight from your WebCam video feed.
  46850. * @param scene Define the scene the texture should be created in
  46851. * @param onReady Define a callback to triggered once the texture will be ready
  46852. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  46853. */
  46854. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  46855. minWidth: number;
  46856. maxWidth: number;
  46857. minHeight: number;
  46858. maxHeight: number;
  46859. deviceId: string;
  46860. }): void;
  46861. }
  46862. }
  46863. declare var DracoDecoderModule: any;
  46864. declare var WebAssembly: any;
  46865. declare module BABYLON {
  46866. /**
  46867. * Configuration for Draco compression
  46868. */
  46869. interface IDracoCompressionConfiguration {
  46870. /**
  46871. * Configuration for the decoder.
  46872. */
  46873. decoder?: {
  46874. /**
  46875. * The url to the WebAssembly module.
  46876. */
  46877. wasmUrl?: string;
  46878. /**
  46879. * The url to the WebAssembly binary.
  46880. */
  46881. wasmBinaryUrl?: string;
  46882. /**
  46883. * The url to the fallback JavaScript module.
  46884. */
  46885. fallbackUrl?: string;
  46886. };
  46887. }
  46888. /**
  46889. * Draco compression (https://google.github.io/draco/)
  46890. *
  46891. * This class wraps the Draco module.
  46892. *
  46893. * **Encoder**
  46894. *
  46895. * The encoder is not currently implemented.
  46896. *
  46897. * **Decoder**
  46898. *
  46899. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  46900. *
  46901. * To update the configuration, use the following code:
  46902. * ```javascript
  46903. * BABYLON.DracoCompression.Configuration = {
  46904. * decoder: {
  46905. * wasmUrl: "<url to the WebAssembly library>",
  46906. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  46907. * fallbackUrl: "<url to the fallback JavaScript library>",
  46908. * }
  46909. * };
  46910. * ```
  46911. *
  46912. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  46913. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  46914. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  46915. *
  46916. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  46917. * ```javascript
  46918. * var dracoCompression = new BABYLON.DracoCompression();
  46919. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  46920. * [BABYLON.VertexBuffer.PositionKind]: 0
  46921. * });
  46922. * ```
  46923. *
  46924. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  46925. */
  46926. class DracoCompression implements IDisposable {
  46927. private static _DecoderModulePromise;
  46928. /**
  46929. * The configuration. Defaults to the following urls:
  46930. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  46931. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  46932. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  46933. */
  46934. static Configuration: IDracoCompressionConfiguration;
  46935. /**
  46936. * Returns true if the decoder is available.
  46937. */
  46938. static readonly DecoderAvailable: boolean;
  46939. /**
  46940. * Constructor
  46941. */
  46942. constructor();
  46943. /**
  46944. * Stop all async operations and release resources.
  46945. */
  46946. dispose(): void;
  46947. /**
  46948. * Decode Draco compressed mesh data to vertex data.
  46949. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  46950. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  46951. * @returns A promise that resolves with the decoded vertex data
  46952. */
  46953. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  46954. [kind: string]: number;
  46955. }): Promise<VertexData>;
  46956. private static _GetDecoderModule;
  46957. private static _LoadScriptAsync;
  46958. private static _LoadFileAsync;
  46959. }
  46960. }
  46961. declare module BABYLON {
  46962. /**
  46963. * Particle emitter emitting particles from the inside of a box.
  46964. * It emits the particles randomly between 2 given directions.
  46965. */
  46966. class BoxParticleEmitter implements IParticleEmitterType {
  46967. /**
  46968. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  46969. */
  46970. direction1: Vector3;
  46971. /**
  46972. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  46973. */
  46974. direction2: Vector3;
  46975. /**
  46976. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  46977. */
  46978. minEmitBox: Vector3;
  46979. /**
  46980. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  46981. */
  46982. maxEmitBox: Vector3;
  46983. /**
  46984. * Creates a new instance BoxParticleEmitter
  46985. */
  46986. constructor();
  46987. /**
  46988. * Called by the particle System when the direction is computed for the created particle.
  46989. * @param worldMatrix is the world matrix of the particle system
  46990. * @param directionToUpdate is the direction vector to update with the result
  46991. * @param particle is the particle we are computed the direction for
  46992. */
  46993. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46994. /**
  46995. * Called by the particle System when the position is computed for the created particle.
  46996. * @param worldMatrix is the world matrix of the particle system
  46997. * @param positionToUpdate is the position vector to update with the result
  46998. * @param particle is the particle we are computed the position for
  46999. */
  47000. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47001. /**
  47002. * Clones the current emitter and returns a copy of it
  47003. * @returns the new emitter
  47004. */
  47005. clone(): BoxParticleEmitter;
  47006. /**
  47007. * Called by the GPUParticleSystem to setup the update shader
  47008. * @param effect defines the update shader
  47009. */
  47010. applyToShader(effect: Effect): void;
  47011. /**
  47012. * Returns a string to use to update the GPU particles update shader
  47013. * @returns a string containng the defines string
  47014. */
  47015. getEffectDefines(): string;
  47016. /**
  47017. * Returns the string "BoxParticleEmitter"
  47018. * @returns a string containing the class name
  47019. */
  47020. getClassName(): string;
  47021. /**
  47022. * Serializes the particle system to a JSON object.
  47023. * @returns the JSON object
  47024. */
  47025. serialize(): any;
  47026. /**
  47027. * Parse properties from a JSON object
  47028. * @param serializationObject defines the JSON object
  47029. */
  47030. parse(serializationObject: any): void;
  47031. }
  47032. }
  47033. declare module BABYLON {
  47034. /**
  47035. * Particle emitter emitting particles from the inside of a cone.
  47036. * It emits the particles alongside the cone volume from the base to the particle.
  47037. * The emission direction might be randomized.
  47038. */
  47039. class ConeParticleEmitter implements IParticleEmitterType {
  47040. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47041. directionRandomizer: number;
  47042. private _radius;
  47043. private _angle;
  47044. private _height;
  47045. /**
  47046. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  47047. */
  47048. radiusRange: number;
  47049. /**
  47050. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  47051. */
  47052. heightRange: number;
  47053. /**
  47054. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  47055. */
  47056. emitFromSpawnPointOnly: boolean;
  47057. /**
  47058. * Gets or sets the radius of the emission cone
  47059. */
  47060. radius: number;
  47061. /**
  47062. * Gets or sets the angle of the emission cone
  47063. */
  47064. angle: number;
  47065. private _buildHeight;
  47066. /**
  47067. * Creates a new instance ConeParticleEmitter
  47068. * @param radius the radius of the emission cone (1 by default)
  47069. * @param angles the cone base angle (PI by default)
  47070. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  47071. */
  47072. constructor(radius?: number, angle?: number,
  47073. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47074. directionRandomizer?: number);
  47075. /**
  47076. * Called by the particle System when the direction is computed for the created particle.
  47077. * @param worldMatrix is the world matrix of the particle system
  47078. * @param directionToUpdate is the direction vector to update with the result
  47079. * @param particle is the particle we are computed the direction for
  47080. */
  47081. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47082. /**
  47083. * Called by the particle System when the position is computed for the created particle.
  47084. * @param worldMatrix is the world matrix of the particle system
  47085. * @param positionToUpdate is the position vector to update with the result
  47086. * @param particle is the particle we are computed the position for
  47087. */
  47088. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47089. /**
  47090. * Clones the current emitter and returns a copy of it
  47091. * @returns the new emitter
  47092. */
  47093. clone(): ConeParticleEmitter;
  47094. /**
  47095. * Called by the GPUParticleSystem to setup the update shader
  47096. * @param effect defines the update shader
  47097. */
  47098. applyToShader(effect: Effect): void;
  47099. /**
  47100. * Returns a string to use to update the GPU particles update shader
  47101. * @returns a string containng the defines string
  47102. */
  47103. getEffectDefines(): string;
  47104. /**
  47105. * Returns the string "ConeParticleEmitter"
  47106. * @returns a string containing the class name
  47107. */
  47108. getClassName(): string;
  47109. /**
  47110. * Serializes the particle system to a JSON object.
  47111. * @returns the JSON object
  47112. */
  47113. serialize(): any;
  47114. /**
  47115. * Parse properties from a JSON object
  47116. * @param serializationObject defines the JSON object
  47117. */
  47118. parse(serializationObject: any): void;
  47119. }
  47120. }
  47121. declare module BABYLON {
  47122. /**
  47123. * Particle emitter emitting particles from the inside of a cylinder.
  47124. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  47125. */
  47126. class CylinderParticleEmitter implements IParticleEmitterType {
  47127. /**
  47128. * The radius of the emission cylinder.
  47129. */
  47130. radius: number;
  47131. /**
  47132. * The height of the emission cylinder.
  47133. */
  47134. height: number;
  47135. /**
  47136. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47137. */
  47138. radiusRange: number;
  47139. /**
  47140. * How much to randomize the particle direction [0-1].
  47141. */
  47142. directionRandomizer: number;
  47143. /**
  47144. * Creates a new instance CylinderParticleEmitter
  47145. * @param radius the radius of the emission cylinder (1 by default)
  47146. * @param height the height of the emission cylinder (1 by default)
  47147. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47148. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47149. */
  47150. constructor(
  47151. /**
  47152. * The radius of the emission cylinder.
  47153. */
  47154. radius?: number,
  47155. /**
  47156. * The height of the emission cylinder.
  47157. */
  47158. height?: number,
  47159. /**
  47160. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47161. */
  47162. radiusRange?: number,
  47163. /**
  47164. * How much to randomize the particle direction [0-1].
  47165. */
  47166. directionRandomizer?: number);
  47167. /**
  47168. * Called by the particle System when the direction is computed for the created particle.
  47169. * @param worldMatrix is the world matrix of the particle system
  47170. * @param directionToUpdate is the direction vector to update with the result
  47171. * @param particle is the particle we are computed the direction for
  47172. */
  47173. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47174. /**
  47175. * Called by the particle System when the position is computed for the created particle.
  47176. * @param worldMatrix is the world matrix of the particle system
  47177. * @param positionToUpdate is the position vector to update with the result
  47178. * @param particle is the particle we are computed the position for
  47179. */
  47180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47181. /**
  47182. * Clones the current emitter and returns a copy of it
  47183. * @returns the new emitter
  47184. */
  47185. clone(): CylinderParticleEmitter;
  47186. /**
  47187. * Called by the GPUParticleSystem to setup the update shader
  47188. * @param effect defines the update shader
  47189. */
  47190. applyToShader(effect: Effect): void;
  47191. /**
  47192. * Returns a string to use to update the GPU particles update shader
  47193. * @returns a string containng the defines string
  47194. */
  47195. getEffectDefines(): string;
  47196. /**
  47197. * Returns the string "CylinderParticleEmitter"
  47198. * @returns a string containing the class name
  47199. */
  47200. getClassName(): string;
  47201. /**
  47202. * Serializes the particle system to a JSON object.
  47203. * @returns the JSON object
  47204. */
  47205. serialize(): any;
  47206. /**
  47207. * Parse properties from a JSON object
  47208. * @param serializationObject defines the JSON object
  47209. */
  47210. parse(serializationObject: any): void;
  47211. }
  47212. /**
  47213. * Particle emitter emitting particles from the inside of a cylinder.
  47214. * It emits the particles randomly between two vectors.
  47215. */
  47216. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  47217. /**
  47218. * The min limit of the emission direction.
  47219. */
  47220. direction1: Vector3;
  47221. /**
  47222. * The max limit of the emission direction.
  47223. */
  47224. direction2: Vector3;
  47225. /**
  47226. * Creates a new instance CylinderDirectedParticleEmitter
  47227. * @param radius the radius of the emission cylinder (1 by default)
  47228. * @param height the height of the emission cylinder (1 by default)
  47229. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47230. * @param direction1 the min limit of the emission direction (up vector by default)
  47231. * @param direction2 the max limit of the emission direction (up vector by default)
  47232. */
  47233. constructor(radius?: number, height?: number, radiusRange?: number,
  47234. /**
  47235. * The min limit of the emission direction.
  47236. */
  47237. direction1?: Vector3,
  47238. /**
  47239. * The max limit of the emission direction.
  47240. */
  47241. direction2?: Vector3);
  47242. /**
  47243. * Called by the particle System when the direction is computed for the created particle.
  47244. * @param worldMatrix is the world matrix of the particle system
  47245. * @param directionToUpdate is the direction vector to update with the result
  47246. * @param particle is the particle we are computed the direction for
  47247. */
  47248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47249. /**
  47250. * Clones the current emitter and returns a copy of it
  47251. * @returns the new emitter
  47252. */
  47253. clone(): CylinderDirectedParticleEmitter;
  47254. /**
  47255. * Called by the GPUParticleSystem to setup the update shader
  47256. * @param effect defines the update shader
  47257. */
  47258. applyToShader(effect: Effect): void;
  47259. /**
  47260. * Returns a string to use to update the GPU particles update shader
  47261. * @returns a string containng the defines string
  47262. */
  47263. getEffectDefines(): string;
  47264. /**
  47265. * Returns the string "CylinderDirectedParticleEmitter"
  47266. * @returns a string containing the class name
  47267. */
  47268. getClassName(): string;
  47269. /**
  47270. * Serializes the particle system to a JSON object.
  47271. * @returns the JSON object
  47272. */
  47273. serialize(): any;
  47274. /**
  47275. * Parse properties from a JSON object
  47276. * @param serializationObject defines the JSON object
  47277. */
  47278. parse(serializationObject: any): void;
  47279. }
  47280. }
  47281. declare module BABYLON {
  47282. /**
  47283. * Particle emitter emitting particles from the inside of a hemisphere.
  47284. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  47285. */
  47286. class HemisphericParticleEmitter implements IParticleEmitterType {
  47287. /**
  47288. * The radius of the emission hemisphere.
  47289. */
  47290. radius: number;
  47291. /**
  47292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47293. */
  47294. radiusRange: number;
  47295. /**
  47296. * How much to randomize the particle direction [0-1].
  47297. */
  47298. directionRandomizer: number;
  47299. /**
  47300. * Creates a new instance HemisphericParticleEmitter
  47301. * @param radius the radius of the emission hemisphere (1 by default)
  47302. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47304. */
  47305. constructor(
  47306. /**
  47307. * The radius of the emission hemisphere.
  47308. */
  47309. radius?: number,
  47310. /**
  47311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47312. */
  47313. radiusRange?: number,
  47314. /**
  47315. * How much to randomize the particle direction [0-1].
  47316. */
  47317. directionRandomizer?: number);
  47318. /**
  47319. * Called by the particle System when the direction is computed for the created particle.
  47320. * @param worldMatrix is the world matrix of the particle system
  47321. * @param directionToUpdate is the direction vector to update with the result
  47322. * @param particle is the particle we are computed the direction for
  47323. */
  47324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47325. /**
  47326. * Called by the particle System when the position is computed for the created particle.
  47327. * @param worldMatrix is the world matrix of the particle system
  47328. * @param positionToUpdate is the position vector to update with the result
  47329. * @param particle is the particle we are computed the position for
  47330. */
  47331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47332. /**
  47333. * Clones the current emitter and returns a copy of it
  47334. * @returns the new emitter
  47335. */
  47336. clone(): HemisphericParticleEmitter;
  47337. /**
  47338. * Called by the GPUParticleSystem to setup the update shader
  47339. * @param effect defines the update shader
  47340. */
  47341. applyToShader(effect: Effect): void;
  47342. /**
  47343. * Returns a string to use to update the GPU particles update shader
  47344. * @returns a string containng the defines string
  47345. */
  47346. getEffectDefines(): string;
  47347. /**
  47348. * Returns the string "HemisphericParticleEmitter"
  47349. * @returns a string containing the class name
  47350. */
  47351. getClassName(): string;
  47352. /**
  47353. * Serializes the particle system to a JSON object.
  47354. * @returns the JSON object
  47355. */
  47356. serialize(): any;
  47357. /**
  47358. * Parse properties from a JSON object
  47359. * @param serializationObject defines the JSON object
  47360. */
  47361. parse(serializationObject: any): void;
  47362. }
  47363. }
  47364. declare module BABYLON {
  47365. /**
  47366. * Particle emitter represents a volume emitting particles.
  47367. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  47368. */
  47369. interface IParticleEmitterType {
  47370. /**
  47371. * Called by the particle System when the direction is computed for the created particle.
  47372. * @param worldMatrix is the world matrix of the particle system
  47373. * @param directionToUpdate is the direction vector to update with the result
  47374. * @param particle is the particle we are computed the direction for
  47375. */
  47376. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47377. /**
  47378. * Called by the particle System when the position is computed for the created particle.
  47379. * @param worldMatrix is the world matrix of the particle system
  47380. * @param positionToUpdate is the position vector to update with the result
  47381. * @param particle is the particle we are computed the position for
  47382. */
  47383. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47384. /**
  47385. * Clones the current emitter and returns a copy of it
  47386. * @returns the new emitter
  47387. */
  47388. clone(): IParticleEmitterType;
  47389. /**
  47390. * Called by the GPUParticleSystem to setup the update shader
  47391. * @param effect defines the update shader
  47392. */
  47393. applyToShader(effect: Effect): void;
  47394. /**
  47395. * Returns a string to use to update the GPU particles update shader
  47396. * @returns the effect defines string
  47397. */
  47398. getEffectDefines(): string;
  47399. /**
  47400. * Returns a string representing the class name
  47401. * @returns a string containing the class name
  47402. */
  47403. getClassName(): string;
  47404. /**
  47405. * Serializes the particle system to a JSON object.
  47406. * @returns the JSON object
  47407. */
  47408. serialize(): any;
  47409. /**
  47410. * Parse properties from a JSON object
  47411. * @param serializationObject defines the JSON object
  47412. */
  47413. parse(serializationObject: any): void;
  47414. }
  47415. }
  47416. declare module BABYLON {
  47417. /**
  47418. * Particle emitter emitting particles from a point.
  47419. * It emits the particles randomly between 2 given directions.
  47420. */
  47421. class PointParticleEmitter implements IParticleEmitterType {
  47422. /**
  47423. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47424. */
  47425. direction1: Vector3;
  47426. /**
  47427. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47428. */
  47429. direction2: Vector3;
  47430. /**
  47431. * Creates a new instance PointParticleEmitter
  47432. */
  47433. constructor();
  47434. /**
  47435. * Called by the particle System when the direction is computed for the created particle.
  47436. * @param worldMatrix is the world matrix of the particle system
  47437. * @param directionToUpdate is the direction vector to update with the result
  47438. * @param particle is the particle we are computed the direction for
  47439. */
  47440. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47441. /**
  47442. * Called by the particle System when the position is computed for the created particle.
  47443. * @param worldMatrix is the world matrix of the particle system
  47444. * @param positionToUpdate is the position vector to update with the result
  47445. * @param particle is the particle we are computed the position for
  47446. */
  47447. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47448. /**
  47449. * Clones the current emitter and returns a copy of it
  47450. * @returns the new emitter
  47451. */
  47452. clone(): PointParticleEmitter;
  47453. /**
  47454. * Called by the GPUParticleSystem to setup the update shader
  47455. * @param effect defines the update shader
  47456. */
  47457. applyToShader(effect: Effect): void;
  47458. /**
  47459. * Returns a string to use to update the GPU particles update shader
  47460. * @returns a string containng the defines string
  47461. */
  47462. getEffectDefines(): string;
  47463. /**
  47464. * Returns the string "PointParticleEmitter"
  47465. * @returns a string containing the class name
  47466. */
  47467. getClassName(): string;
  47468. /**
  47469. * Serializes the particle system to a JSON object.
  47470. * @returns the JSON object
  47471. */
  47472. serialize(): any;
  47473. /**
  47474. * Parse properties from a JSON object
  47475. * @param serializationObject defines the JSON object
  47476. */
  47477. parse(serializationObject: any): void;
  47478. }
  47479. }
  47480. declare module BABYLON {
  47481. /**
  47482. * Particle emitter emitting particles from the inside of a sphere.
  47483. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  47484. */
  47485. class SphereParticleEmitter implements IParticleEmitterType {
  47486. /**
  47487. * The radius of the emission sphere.
  47488. */
  47489. radius: number;
  47490. /**
  47491. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47492. */
  47493. radiusRange: number;
  47494. /**
  47495. * How much to randomize the particle direction [0-1].
  47496. */
  47497. directionRandomizer: number;
  47498. /**
  47499. * Creates a new instance SphereParticleEmitter
  47500. * @param radius the radius of the emission sphere (1 by default)
  47501. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47502. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47503. */
  47504. constructor(
  47505. /**
  47506. * The radius of the emission sphere.
  47507. */
  47508. radius?: number,
  47509. /**
  47510. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47511. */
  47512. radiusRange?: number,
  47513. /**
  47514. * How much to randomize the particle direction [0-1].
  47515. */
  47516. directionRandomizer?: number);
  47517. /**
  47518. * Called by the particle System when the direction is computed for the created particle.
  47519. * @param worldMatrix is the world matrix of the particle system
  47520. * @param directionToUpdate is the direction vector to update with the result
  47521. * @param particle is the particle we are computed the direction for
  47522. */
  47523. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47524. /**
  47525. * Called by the particle System when the position is computed for the created particle.
  47526. * @param worldMatrix is the world matrix of the particle system
  47527. * @param positionToUpdate is the position vector to update with the result
  47528. * @param particle is the particle we are computed the position for
  47529. */
  47530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47531. /**
  47532. * Clones the current emitter and returns a copy of it
  47533. * @returns the new emitter
  47534. */
  47535. clone(): SphereParticleEmitter;
  47536. /**
  47537. * Called by the GPUParticleSystem to setup the update shader
  47538. * @param effect defines the update shader
  47539. */
  47540. applyToShader(effect: Effect): void;
  47541. /**
  47542. * Returns a string to use to update the GPU particles update shader
  47543. * @returns a string containng the defines string
  47544. */
  47545. getEffectDefines(): string;
  47546. /**
  47547. * Returns the string "SphereParticleEmitter"
  47548. * @returns a string containing the class name
  47549. */
  47550. getClassName(): string;
  47551. /**
  47552. * Serializes the particle system to a JSON object.
  47553. * @returns the JSON object
  47554. */
  47555. serialize(): any;
  47556. /**
  47557. * Parse properties from a JSON object
  47558. * @param serializationObject defines the JSON object
  47559. */
  47560. parse(serializationObject: any): void;
  47561. }
  47562. /**
  47563. * Particle emitter emitting particles from the inside of a sphere.
  47564. * It emits the particles randomly between two vectors.
  47565. */
  47566. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  47567. /**
  47568. * The min limit of the emission direction.
  47569. */
  47570. direction1: Vector3;
  47571. /**
  47572. * The max limit of the emission direction.
  47573. */
  47574. direction2: Vector3;
  47575. /**
  47576. * Creates a new instance SphereDirectedParticleEmitter
  47577. * @param radius the radius of the emission sphere (1 by default)
  47578. * @param direction1 the min limit of the emission direction (up vector by default)
  47579. * @param direction2 the max limit of the emission direction (up vector by default)
  47580. */
  47581. constructor(radius?: number,
  47582. /**
  47583. * The min limit of the emission direction.
  47584. */
  47585. direction1?: Vector3,
  47586. /**
  47587. * The max limit of the emission direction.
  47588. */
  47589. direction2?: Vector3);
  47590. /**
  47591. * Called by the particle System when the direction is computed for the created particle.
  47592. * @param worldMatrix is the world matrix of the particle system
  47593. * @param directionToUpdate is the direction vector to update with the result
  47594. * @param particle is the particle we are computed the direction for
  47595. */
  47596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47597. /**
  47598. * Clones the current emitter and returns a copy of it
  47599. * @returns the new emitter
  47600. */
  47601. clone(): SphereDirectedParticleEmitter;
  47602. /**
  47603. * Called by the GPUParticleSystem to setup the update shader
  47604. * @param effect defines the update shader
  47605. */
  47606. applyToShader(effect: Effect): void;
  47607. /**
  47608. * Returns a string to use to update the GPU particles update shader
  47609. * @returns a string containng the defines string
  47610. */
  47611. getEffectDefines(): string;
  47612. /**
  47613. * Returns the string "SphereDirectedParticleEmitter"
  47614. * @returns a string containing the class name
  47615. */
  47616. getClassName(): string;
  47617. /**
  47618. * Serializes the particle system to a JSON object.
  47619. * @returns the JSON object
  47620. */
  47621. serialize(): any;
  47622. /**
  47623. * Parse properties from a JSON object
  47624. * @param serializationObject defines the JSON object
  47625. */
  47626. parse(serializationObject: any): void;
  47627. }
  47628. }
  47629. declare module BABYLON {
  47630. /** @hidden */
  47631. class CannonJSPlugin implements IPhysicsEnginePlugin {
  47632. private _useDeltaForWorldStep;
  47633. world: any;
  47634. name: string;
  47635. private _physicsMaterials;
  47636. private _fixedTimeStep;
  47637. BJSCANNON: any;
  47638. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  47639. setGravity(gravity: Vector3): void;
  47640. setTimeStep(timeStep: number): void;
  47641. getTimeStep(): number;
  47642. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47643. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47644. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47645. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47646. private _processChildMeshes;
  47647. removePhysicsBody(impostor: PhysicsImpostor): void;
  47648. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47649. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47650. private _addMaterial;
  47651. private _checkWithEpsilon;
  47652. private _createShape;
  47653. private _createHeightmap;
  47654. private _minus90X;
  47655. private _plus90X;
  47656. private _tmpPosition;
  47657. private _tmpDeltaPosition;
  47658. private _tmpUnityRotation;
  47659. private _updatePhysicsBodyTransformation;
  47660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47662. isSupported(): boolean;
  47663. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47664. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47665. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47666. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47667. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47668. getBodyMass(impostor: PhysicsImpostor): number;
  47669. getBodyFriction(impostor: PhysicsImpostor): number;
  47670. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47671. getBodyRestitution(impostor: PhysicsImpostor): number;
  47672. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47673. sleepBody(impostor: PhysicsImpostor): void;
  47674. wakeUpBody(impostor: PhysicsImpostor): void;
  47675. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47676. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47677. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47678. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47679. getRadius(impostor: PhysicsImpostor): number;
  47680. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47681. dispose(): void;
  47682. private _extendNamespace;
  47683. }
  47684. }
  47685. declare module BABYLON {
  47686. /** @hidden */
  47687. class OimoJSPlugin implements IPhysicsEnginePlugin {
  47688. world: any;
  47689. name: string;
  47690. BJSOIMO: any;
  47691. constructor(iterations?: number);
  47692. setGravity(gravity: Vector3): void;
  47693. setTimeStep(timeStep: number): void;
  47694. getTimeStep(): number;
  47695. private _tmpImpostorsArray;
  47696. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47697. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47698. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47699. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47700. private _tmpPositionVector;
  47701. removePhysicsBody(impostor: PhysicsImpostor): void;
  47702. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47703. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47704. isSupported(): boolean;
  47705. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47706. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47707. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47708. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47709. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47710. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47711. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47712. getBodyMass(impostor: PhysicsImpostor): number;
  47713. getBodyFriction(impostor: PhysicsImpostor): number;
  47714. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47715. getBodyRestitution(impostor: PhysicsImpostor): number;
  47716. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47717. sleepBody(impostor: PhysicsImpostor): void;
  47718. wakeUpBody(impostor: PhysicsImpostor): void;
  47719. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47720. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47721. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47722. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47723. getRadius(impostor: PhysicsImpostor): number;
  47724. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47725. dispose(): void;
  47726. }
  47727. }
  47728. declare module BABYLON {
  47729. /**
  47730. * This represents a set of one or more post processes in Babylon.
  47731. * A post process can be used to apply a shader to a texture after it is rendered.
  47732. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47733. */
  47734. class PostProcessRenderEffect {
  47735. private _postProcesses;
  47736. private _getPostProcesses;
  47737. private _singleInstance;
  47738. private _cameras;
  47739. private _indicesForCamera;
  47740. /**
  47741. * Name of the effect
  47742. * @hidden
  47743. */
  47744. _name: string;
  47745. /**
  47746. * Instantiates a post process render effect.
  47747. * A post process can be used to apply a shader to a texture after it is rendered.
  47748. * @param engine The engine the effect is tied to
  47749. * @param name The name of the effect
  47750. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  47751. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  47752. */
  47753. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  47754. /**
  47755. * Checks if all the post processes in the effect are supported.
  47756. */
  47757. readonly isSupported: boolean;
  47758. /**
  47759. * Updates the current state of the effect
  47760. * @hidden
  47761. */
  47762. _update(): void;
  47763. /**
  47764. * Attaches the effect on cameras
  47765. * @param cameras The camera to attach to.
  47766. * @hidden
  47767. */
  47768. _attachCameras(cameras: Camera): void;
  47769. /**
  47770. * Attaches the effect on cameras
  47771. * @param cameras The camera to attach to.
  47772. * @hidden
  47773. */
  47774. _attachCameras(cameras: Camera[]): void;
  47775. /**
  47776. * Detatches the effect on cameras
  47777. * @param cameras The camera to detatch from.
  47778. * @hidden
  47779. */
  47780. _detachCameras(cameras: Camera): void;
  47781. /**
  47782. * Detatches the effect on cameras
  47783. * @param cameras The camera to detatch from.
  47784. * @hidden
  47785. */
  47786. _detachCameras(cameras: Camera[]): void;
  47787. /**
  47788. * Enables the effect on given cameras
  47789. * @param cameras The camera to enable.
  47790. * @hidden
  47791. */
  47792. _enable(cameras: Camera): void;
  47793. /**
  47794. * Enables the effect on given cameras
  47795. * @param cameras The camera to enable.
  47796. * @hidden
  47797. */
  47798. _enable(cameras: Nullable<Camera[]>): void;
  47799. /**
  47800. * Disables the effect on the given cameras
  47801. * @param cameras The camera to disable.
  47802. * @hidden
  47803. */
  47804. _disable(cameras: Camera): void;
  47805. /**
  47806. * Disables the effect on the given cameras
  47807. * @param cameras The camera to disable.
  47808. * @hidden
  47809. */
  47810. _disable(cameras: Nullable<Camera[]>): void;
  47811. /**
  47812. * Gets a list of the post processes contained in the effect.
  47813. * @param camera The camera to get the post processes on.
  47814. * @returns The list of the post processes in the effect.
  47815. */
  47816. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  47817. }
  47818. }
  47819. declare module BABYLON {
  47820. /**
  47821. * PostProcessRenderPipeline
  47822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47823. */
  47824. class PostProcessRenderPipeline {
  47825. private engine;
  47826. private _renderEffects;
  47827. private _renderEffectsForIsolatedPass;
  47828. /**
  47829. * @hidden
  47830. */
  47831. protected _cameras: Camera[];
  47832. /** @hidden */
  47833. _name: string;
  47834. /**
  47835. * Initializes a PostProcessRenderPipeline
  47836. * @param engine engine to add the pipeline to
  47837. * @param name name of the pipeline
  47838. */
  47839. constructor(engine: Engine, name: string);
  47840. /**
  47841. * "PostProcessRenderPipeline"
  47842. * @returns "PostProcessRenderPipeline"
  47843. */
  47844. getClassName(): string;
  47845. /**
  47846. * If all the render effects in the pipeline are support
  47847. */
  47848. readonly isSupported: boolean;
  47849. /**
  47850. * Adds an effect to the pipeline
  47851. * @param renderEffect the effect to add
  47852. */
  47853. addEffect(renderEffect: PostProcessRenderEffect): void;
  47854. /** @hidden */
  47855. _rebuild(): void;
  47856. /** @hidden */
  47857. _enableEffect(renderEffectName: string, cameras: Camera): void;
  47858. /** @hidden */
  47859. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  47860. /** @hidden */
  47861. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  47862. /** @hidden */
  47863. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  47864. /** @hidden */
  47865. _attachCameras(cameras: Camera, unique: boolean): void;
  47866. /** @hidden */
  47867. _attachCameras(cameras: Camera[], unique: boolean): void;
  47868. /** @hidden */
  47869. _detachCameras(cameras: Camera): void;
  47870. /** @hidden */
  47871. _detachCameras(cameras: Nullable<Camera[]>): void;
  47872. /** @hidden */
  47873. _update(): void;
  47874. /** @hidden */
  47875. _reset(): void;
  47876. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  47877. /**
  47878. * Disposes of the pipeline
  47879. */
  47880. dispose(): void;
  47881. }
  47882. }
  47883. declare module BABYLON {
  47884. /**
  47885. * PostProcessRenderPipelineManager class
  47886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47887. */
  47888. class PostProcessRenderPipelineManager {
  47889. private _renderPipelines;
  47890. /**
  47891. * Initializes a PostProcessRenderPipelineManager
  47892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47893. */
  47894. constructor();
  47895. /**
  47896. * Adds a pipeline to the manager
  47897. * @param renderPipeline The pipeline to add
  47898. */
  47899. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  47900. /**
  47901. * Attaches a camera to the pipeline
  47902. * @param renderPipelineName The name of the pipeline to attach to
  47903. * @param cameras the camera to attach
  47904. * @param unique if the camera can be attached multiple times to the pipeline
  47905. */
  47906. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  47907. /**
  47908. * Detaches a camera from the pipeline
  47909. * @param renderPipelineName The name of the pipeline to detach from
  47910. * @param cameras the camera to detach
  47911. */
  47912. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  47913. /**
  47914. * Enables an effect by name on a pipeline
  47915. * @param renderPipelineName the name of the pipeline to enable the effect in
  47916. * @param renderEffectName the name of the effect to enable
  47917. * @param cameras the cameras that the effect should be enabled on
  47918. */
  47919. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  47920. /**
  47921. * Disables an effect by name on a pipeline
  47922. * @param renderPipelineName the name of the pipeline to disable the effect in
  47923. * @param renderEffectName the name of the effect to disable
  47924. * @param cameras the cameras that the effect should be disabled on
  47925. */
  47926. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  47927. /**
  47928. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  47929. */
  47930. update(): void;
  47931. /** @hidden */
  47932. _rebuild(): void;
  47933. /**
  47934. * Disposes of the manager and pipelines
  47935. */
  47936. dispose(): void;
  47937. }
  47938. }
  47939. declare module BABYLON {
  47940. interface Scene {
  47941. /** @hidden (Backing field) */
  47942. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  47943. /**
  47944. * Gets the postprocess render pipeline manager
  47945. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  47946. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  47947. */
  47948. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  47949. }
  47950. /**
  47951. * Defines the Render Pipeline scene component responsible to rendering pipelines
  47952. */
  47953. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  47954. /**
  47955. * The component name helpfull to identify the component in the list of scene components.
  47956. */
  47957. readonly name: string;
  47958. /**
  47959. * The scene the component belongs to.
  47960. */
  47961. scene: Scene;
  47962. /**
  47963. * Creates a new instance of the component for the given scene
  47964. * @param scene Defines the scene to register the component in
  47965. */
  47966. constructor(scene: Scene);
  47967. /**
  47968. * Registers the component in a given scene
  47969. */
  47970. register(): void;
  47971. /**
  47972. * Rebuilds the elements related to this component in case of
  47973. * context lost for instance.
  47974. */
  47975. rebuild(): void;
  47976. /**
  47977. * Disposes the component and the associated ressources
  47978. */
  47979. dispose(): void;
  47980. private _gatherRenderTargets;
  47981. }
  47982. }
  47983. declare module BABYLON {
  47984. /**
  47985. * Helper class dealing with the extraction of spherical polynomial dataArray
  47986. * from a cube map.
  47987. */
  47988. class CubeMapToSphericalPolynomialTools {
  47989. private static FileFaces;
  47990. /**
  47991. * Converts a texture to the according Spherical Polynomial data.
  47992. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47993. *
  47994. * @param texture The texture to extract the information from.
  47995. * @return The Spherical Polynomial data.
  47996. */
  47997. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47998. /**
  47999. * Converts a cubemap to the according Spherical Polynomial data.
  48000. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48001. *
  48002. * @param cubeInfo The Cube map to extract the information from.
  48003. * @return The Spherical Polynomial data.
  48004. */
  48005. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48006. }
  48007. }
  48008. declare module BABYLON {
  48009. /**
  48010. * Header information of HDR texture files.
  48011. */
  48012. interface HDRInfo {
  48013. /**
  48014. * The height of the texture in pixels.
  48015. */
  48016. height: number;
  48017. /**
  48018. * The width of the texture in pixels.
  48019. */
  48020. width: number;
  48021. /**
  48022. * The index of the beginning of the data in the binary file.
  48023. */
  48024. dataPosition: number;
  48025. }
  48026. /**
  48027. * This groups tools to convert HDR texture to native colors array.
  48028. */
  48029. class HDRTools {
  48030. private static Ldexp;
  48031. private static Rgbe2float;
  48032. private static readStringLine;
  48033. /**
  48034. * Reads header information from an RGBE texture stored in a native array.
  48035. * More information on this format are available here:
  48036. * https://en.wikipedia.org/wiki/RGBE_image_format
  48037. *
  48038. * @param uint8array The binary file stored in native array.
  48039. * @return The header information.
  48040. */
  48041. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48042. /**
  48043. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48044. * This RGBE texture needs to store the information as a panorama.
  48045. *
  48046. * More information on this format are available here:
  48047. * https://en.wikipedia.org/wiki/RGBE_image_format
  48048. *
  48049. * @param buffer The binary file stored in an array buffer.
  48050. * @param size The expected size of the extracted cubemap.
  48051. * @return The Cube Map information.
  48052. */
  48053. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48054. /**
  48055. * Returns the pixels data extracted from an RGBE texture.
  48056. * This pixels will be stored left to right up to down in the R G B order in one array.
  48057. *
  48058. * More information on this format are available here:
  48059. * https://en.wikipedia.org/wiki/RGBE_image_format
  48060. *
  48061. * @param uint8array The binary file stored in an array buffer.
  48062. * @param hdrInfo The header information of the file.
  48063. * @return The pixels data in RGB right to left up to down order.
  48064. */
  48065. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48066. private static RGBE_ReadPixels_RLE;
  48067. }
  48068. }
  48069. declare module BABYLON {
  48070. /**
  48071. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48072. */
  48073. interface CubeMapInfo {
  48074. /**
  48075. * The pixel array for the front face.
  48076. * This is stored in format, left to right, up to down format.
  48077. */
  48078. front: Nullable<ArrayBufferView>;
  48079. /**
  48080. * The pixel array for the back face.
  48081. * This is stored in format, left to right, up to down format.
  48082. */
  48083. back: Nullable<ArrayBufferView>;
  48084. /**
  48085. * The pixel array for the left face.
  48086. * This is stored in format, left to right, up to down format.
  48087. */
  48088. left: Nullable<ArrayBufferView>;
  48089. /**
  48090. * The pixel array for the right face.
  48091. * This is stored in format, left to right, up to down format.
  48092. */
  48093. right: Nullable<ArrayBufferView>;
  48094. /**
  48095. * The pixel array for the up face.
  48096. * This is stored in format, left to right, up to down format.
  48097. */
  48098. up: Nullable<ArrayBufferView>;
  48099. /**
  48100. * The pixel array for the down face.
  48101. * This is stored in format, left to right, up to down format.
  48102. */
  48103. down: Nullable<ArrayBufferView>;
  48104. /**
  48105. * The size of the cubemap stored.
  48106. *
  48107. * Each faces will be size * size pixels.
  48108. */
  48109. size: number;
  48110. /**
  48111. * The format of the texture.
  48112. *
  48113. * RGBA, RGB.
  48114. */
  48115. format: number;
  48116. /**
  48117. * The type of the texture data.
  48118. *
  48119. * UNSIGNED_INT, FLOAT.
  48120. */
  48121. type: number;
  48122. /**
  48123. * Specifies whether the texture is in gamma space.
  48124. */
  48125. gammaSpace: boolean;
  48126. }
  48127. /**
  48128. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  48129. */
  48130. class PanoramaToCubeMapTools {
  48131. private static FACE_FRONT;
  48132. private static FACE_BACK;
  48133. private static FACE_RIGHT;
  48134. private static FACE_LEFT;
  48135. private static FACE_DOWN;
  48136. private static FACE_UP;
  48137. /**
  48138. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48139. *
  48140. * @param float32Array The source data.
  48141. * @param inputWidth The width of the input panorama.
  48142. * @param inputHeight The height of the input panorama.
  48143. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48144. * @return The cubemap data
  48145. */
  48146. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48147. private static CreateCubemapTexture;
  48148. private static CalcProjectionSpherical;
  48149. }
  48150. }
  48151. declare module BABYLON {
  48152. }
  48153. declare module BABYLON {
  48154. }
  48155. declare module BABYLON {
  48156. }
  48157. declare module BABYLON {
  48158. }
  48159. declare module BABYLON {
  48160. /**
  48161. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  48162. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48163. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48164. */
  48165. class CustomProceduralTexture extends ProceduralTexture {
  48166. private _animate;
  48167. private _time;
  48168. private _config;
  48169. private _texturePath;
  48170. /**
  48171. * Instantiates a new Custom Procedural Texture.
  48172. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  48173. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48174. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48175. * @param name Define the name of the texture
  48176. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48177. * @param size Define the size of the texture to create
  48178. * @param scene Define the scene the texture belongs to
  48179. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48180. * @param generateMipMaps Define if the texture should creates mip maps or not
  48181. */
  48182. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48183. private _loadJson;
  48184. /**
  48185. * Is the texture ready to be used ? (rendered at least once)
  48186. * @returns true if ready, otherwise, false.
  48187. */
  48188. isReady(): boolean;
  48189. /**
  48190. * Render the texture to its associated render target.
  48191. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48192. */
  48193. render(useCameraPostProcess?: boolean): void;
  48194. /**
  48195. * Update the list of dependant textures samplers in the shader.
  48196. */
  48197. updateTextures(): void;
  48198. /**
  48199. * Update the uniform values of the procedural texture in the shader.
  48200. */
  48201. updateShaderUniforms(): void;
  48202. /**
  48203. * Define if the texture animates or not.
  48204. */
  48205. animate: boolean;
  48206. }
  48207. }
  48208. declare module BABYLON {
  48209. /**
  48210. * Class used to generate noise procedural textures
  48211. */
  48212. class NoiseProceduralTexture extends ProceduralTexture {
  48213. private _time;
  48214. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48215. brightness: number;
  48216. /** Defines the number of octaves to process */
  48217. octaves: number;
  48218. /** Defines the level of persistence (0.8 by default) */
  48219. persistence: number;
  48220. /** Gets or sets animation speed factor (default is 1) */
  48221. animationSpeedFactor: number;
  48222. /**
  48223. * Creates a new NoiseProceduralTexture
  48224. * @param name defines the name fo the texture
  48225. * @param size defines the size of the texture (default is 256)
  48226. * @param scene defines the hosting scene
  48227. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48228. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48229. */
  48230. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48231. private _updateShaderUniforms;
  48232. protected _getDefines(): string;
  48233. /** Generate the current state of the procedural texture */
  48234. render(useCameraPostProcess?: boolean): void;
  48235. /**
  48236. * Serializes this noise procedural texture
  48237. * @returns a serialized noise procedural texture object
  48238. */
  48239. serialize(): any;
  48240. /**
  48241. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48242. * @param parsedTexture defines parsed texture data
  48243. * @param scene defines the current scene
  48244. * @param rootUrl defines the root URL containing noise procedural texture information
  48245. * @returns a parsed NoiseProceduralTexture
  48246. */
  48247. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  48248. }
  48249. }
  48250. declare module BABYLON {
  48251. /**
  48252. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  48253. * This is the base class of any Procedural texture and contains most of the shareable code.
  48254. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48255. */
  48256. class ProceduralTexture extends Texture {
  48257. isCube: boolean;
  48258. /**
  48259. * Define if the texture is enabled or not (disabled texture will not render)
  48260. */
  48261. isEnabled: boolean;
  48262. /**
  48263. * Define if the texture must be cleared before rendering (default is true)
  48264. */
  48265. autoClear: boolean;
  48266. /**
  48267. * Callback called when the texture is generated
  48268. */
  48269. onGenerated: () => void;
  48270. /**
  48271. * Event raised when the texture is generated
  48272. */
  48273. onGeneratedObservable: Observable<ProceduralTexture>;
  48274. /** @hidden */
  48275. _generateMipMaps: boolean;
  48276. /** @hidden **/
  48277. _effect: Effect;
  48278. /** @hidden */
  48279. _textures: {
  48280. [key: string]: Texture;
  48281. };
  48282. private _size;
  48283. private _currentRefreshId;
  48284. private _refreshRate;
  48285. private _vertexBuffers;
  48286. private _indexBuffer;
  48287. private _uniforms;
  48288. private _samplers;
  48289. private _fragment;
  48290. private _floats;
  48291. private _ints;
  48292. private _floatsArrays;
  48293. private _colors3;
  48294. private _colors4;
  48295. private _vectors2;
  48296. private _vectors3;
  48297. private _matrices;
  48298. private _fallbackTexture;
  48299. private _fallbackTextureUsed;
  48300. private _engine;
  48301. private _cachedDefines;
  48302. private _contentUpdateId;
  48303. private _contentData;
  48304. /**
  48305. * Instantiates a new procedural texture.
  48306. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  48307. * This is the base class of any Procedural texture and contains most of the shareable code.
  48308. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48309. * @param name Define the name of the texture
  48310. * @param size Define the size of the texture to create
  48311. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  48312. * @param scene Define the scene the texture belongs to
  48313. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48314. * @param generateMipMaps Define if the texture should creates mip maps or not
  48315. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  48316. */
  48317. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  48318. /**
  48319. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  48320. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  48321. */
  48322. getContent(): Nullable<ArrayBufferView>;
  48323. private _createIndexBuffer;
  48324. /** @hidden */
  48325. _rebuild(): void;
  48326. /**
  48327. * Resets the texture in order to recreate its associated resources.
  48328. * This can be called in case of context loss
  48329. */
  48330. reset(): void;
  48331. protected _getDefines(): string;
  48332. /**
  48333. * Is the texture ready to be used ? (rendered at least once)
  48334. * @returns true if ready, otherwise, false.
  48335. */
  48336. isReady(): boolean;
  48337. /**
  48338. * Resets the refresh counter of the texture and start bak from scratch.
  48339. * Could be usefull to regenerate the texture if it is setup to render only once.
  48340. */
  48341. resetRefreshCounter(): void;
  48342. /**
  48343. * Set the fragment shader to use in order to render the texture.
  48344. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  48345. */
  48346. setFragment(fragment: any): void;
  48347. /**
  48348. * Define the refresh rate of the texture or the rendering frequency.
  48349. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48350. */
  48351. refreshRate: number;
  48352. /** @hidden */
  48353. _shouldRender(): boolean;
  48354. /**
  48355. * Get the size the texture is rendering at.
  48356. * @returns the size (texture is always squared)
  48357. */
  48358. getRenderSize(): number;
  48359. /**
  48360. * Resize the texture to new value.
  48361. * @param size Define the new size the texture should have
  48362. * @param generateMipMaps Define whether the new texture should create mip maps
  48363. */
  48364. resize(size: number, generateMipMaps: boolean): void;
  48365. private _checkUniform;
  48366. /**
  48367. * Set a texture in the shader program used to render.
  48368. * @param name Define the name of the uniform samplers as defined in the shader
  48369. * @param texture Define the texture to bind to this sampler
  48370. * @return the texture itself allowing "fluent" like uniform updates
  48371. */
  48372. setTexture(name: string, texture: Texture): ProceduralTexture;
  48373. /**
  48374. * Set a float in the shader.
  48375. * @param name Define the name of the uniform as defined in the shader
  48376. * @param value Define the value to give to the uniform
  48377. * @return the texture itself allowing "fluent" like uniform updates
  48378. */
  48379. setFloat(name: string, value: number): ProceduralTexture;
  48380. /**
  48381. * Set a int in the shader.
  48382. * @param name Define the name of the uniform as defined in the shader
  48383. * @param value Define the value to give to the uniform
  48384. * @return the texture itself allowing "fluent" like uniform updates
  48385. */
  48386. setInt(name: string, value: number): ProceduralTexture;
  48387. /**
  48388. * Set an array of floats in the shader.
  48389. * @param name Define the name of the uniform as defined in the shader
  48390. * @param value Define the value to give to the uniform
  48391. * @return the texture itself allowing "fluent" like uniform updates
  48392. */
  48393. setFloats(name: string, value: number[]): ProceduralTexture;
  48394. /**
  48395. * Set a vec3 in the shader from a Color3.
  48396. * @param name Define the name of the uniform as defined in the shader
  48397. * @param value Define the value to give to the uniform
  48398. * @return the texture itself allowing "fluent" like uniform updates
  48399. */
  48400. setColor3(name: string, value: Color3): ProceduralTexture;
  48401. /**
  48402. * Set a vec4 in the shader from a Color4.
  48403. * @param name Define the name of the uniform as defined in the shader
  48404. * @param value Define the value to give to the uniform
  48405. * @return the texture itself allowing "fluent" like uniform updates
  48406. */
  48407. setColor4(name: string, value: Color4): ProceduralTexture;
  48408. /**
  48409. * Set a vec2 in the shader from a Vector2.
  48410. * @param name Define the name of the uniform as defined in the shader
  48411. * @param value Define the value to give to the uniform
  48412. * @return the texture itself allowing "fluent" like uniform updates
  48413. */
  48414. setVector2(name: string, value: Vector2): ProceduralTexture;
  48415. /**
  48416. * Set a vec3 in the shader from a Vector3.
  48417. * @param name Define the name of the uniform as defined in the shader
  48418. * @param value Define the value to give to the uniform
  48419. * @return the texture itself allowing "fluent" like uniform updates
  48420. */
  48421. setVector3(name: string, value: Vector3): ProceduralTexture;
  48422. /**
  48423. * Set a mat4 in the shader from a MAtrix.
  48424. * @param name Define the name of the uniform as defined in the shader
  48425. * @param value Define the value to give to the uniform
  48426. * @return the texture itself allowing "fluent" like uniform updates
  48427. */
  48428. setMatrix(name: string, value: Matrix): ProceduralTexture;
  48429. /**
  48430. * Render the texture to its associated render target.
  48431. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48432. */
  48433. render(useCameraPostProcess?: boolean): void;
  48434. /**
  48435. * Clone the texture.
  48436. * @returns the cloned texture
  48437. */
  48438. clone(): ProceduralTexture;
  48439. /**
  48440. * Dispose the texture and release its asoociated resources.
  48441. */
  48442. dispose(): void;
  48443. }
  48444. }
  48445. declare module BABYLON {
  48446. interface AbstractScene {
  48447. /**
  48448. * The list of procedural textures added to the scene
  48449. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48450. */
  48451. proceduralTextures: Array<ProceduralTexture>;
  48452. }
  48453. /**
  48454. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  48455. * in a given scene.
  48456. */
  48457. class ProceduralTextureSceneComponent implements ISceneComponent {
  48458. /**
  48459. * The component name helpfull to identify the component in the list of scene components.
  48460. */
  48461. readonly name: string;
  48462. /**
  48463. * The scene the component belongs to.
  48464. */
  48465. scene: Scene;
  48466. /**
  48467. * Creates a new instance of the component for the given scene
  48468. * @param scene Defines the scene to register the component in
  48469. */
  48470. constructor(scene: Scene);
  48471. /**
  48472. * Registers the component in a given scene
  48473. */
  48474. register(): void;
  48475. /**
  48476. * Rebuilds the elements related to this component in case of
  48477. * context lost for instance.
  48478. */
  48479. rebuild(): void;
  48480. /**
  48481. * Disposes the component and the associated ressources.
  48482. */
  48483. dispose(): void;
  48484. private _beforeClear;
  48485. }
  48486. }
  48487. declare module BABYLON {
  48488. /**
  48489. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  48490. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48491. */
  48492. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  48493. private _scene;
  48494. private _camerasToBeAttached;
  48495. /**
  48496. * ID of the sharpen post process,
  48497. */
  48498. private readonly SharpenPostProcessId;
  48499. /**
  48500. * @ignore
  48501. * ID of the image processing post process;
  48502. */
  48503. readonly ImageProcessingPostProcessId: string;
  48504. /**
  48505. * @ignore
  48506. * ID of the Fast Approximate Anti-Aliasing post process;
  48507. */
  48508. readonly FxaaPostProcessId: string;
  48509. /**
  48510. * ID of the chromatic aberration post process,
  48511. */
  48512. private readonly ChromaticAberrationPostProcessId;
  48513. /**
  48514. * ID of the grain post process
  48515. */
  48516. private readonly GrainPostProcessId;
  48517. /**
  48518. * Sharpen post process which will apply a sharpen convolution to enhance edges
  48519. */
  48520. sharpen: SharpenPostProcess;
  48521. private _sharpenEffect;
  48522. private bloom;
  48523. /**
  48524. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  48525. */
  48526. depthOfField: DepthOfFieldEffect;
  48527. /**
  48528. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  48529. */
  48530. fxaa: FxaaPostProcess;
  48531. /**
  48532. * Image post processing pass used to perform operations such as tone mapping or color grading.
  48533. */
  48534. imageProcessing: ImageProcessingPostProcess;
  48535. /**
  48536. * Chromatic aberration post process which will shift rgb colors in the image
  48537. */
  48538. chromaticAberration: ChromaticAberrationPostProcess;
  48539. private _chromaticAberrationEffect;
  48540. /**
  48541. * Grain post process which add noise to the image
  48542. */
  48543. grain: GrainPostProcess;
  48544. private _grainEffect;
  48545. /**
  48546. * Glow post process which adds a glow to emmisive areas of the image
  48547. */
  48548. private _glowLayer;
  48549. /**
  48550. * Animations which can be used to tweak settings over a period of time
  48551. */
  48552. animations: Animation[];
  48553. private _imageProcessingConfigurationObserver;
  48554. private _sharpenEnabled;
  48555. private _bloomEnabled;
  48556. private _depthOfFieldEnabled;
  48557. private _depthOfFieldBlurLevel;
  48558. private _fxaaEnabled;
  48559. private _imageProcessingEnabled;
  48560. private _defaultPipelineTextureType;
  48561. private _bloomScale;
  48562. private _chromaticAberrationEnabled;
  48563. private _grainEnabled;
  48564. private _buildAllowed;
  48565. /**
  48566. * Enable or disable the sharpen process from the pipeline
  48567. */
  48568. sharpenEnabled: boolean;
  48569. private _resizeObserver;
  48570. private _hardwareScaleLevel;
  48571. private _bloomKernel;
  48572. /**
  48573. * Specifies the size of the bloom blur kernel, relative to the final output size
  48574. */
  48575. bloomKernel: number;
  48576. /**
  48577. * Specifies the weight of the bloom in the final rendering
  48578. */
  48579. private _bloomWeight;
  48580. /**
  48581. * Specifies the luma threshold for the area that will be blurred by the bloom
  48582. */
  48583. private _bloomThreshold;
  48584. private _hdr;
  48585. /**
  48586. * The strength of the bloom.
  48587. */
  48588. bloomWeight: number;
  48589. /**
  48590. * The strength of the bloom.
  48591. */
  48592. bloomThreshold: number;
  48593. /**
  48594. * The scale of the bloom, lower value will provide better performance.
  48595. */
  48596. bloomScale: number;
  48597. /**
  48598. * Enable or disable the bloom from the pipeline
  48599. */
  48600. bloomEnabled: boolean;
  48601. private _rebuildBloom;
  48602. /**
  48603. * If the depth of field is enabled.
  48604. */
  48605. depthOfFieldEnabled: boolean;
  48606. /**
  48607. * Blur level of the depth of field effect. (Higher blur will effect performance)
  48608. */
  48609. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  48610. /**
  48611. * If the anti aliasing is enabled.
  48612. */
  48613. fxaaEnabled: boolean;
  48614. private _samples;
  48615. /**
  48616. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  48617. */
  48618. samples: number;
  48619. /**
  48620. * If image processing is enabled.
  48621. */
  48622. imageProcessingEnabled: boolean;
  48623. /**
  48624. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  48625. */
  48626. glowLayerEnabled: boolean;
  48627. /**
  48628. * Enable or disable the chromaticAberration process from the pipeline
  48629. */
  48630. chromaticAberrationEnabled: boolean;
  48631. /**
  48632. * Enable or disable the grain process from the pipeline
  48633. */
  48634. grainEnabled: boolean;
  48635. /**
  48636. * @constructor
  48637. * @param name - The rendering pipeline name (default: "")
  48638. * @param hdr - If high dynamic range textures should be used (default: true)
  48639. * @param scene - The scene linked to this pipeline (default: the last created scene)
  48640. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  48641. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  48642. */
  48643. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  48644. /**
  48645. * Force the compilation of the entire pipeline.
  48646. */
  48647. prepare(): void;
  48648. private _hasCleared;
  48649. private _prevPostProcess;
  48650. private _prevPrevPostProcess;
  48651. private _setAutoClearAndTextureSharing;
  48652. private _depthOfFieldSceneObserver;
  48653. private _buildPipeline;
  48654. private _disposePostProcesses;
  48655. /**
  48656. * Adds a camera to the pipeline
  48657. * @param camera the camera to be added
  48658. */
  48659. addCamera(camera: Camera): void;
  48660. /**
  48661. * Removes a camera from the pipeline
  48662. * @param camera the camera to remove
  48663. */
  48664. removeCamera(camera: Camera): void;
  48665. /**
  48666. * Dispose of the pipeline and stop all post processes
  48667. */
  48668. dispose(): void;
  48669. /**
  48670. * Serialize the rendering pipeline (Used when exporting)
  48671. * @returns the serialized object
  48672. */
  48673. serialize(): any;
  48674. /**
  48675. * Parse the serialized pipeline
  48676. * @param source Source pipeline.
  48677. * @param scene The scene to load the pipeline to.
  48678. * @param rootUrl The URL of the serialized pipeline.
  48679. * @returns An instantiated pipeline from the serialized object.
  48680. */
  48681. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  48682. }
  48683. }
  48684. declare module BABYLON {
  48685. /**
  48686. * BABYLON.JS Chromatic Aberration GLSL Shader
  48687. * Author: Olivier Guyot
  48688. * Separates very slightly R, G and B colors on the edges of the screen
  48689. * Inspired by Francois Tarlier & Martins Upitis
  48690. */
  48691. class LensRenderingPipeline extends PostProcessRenderPipeline {
  48692. /**
  48693. * @ignore
  48694. * The chromatic aberration PostProcess id in the pipeline
  48695. */
  48696. LensChromaticAberrationEffect: string;
  48697. /**
  48698. * @ignore
  48699. * The highlights enhancing PostProcess id in the pipeline
  48700. */
  48701. HighlightsEnhancingEffect: string;
  48702. /**
  48703. * @ignore
  48704. * The depth-of-field PostProcess id in the pipeline
  48705. */
  48706. LensDepthOfFieldEffect: string;
  48707. private _scene;
  48708. private _depthTexture;
  48709. private _grainTexture;
  48710. private _chromaticAberrationPostProcess;
  48711. private _highlightsPostProcess;
  48712. private _depthOfFieldPostProcess;
  48713. private _edgeBlur;
  48714. private _grainAmount;
  48715. private _chromaticAberration;
  48716. private _distortion;
  48717. private _highlightsGain;
  48718. private _highlightsThreshold;
  48719. private _dofDistance;
  48720. private _dofAperture;
  48721. private _dofDarken;
  48722. private _dofPentagon;
  48723. private _blurNoise;
  48724. /**
  48725. * @constructor
  48726. *
  48727. * Effect parameters are as follow:
  48728. * {
  48729. * chromatic_aberration: number; // from 0 to x (1 for realism)
  48730. * edge_blur: number; // from 0 to x (1 for realism)
  48731. * distortion: number; // from 0 to x (1 for realism)
  48732. * grain_amount: number; // from 0 to 1
  48733. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  48734. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  48735. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  48736. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  48737. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  48738. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  48739. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  48740. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  48741. * }
  48742. * Note: if an effect parameter is unset, effect is disabled
  48743. *
  48744. * @param name The rendering pipeline name
  48745. * @param parameters - An object containing all parameters (see above)
  48746. * @param scene The scene linked to this pipeline
  48747. * @param 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)
  48748. * @param cameras The array of cameras that the rendering pipeline will be attached to
  48749. */
  48750. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  48751. /**
  48752. * Sets the amount of blur at the edges
  48753. * @param amount blur amount
  48754. */
  48755. setEdgeBlur(amount: number): void;
  48756. /**
  48757. * Sets edge blur to 0
  48758. */
  48759. disableEdgeBlur(): void;
  48760. /**
  48761. * Sets the amout of grain
  48762. * @param amount Amount of grain
  48763. */
  48764. setGrainAmount(amount: number): void;
  48765. /**
  48766. * Set grain amount to 0
  48767. */
  48768. disableGrain(): void;
  48769. /**
  48770. * Sets the chromatic aberration amount
  48771. * @param amount amount of chromatic aberration
  48772. */
  48773. setChromaticAberration(amount: number): void;
  48774. /**
  48775. * Sets chromatic aberration amount to 0
  48776. */
  48777. disableChromaticAberration(): void;
  48778. /**
  48779. * Sets the EdgeDistortion amount
  48780. * @param amount amount of EdgeDistortion
  48781. */
  48782. setEdgeDistortion(amount: number): void;
  48783. /**
  48784. * Sets edge distortion to 0
  48785. */
  48786. disableEdgeDistortion(): void;
  48787. /**
  48788. * Sets the FocusDistance amount
  48789. * @param amount amount of FocusDistance
  48790. */
  48791. setFocusDistance(amount: number): void;
  48792. /**
  48793. * Disables depth of field
  48794. */
  48795. disableDepthOfField(): void;
  48796. /**
  48797. * Sets the Aperture amount
  48798. * @param amount amount of Aperture
  48799. */
  48800. setAperture(amount: number): void;
  48801. /**
  48802. * Sets the DarkenOutOfFocus amount
  48803. * @param amount amount of DarkenOutOfFocus
  48804. */
  48805. setDarkenOutOfFocus(amount: number): void;
  48806. /**
  48807. * Creates a pentagon bokeh effect
  48808. */
  48809. enablePentagonBokeh(): void;
  48810. /**
  48811. * Disables the pentagon bokeh effect
  48812. */
  48813. disablePentagonBokeh(): void;
  48814. /**
  48815. * Enables noise blur
  48816. */
  48817. enableNoiseBlur(): void;
  48818. /**
  48819. * Disables noise blur
  48820. */
  48821. disableNoiseBlur(): void;
  48822. /**
  48823. * Sets the HighlightsGain amount
  48824. * @param amount amount of HighlightsGain
  48825. */
  48826. setHighlightsGain(amount: number): void;
  48827. /**
  48828. * Sets the HighlightsThreshold amount
  48829. * @param amount amount of HighlightsThreshold
  48830. */
  48831. setHighlightsThreshold(amount: number): void;
  48832. /**
  48833. * Disables highlights
  48834. */
  48835. disableHighlights(): void;
  48836. /**
  48837. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  48838. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  48839. */
  48840. dispose(disableDepthRender?: boolean): void;
  48841. private _createChromaticAberrationPostProcess;
  48842. private _createHighlightsPostProcess;
  48843. private _createDepthOfFieldPostProcess;
  48844. private _createGrainTexture;
  48845. }
  48846. }
  48847. declare module BABYLON {
  48848. /**
  48849. * Render pipeline to produce ssao effect
  48850. */
  48851. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  48852. /**
  48853. * @ignore
  48854. * The PassPostProcess id in the pipeline that contains the original scene color
  48855. */
  48856. SSAOOriginalSceneColorEffect: string;
  48857. /**
  48858. * @ignore
  48859. * The SSAO PostProcess id in the pipeline
  48860. */
  48861. SSAORenderEffect: string;
  48862. /**
  48863. * @ignore
  48864. * The horizontal blur PostProcess id in the pipeline
  48865. */
  48866. SSAOBlurHRenderEffect: string;
  48867. /**
  48868. * @ignore
  48869. * The vertical blur PostProcess id in the pipeline
  48870. */
  48871. SSAOBlurVRenderEffect: string;
  48872. /**
  48873. * @ignore
  48874. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  48875. */
  48876. SSAOCombineRenderEffect: string;
  48877. /**
  48878. * The output strength of the SSAO post-process. Default value is 1.0.
  48879. */
  48880. totalStrength: number;
  48881. /**
  48882. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  48883. */
  48884. maxZ: number;
  48885. /**
  48886. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  48887. */
  48888. minZAspect: number;
  48889. private _samples;
  48890. /**
  48891. * Number of samples used for the SSAO calculations. Default value is 8
  48892. */
  48893. samples: number;
  48894. private _textureSamples;
  48895. /**
  48896. * Number of samples to use for antialiasing
  48897. */
  48898. textureSamples: number;
  48899. /**
  48900. * Ratio object used for SSAO ratio and blur ratio
  48901. */
  48902. private _ratio;
  48903. /**
  48904. * Dynamically generated sphere sampler.
  48905. */
  48906. private _sampleSphere;
  48907. /**
  48908. * Blur filter offsets
  48909. */
  48910. private _samplerOffsets;
  48911. private _expensiveBlur;
  48912. /**
  48913. * If bilateral blur should be used
  48914. */
  48915. expensiveBlur: boolean;
  48916. /**
  48917. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  48918. */
  48919. radius: number;
  48920. /**
  48921. * The base color of the SSAO post-process
  48922. * The final result is "base + ssao" between [0, 1]
  48923. */
  48924. base: number;
  48925. /**
  48926. * Support test.
  48927. */
  48928. static readonly IsSupported: boolean;
  48929. private _scene;
  48930. private _depthTexture;
  48931. private _normalTexture;
  48932. private _randomTexture;
  48933. private _originalColorPostProcess;
  48934. private _ssaoPostProcess;
  48935. private _blurHPostProcess;
  48936. private _blurVPostProcess;
  48937. private _ssaoCombinePostProcess;
  48938. private _firstUpdate;
  48939. /**
  48940. * @constructor
  48941. * @param name The rendering pipeline name
  48942. * @param scene The scene linked to this pipeline
  48943. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  48944. * @param cameras The array of cameras that the rendering pipeline will be attached to
  48945. */
  48946. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  48947. /**
  48948. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  48949. */
  48950. dispose(disableGeometryBufferRenderer?: boolean): void;
  48951. private _createBlurPostProcess;
  48952. /** @hidden */
  48953. _rebuild(): void;
  48954. private _bits;
  48955. private _radicalInverse_VdC;
  48956. private _hammersley;
  48957. private _hemisphereSample_uniform;
  48958. private _generateHemisphere;
  48959. private _createSSAOPostProcess;
  48960. private _createSSAOCombinePostProcess;
  48961. private _createRandomTexture;
  48962. /**
  48963. * Serialize the rendering pipeline (Used when exporting)
  48964. * @returns the serialized object
  48965. */
  48966. serialize(): any;
  48967. /**
  48968. * Parse the serialized pipeline
  48969. * @param source Source pipeline.
  48970. * @param scene The scene to load the pipeline to.
  48971. * @param rootUrl The URL of the serialized pipeline.
  48972. * @returns An instantiated pipeline from the serialized object.
  48973. */
  48974. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  48975. }
  48976. }
  48977. declare module BABYLON {
  48978. /**
  48979. * Render pipeline to produce ssao effect
  48980. */
  48981. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  48982. /**
  48983. * @ignore
  48984. * The PassPostProcess id in the pipeline that contains the original scene color
  48985. */
  48986. SSAOOriginalSceneColorEffect: string;
  48987. /**
  48988. * @ignore
  48989. * The SSAO PostProcess id in the pipeline
  48990. */
  48991. SSAORenderEffect: string;
  48992. /**
  48993. * @ignore
  48994. * The horizontal blur PostProcess id in the pipeline
  48995. */
  48996. SSAOBlurHRenderEffect: string;
  48997. /**
  48998. * @ignore
  48999. * The vertical blur PostProcess id in the pipeline
  49000. */
  49001. SSAOBlurVRenderEffect: string;
  49002. /**
  49003. * @ignore
  49004. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49005. */
  49006. SSAOCombineRenderEffect: string;
  49007. /**
  49008. * The output strength of the SSAO post-process. Default value is 1.0.
  49009. */
  49010. totalStrength: number;
  49011. /**
  49012. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  49013. */
  49014. radius: number;
  49015. /**
  49016. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  49017. * Must not be equal to fallOff and superior to fallOff.
  49018. * Default value is 0.975
  49019. */
  49020. area: number;
  49021. /**
  49022. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  49023. * Must not be equal to area and inferior to area.
  49024. * Default value is 0.0
  49025. */
  49026. fallOff: number;
  49027. /**
  49028. * The base color of the SSAO post-process
  49029. * The final result is "base + ssao" between [0, 1]
  49030. */
  49031. base: number;
  49032. private _scene;
  49033. private _depthTexture;
  49034. private _randomTexture;
  49035. private _originalColorPostProcess;
  49036. private _ssaoPostProcess;
  49037. private _blurHPostProcess;
  49038. private _blurVPostProcess;
  49039. private _ssaoCombinePostProcess;
  49040. private _firstUpdate;
  49041. /**
  49042. * @constructor
  49043. * @param name - The rendering pipeline name
  49044. * @param scene - The scene linked to this pipeline
  49045. * @param 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 }
  49046. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  49047. */
  49048. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49049. /**
  49050. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49051. */
  49052. dispose(disableDepthRender?: boolean): void;
  49053. private _createBlurPostProcess;
  49054. /** @hidden */
  49055. _rebuild(): void;
  49056. private _createSSAOPostProcess;
  49057. private _createSSAOCombinePostProcess;
  49058. private _createRandomTexture;
  49059. }
  49060. }
  49061. declare module BABYLON {
  49062. /**
  49063. * Standard rendering pipeline
  49064. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49065. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  49066. */
  49067. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49068. /**
  49069. * Public members
  49070. */
  49071. /**
  49072. * Post-process which contains the original scene color before the pipeline applies all the effects
  49073. */
  49074. originalPostProcess: Nullable<PostProcess>;
  49075. /**
  49076. * Post-process used to down scale an image x4
  49077. */
  49078. downSampleX4PostProcess: Nullable<PostProcess>;
  49079. /**
  49080. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  49081. */
  49082. brightPassPostProcess: Nullable<PostProcess>;
  49083. /**
  49084. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  49085. */
  49086. blurHPostProcesses: PostProcess[];
  49087. /**
  49088. * Post-process array storing all the vertical blur post-processes used by the pipeline
  49089. */
  49090. blurVPostProcesses: PostProcess[];
  49091. /**
  49092. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  49093. */
  49094. textureAdderPostProcess: Nullable<PostProcess>;
  49095. /**
  49096. * Post-process used to create volumetric lighting effect
  49097. */
  49098. volumetricLightPostProcess: Nullable<PostProcess>;
  49099. /**
  49100. * Post-process used to smooth the previous volumetric light post-process on the X axis
  49101. */
  49102. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  49103. /**
  49104. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  49105. */
  49106. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  49107. /**
  49108. * Post-process used to merge the volumetric light effect and the real scene color
  49109. */
  49110. volumetricLightMergePostProces: Nullable<PostProcess>;
  49111. /**
  49112. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  49113. */
  49114. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  49115. /**
  49116. * Base post-process used to calculate the average luminance of the final image for HDR
  49117. */
  49118. luminancePostProcess: Nullable<PostProcess>;
  49119. /**
  49120. * Post-processes used to create down sample post-processes in order to get
  49121. * the average luminance of the final image for HDR
  49122. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  49123. */
  49124. luminanceDownSamplePostProcesses: PostProcess[];
  49125. /**
  49126. * Post-process used to create a HDR effect (light adaptation)
  49127. */
  49128. hdrPostProcess: Nullable<PostProcess>;
  49129. /**
  49130. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  49131. */
  49132. textureAdderFinalPostProcess: Nullable<PostProcess>;
  49133. /**
  49134. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  49135. */
  49136. lensFlareFinalPostProcess: Nullable<PostProcess>;
  49137. /**
  49138. * Post-process used to merge the final HDR post-process and the real scene color
  49139. */
  49140. hdrFinalPostProcess: Nullable<PostProcess>;
  49141. /**
  49142. * Post-process used to create a lens flare effect
  49143. */
  49144. lensFlarePostProcess: Nullable<PostProcess>;
  49145. /**
  49146. * Post-process that merges the result of the lens flare post-process and the real scene color
  49147. */
  49148. lensFlareComposePostProcess: Nullable<PostProcess>;
  49149. /**
  49150. * Post-process used to create a motion blur effect
  49151. */
  49152. motionBlurPostProcess: Nullable<PostProcess>;
  49153. /**
  49154. * Post-process used to create a depth of field effect
  49155. */
  49156. depthOfFieldPostProcess: Nullable<PostProcess>;
  49157. /**
  49158. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49159. */
  49160. fxaaPostProcess: Nullable<FxaaPostProcess>;
  49161. /**
  49162. * Represents the brightness threshold in order to configure the illuminated surfaces
  49163. */
  49164. brightThreshold: number;
  49165. /**
  49166. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  49167. */
  49168. blurWidth: number;
  49169. /**
  49170. * Sets if the blur for highlighted surfaces must be only horizontal
  49171. */
  49172. horizontalBlur: boolean;
  49173. /**
  49174. * Sets the overall exposure used by the pipeline
  49175. */
  49176. exposure: number;
  49177. /**
  49178. * Texture used typically to simulate "dirty" on camera lens
  49179. */
  49180. lensTexture: Nullable<Texture>;
  49181. /**
  49182. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  49183. */
  49184. volumetricLightCoefficient: number;
  49185. /**
  49186. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  49187. */
  49188. volumetricLightPower: number;
  49189. /**
  49190. * Used the set the blur intensity to smooth the volumetric lights
  49191. */
  49192. volumetricLightBlurScale: number;
  49193. /**
  49194. * Light (spot or directional) used to generate the volumetric lights rays
  49195. * The source light must have a shadow generate so the pipeline can get its
  49196. * depth map
  49197. */
  49198. sourceLight: Nullable<SpotLight | DirectionalLight>;
  49199. /**
  49200. * For eye adaptation, represents the minimum luminance the eye can see
  49201. */
  49202. hdrMinimumLuminance: number;
  49203. /**
  49204. * For eye adaptation, represents the decrease luminance speed
  49205. */
  49206. hdrDecreaseRate: number;
  49207. /**
  49208. * For eye adaptation, represents the increase luminance speed
  49209. */
  49210. hdrIncreaseRate: number;
  49211. /**
  49212. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  49213. */
  49214. lensColorTexture: Nullable<Texture>;
  49215. /**
  49216. * The overall strengh for the lens flare effect
  49217. */
  49218. lensFlareStrength: number;
  49219. /**
  49220. * Dispersion coefficient for lens flare ghosts
  49221. */
  49222. lensFlareGhostDispersal: number;
  49223. /**
  49224. * Main lens flare halo width
  49225. */
  49226. lensFlareHaloWidth: number;
  49227. /**
  49228. * Based on the lens distortion effect, defines how much the lens flare result
  49229. * is distorted
  49230. */
  49231. lensFlareDistortionStrength: number;
  49232. /**
  49233. * Lens star texture must be used to simulate rays on the flares and is available
  49234. * in the documentation
  49235. */
  49236. lensStarTexture: Nullable<Texture>;
  49237. /**
  49238. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  49239. * flare effect by taking account of the dirt texture
  49240. */
  49241. lensFlareDirtTexture: Nullable<Texture>;
  49242. /**
  49243. * Represents the focal length for the depth of field effect
  49244. */
  49245. depthOfFieldDistance: number;
  49246. /**
  49247. * Represents the blur intensity for the blurred part of the depth of field effect
  49248. */
  49249. depthOfFieldBlurWidth: number;
  49250. /**
  49251. * For motion blur, defines how much the image is blurred by the movement
  49252. */
  49253. motionStrength: number;
  49254. /**
  49255. * List of animations for the pipeline (IAnimatable implementation)
  49256. */
  49257. animations: Animation[];
  49258. /**
  49259. * Private members
  49260. */
  49261. private _scene;
  49262. private _currentDepthOfFieldSource;
  49263. private _basePostProcess;
  49264. private _hdrCurrentLuminance;
  49265. private _floatTextureType;
  49266. private _ratio;
  49267. private _bloomEnabled;
  49268. private _depthOfFieldEnabled;
  49269. private _vlsEnabled;
  49270. private _lensFlareEnabled;
  49271. private _hdrEnabled;
  49272. private _motionBlurEnabled;
  49273. private _fxaaEnabled;
  49274. private _motionBlurSamples;
  49275. private _volumetricLightStepsCount;
  49276. private _samples;
  49277. /**
  49278. * @ignore
  49279. * Specifies if the bloom pipeline is enabled
  49280. */
  49281. BloomEnabled: boolean;
  49282. /**
  49283. * @ignore
  49284. * Specifies if the depth of field pipeline is enabed
  49285. */
  49286. DepthOfFieldEnabled: boolean;
  49287. /**
  49288. * @ignore
  49289. * Specifies if the lens flare pipeline is enabed
  49290. */
  49291. LensFlareEnabled: boolean;
  49292. /**
  49293. * @ignore
  49294. * Specifies if the HDR pipeline is enabled
  49295. */
  49296. HDREnabled: boolean;
  49297. /**
  49298. * @ignore
  49299. * Specifies if the volumetric lights scattering effect is enabled
  49300. */
  49301. VLSEnabled: boolean;
  49302. /**
  49303. * @ignore
  49304. * Specifies if the motion blur effect is enabled
  49305. */
  49306. MotionBlurEnabled: boolean;
  49307. /**
  49308. * Specifies if anti-aliasing is enabled
  49309. */
  49310. fxaaEnabled: boolean;
  49311. /**
  49312. * Specifies the number of steps used to calculate the volumetric lights
  49313. * Typically in interval [50, 200]
  49314. */
  49315. volumetricLightStepsCount: number;
  49316. /**
  49317. * Specifies the number of samples used for the motion blur effect
  49318. * Typically in interval [16, 64]
  49319. */
  49320. motionBlurSamples: number;
  49321. /**
  49322. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49323. */
  49324. samples: number;
  49325. /**
  49326. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49327. * @constructor
  49328. * @param name The rendering pipeline name
  49329. * @param scene The scene linked to this pipeline
  49330. * @param 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)
  49331. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  49332. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49333. */
  49334. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  49335. private _buildPipeline;
  49336. private _createDownSampleX4PostProcess;
  49337. private _createBrightPassPostProcess;
  49338. private _createBlurPostProcesses;
  49339. private _createTextureAdderPostProcess;
  49340. private _createVolumetricLightPostProcess;
  49341. private _createLuminancePostProcesses;
  49342. private _createHdrPostProcess;
  49343. private _createLensFlarePostProcess;
  49344. private _createDepthOfFieldPostProcess;
  49345. private _createMotionBlurPostProcess;
  49346. private _getDepthTexture;
  49347. private _disposePostProcesses;
  49348. /**
  49349. * Dispose of the pipeline and stop all post processes
  49350. */
  49351. dispose(): void;
  49352. /**
  49353. * Serialize the rendering pipeline (Used when exporting)
  49354. * @returns the serialized object
  49355. */
  49356. serialize(): any;
  49357. /**
  49358. * Parse the serialized pipeline
  49359. * @param source Source pipeline.
  49360. * @param scene The scene to load the pipeline to.
  49361. * @param rootUrl The URL of the serialized pipeline.
  49362. * @returns An instantiated pipeline from the serialized object.
  49363. */
  49364. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  49365. /**
  49366. * Luminance steps
  49367. */
  49368. static LuminanceSteps: number;
  49369. }
  49370. }