babylon.d.ts 2.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998
  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. }
  192. interface WebGLRenderingContext {
  193. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  194. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  195. vertexAttribDivisor(index: number, divisor: number): void;
  196. createVertexArray(): any;
  197. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  198. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  199. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  200. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  201. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  202. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  203. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  204. createQuery(): WebGLQuery;
  205. deleteQuery(query: WebGLQuery): void;
  206. beginQuery(target: number, query: WebGLQuery): void;
  207. endQuery(target: number): void;
  208. getQueryParameter(query: WebGLQuery, pname: number): any;
  209. getQuery(target: number, pname: number): any;
  210. MAX_SAMPLES: number;
  211. RGBA8: number;
  212. READ_FRAMEBUFFER: number;
  213. DRAW_FRAMEBUFFER: number;
  214. UNIFORM_BUFFER: number;
  215. HALF_FLOAT_OES: number;
  216. RGBA16F: number;
  217. RGBA32F: number;
  218. R32F: number;
  219. RG32F: number;
  220. RGB32F: number;
  221. R16F: number;
  222. RG16F: number;
  223. RGB16F: number;
  224. RED: number;
  225. RG: number;
  226. R8: number;
  227. RG8: number;
  228. UNSIGNED_INT_24_8: number;
  229. DEPTH24_STENCIL8: number;
  230. drawBuffers(buffers: number[]): void;
  231. readBuffer(src: number): void;
  232. readonly COLOR_ATTACHMENT0: number;
  233. readonly COLOR_ATTACHMENT1: number;
  234. readonly COLOR_ATTACHMENT2: number;
  235. readonly COLOR_ATTACHMENT3: number;
  236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  237. ANY_SAMPLES_PASSED: number;
  238. QUERY_RESULT_AVAILABLE: number;
  239. QUERY_RESULT: number;
  240. }
  241. interface Document {
  242. mozCancelFullScreen(): void;
  243. msCancelFullScreen(): void;
  244. mozFullScreen: boolean;
  245. msIsFullScreen: boolean;
  246. fullscreen: boolean;
  247. mozPointerLockElement: HTMLElement;
  248. msPointerLockElement: HTMLElement;
  249. webkitPointerLockElement: HTMLElement;
  250. }
  251. interface HTMLCanvasElement {
  252. msRequestPointerLock?(): void;
  253. mozRequestPointerLock?(): void;
  254. webkitRequestPointerLock?(): void;
  255. }
  256. interface CanvasRenderingContext2D {
  257. msImageSmoothingEnabled: boolean;
  258. }
  259. interface WebGLBuffer {
  260. references: number;
  261. capacity: number;
  262. is32Bits: boolean;
  263. }
  264. interface WebGLProgram {
  265. transformFeedback?: WebGLTransformFeedback | null;
  266. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  267. }
  268. interface MouseEvent {
  269. mozMovementX: number;
  270. mozMovementY: number;
  271. webkitMovementX: number;
  272. webkitMovementY: number;
  273. msMovementX: number;
  274. msMovementY: number;
  275. }
  276. interface Navigator {
  277. mozGetVRDevices: (any: any) => any;
  278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  281. webkitGetGamepads(): Gamepad[];
  282. msGetGamepads(): Gamepad[];
  283. webkitGamepads(): Gamepad[];
  284. }
  285. interface HTMLVideoElement {
  286. mozSrcObject: any;
  287. }
  288. interface Screen {
  289. orientation: string;
  290. mozOrientation: string;
  291. }
  292. interface Math {
  293. fround(x: number): number;
  294. imul(a: number, b: number): number;
  295. }
  296. interface EXT_disjoint_timer_query {
  297. QUERY_COUNTER_BITS_EXT: number;
  298. TIME_ELAPSED_EXT: number;
  299. TIMESTAMP_EXT: number;
  300. GPU_DISJOINT_EXT: number;
  301. QUERY_RESULT_EXT: number;
  302. QUERY_RESULT_AVAILABLE_EXT: number;
  303. queryCounterEXT(query: WebGLQuery, target: number): void;
  304. createQueryEXT(): WebGLQuery;
  305. beginQueryEXT(target: number, query: WebGLQuery): void;
  306. endQueryEXT(target: number): void;
  307. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  308. deleteQueryEXT(query: WebGLQuery): void;
  309. }
  310. interface WebGLUniformLocation {
  311. _currentState: any;
  312. }
  313. declare module BABYLON {
  314. /**
  315. * Defines how a node can be built from a string name.
  316. */
  317. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  318. /**
  319. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  320. */
  321. class Node implements IBehaviorAware<Node> {
  322. private static _NodeConstructors;
  323. /**
  324. * Add a new node constructor
  325. * @param type defines the type name of the node to construct
  326. * @param constructorFunc defines the constructor function
  327. */
  328. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  329. /**
  330. * Returns a node constructor based on type name
  331. * @param type defines the type name
  332. * @param name defines the new node name
  333. * @param scene defines the hosting scene
  334. * @param options defines optional options to transmit to constructors
  335. * @returns the new constructor or null
  336. */
  337. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  338. /**
  339. * Gets or sets the name of the node
  340. */
  341. name: string;
  342. /**
  343. * Gets or sets the id of the node
  344. */
  345. id: string;
  346. /**
  347. * Gets or sets the unique id of the node
  348. */
  349. uniqueId: number;
  350. /**
  351. * Gets or sets a string used to store user defined state for the node
  352. */
  353. state: string;
  354. /**
  355. * Gets or sets an object used to store user defined information for the node
  356. */
  357. metadata: any;
  358. /**
  359. * Gets or sets a boolean used to define if the node must be serialized
  360. */
  361. doNotSerialize: boolean;
  362. /** @hidden */
  363. _isDisposed: boolean;
  364. /**
  365. * Gets a list of Animations associated with the node
  366. */
  367. animations: Animation[];
  368. protected _ranges: {
  369. [name: string]: Nullable<AnimationRange>;
  370. };
  371. /**
  372. * Callback raised when the node is ready to be used
  373. */
  374. onReady: (node: Node) => void;
  375. private _isEnabled;
  376. private _isParentEnabled;
  377. private _isReady;
  378. /** @hidden */
  379. _currentRenderId: number;
  380. private _parentRenderId;
  381. protected _childRenderId: number;
  382. /** @hidden */
  383. _waitingParentId: Nullable<string>;
  384. /** @hidden */
  385. _scene: Scene;
  386. /** @hidden */
  387. _cache: any;
  388. private _parentNode;
  389. private _children;
  390. /** @hidden */
  391. _worldMatrix: Matrix;
  392. /** @hidden */
  393. _worldMatrixDeterminant: number;
  394. /** @hidden */
  395. private _sceneRootNodesIndex;
  396. /**
  397. * Gets a boolean indicating if the node has been disposed
  398. * @returns true if the node was disposed
  399. */
  400. isDisposed(): boolean;
  401. /**
  402. * Gets or sets the parent of the node
  403. */
  404. parent: Nullable<Node>;
  405. private addToSceneRootNodes;
  406. private removeFromSceneRootNodes;
  407. private _animationPropertiesOverride;
  408. /**
  409. * Gets or sets the animation properties override
  410. */
  411. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  412. /**
  413. * Gets a string idenfifying the name of the class
  414. * @returns "Node" string
  415. */
  416. getClassName(): string;
  417. /**
  418. * An event triggered when the mesh is disposed
  419. */
  420. onDisposeObservable: Observable<Node>;
  421. private _onDisposeObserver;
  422. /**
  423. * Sets a callback that will be raised when the node will be disposed
  424. */
  425. onDispose: () => void;
  426. /**
  427. * Creates a new Node
  428. * @param {string} name - the name and id to be given to this node
  429. * @param {BABYLON.Scene} the scene this node will be added to
  430. */
  431. constructor(name: string, scene?: Nullable<Scene>);
  432. /**
  433. * Gets the scene of the node
  434. * @returns a {BABYLON.Scene}
  435. */
  436. getScene(): Scene;
  437. /**
  438. * Gets the engine of the node
  439. * @returns a {BABYLON.Engine}
  440. */
  441. getEngine(): Engine;
  442. private _behaviors;
  443. /**
  444. * Attach a behavior to the node
  445. * @see http://doc.babylonjs.com/features/behaviour
  446. * @param behavior defines the behavior to attach
  447. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  448. * @returns the current Node
  449. */
  450. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  451. /**
  452. * Remove an attached behavior
  453. * @see http://doc.babylonjs.com/features/behaviour
  454. * @param behavior defines the behavior to attach
  455. * @returns the current Node
  456. */
  457. removeBehavior(behavior: Behavior<Node>): Node;
  458. /**
  459. * Gets the list of attached behaviors
  460. * @see http://doc.babylonjs.com/features/behaviour
  461. */
  462. readonly behaviors: Behavior<Node>[];
  463. /**
  464. * Gets an attached behavior by name
  465. * @param name defines the name of the behavior to look for
  466. * @see http://doc.babylonjs.com/features/behaviour
  467. * @returns null if behavior was not found else the requested behavior
  468. */
  469. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  470. /**
  471. * Returns the latest update of the World matrix
  472. * @returns a Matrix
  473. */
  474. getWorldMatrix(): Matrix;
  475. /** @hidden */
  476. _getWorldMatrixDeterminant(): number;
  477. /**
  478. * Returns directly the latest state of the mesh World matrix.
  479. * A Matrix is returned.
  480. */
  481. readonly worldMatrixFromCache: Matrix;
  482. /** @hidden */
  483. _initCache(): void;
  484. /** @hidden */
  485. updateCache(force?: boolean): void;
  486. /** @hidden */
  487. _updateCache(ignoreParentClass?: boolean): void;
  488. /** @hidden */
  489. _isSynchronized(): boolean;
  490. /** @hidden */
  491. _markSyncedWithParent(): void;
  492. /** @hidden */
  493. isSynchronizedWithParent(): boolean;
  494. /** @hidden */
  495. isSynchronized(): boolean;
  496. /**
  497. * Is this node ready to be used/rendered
  498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  499. * @return true if the node is ready
  500. */
  501. isReady(completeCheck?: boolean): boolean;
  502. /**
  503. * Is this node enabled?
  504. * 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
  505. * @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
  506. * @return whether this node (and its parent) is enabled
  507. */
  508. isEnabled(checkAncestors?: boolean): boolean;
  509. /** @hidden */
  510. protected _syncParentEnabledState(): void;
  511. /**
  512. * Set the enabled state of this node
  513. * @param value defines the new enabled state
  514. */
  515. setEnabled(value: boolean): void;
  516. /**
  517. * Is this node a descendant of the given node?
  518. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  519. * @param ancestor defines the parent node to inspect
  520. * @returns a boolean indicating if this node is a descendant of the given node
  521. */
  522. isDescendantOf(ancestor: Node): boolean;
  523. /** @hidden */
  524. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  525. /**
  526. * Will return all nodes that have this node as ascendant
  527. * @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
  528. * @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
  529. * @return all children nodes of all types
  530. */
  531. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  532. /**
  533. * Get all child-meshes of this node
  534. * @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
  535. * @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
  536. * @returns an array of {BABYLON.AbstractMesh}
  537. */
  538. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  539. /**
  540. * Get all child-transformNodes of this node
  541. * @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
  542. * @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
  543. * @returns an array of {BABYLON.TransformNode}
  544. */
  545. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  546. /**
  547. * Get all direct children of this node
  548. * @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
  549. * @returns an array of {BABYLON.Node}
  550. */
  551. getChildren(predicate?: (node: Node) => boolean): Node[];
  552. /** @hidden */
  553. _setReady(state: boolean): void;
  554. /**
  555. * Get an animation by name
  556. * @param name defines the name of the animation to look for
  557. * @returns null if not found else the requested animation
  558. */
  559. getAnimationByName(name: string): Nullable<Animation>;
  560. /**
  561. * Creates an animation range for this node
  562. * @param name defines the name of the range
  563. * @param from defines the starting key
  564. * @param to defines the end key
  565. */
  566. createAnimationRange(name: string, from: number, to: number): void;
  567. /**
  568. * Delete a specific animation range
  569. * @param name defines the name of the range to delete
  570. * @param deleteFrames defines if animation frames from the range must be deleted as well
  571. */
  572. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  573. /**
  574. * Get an animation range by name
  575. * @param name defines the name of the animation range to look for
  576. * @returns null if not found else the requested animation range
  577. */
  578. getAnimationRange(name: string): Nullable<AnimationRange>;
  579. /**
  580. * Will start the animation sequence
  581. * @param name defines the range frames for animation sequence
  582. * @param loop defines if the animation should loop (false by default)
  583. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  584. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  585. * @returns the object created for this animation. If range does not exist, it will return null
  586. */
  587. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  588. /**
  589. * Serialize animation ranges into a JSON compatible object
  590. * @returns serialization object
  591. */
  592. serializeAnimationRanges(): any;
  593. /**
  594. * Computes the world matrix of the node
  595. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  596. * @returns the world matrix
  597. */
  598. computeWorldMatrix(force?: boolean): Matrix;
  599. /**
  600. * Releases resources associated with this node.
  601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  603. */
  604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  605. /**
  606. * Parse animation range data from a serialization object and store them into a given node
  607. * @param node defines where to store the animation ranges
  608. * @param parsedNode defines the serialization object to read data from
  609. * @param scene defines the hosting scene
  610. */
  611. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  612. }
  613. }
  614. declare module BABYLON {
  615. /**
  616. * Define an interface for all classes that will hold resources
  617. */
  618. interface IDisposable {
  619. /**
  620. * Releases all held resources
  621. */
  622. dispose(): void;
  623. }
  624. /**
  625. * This class is used by the onRenderingGroupObservable
  626. */
  627. class RenderingGroupInfo {
  628. /**
  629. * The Scene that being rendered
  630. */
  631. scene: Scene;
  632. /**
  633. * The camera currently used for the rendering pass
  634. */
  635. camera: Nullable<Camera>;
  636. /**
  637. * The ID of the renderingGroup being processed
  638. */
  639. renderingGroupId: number;
  640. }
  641. /**
  642. * Represents a scene to be rendered by the engine.
  643. * @see http://doc.babylonjs.com/features/scene
  644. */
  645. class Scene extends AbstractScene implements IAnimatable {
  646. private static _uniqueIdCounter;
  647. /** The fog is deactivated */
  648. static readonly FOGMODE_NONE: number;
  649. /** The fog density is following an exponential function */
  650. static readonly FOGMODE_EXP: number;
  651. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  652. static readonly FOGMODE_EXP2: number;
  653. /** The fog density is following a linear function. */
  654. static readonly FOGMODE_LINEAR: number;
  655. /**
  656. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  658. */
  659. static MinDeltaTime: number;
  660. /**
  661. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  662. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  663. */
  664. static MaxDeltaTime: number;
  665. /**
  666. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  667. */
  668. autoClear: boolean;
  669. /**
  670. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  671. */
  672. autoClearDepthAndStencil: boolean;
  673. /**
  674. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  675. */
  676. clearColor: Color4;
  677. /**
  678. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  679. */
  680. ambientColor: Color3;
  681. /** @hidden */
  682. _environmentBRDFTexture: BaseTexture;
  683. /** @hidden */
  684. protected _environmentTexture: BaseTexture;
  685. /**
  686. * Texture used in all pbr material as the reflection texture.
  687. * As in the majority of the scene they are the same (exception for multi room and so on),
  688. * this is easier to reference from here than from all the materials.
  689. */
  690. /**
  691. * Texture used in all pbr material as the reflection texture.
  692. * As in the majority of the scene they are the same (exception for multi room and so on),
  693. * this is easier to set here than in all the materials.
  694. */
  695. environmentTexture: BaseTexture;
  696. /** @hidden */
  697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  698. /**
  699. * Default image processing configuration used either in the rendering
  700. * Forward main pass or through the imageProcessingPostProcess if present.
  701. * As in the majority of the scene they are the same (exception for multi camera),
  702. * this is easier to reference from here than from all the materials and post process.
  703. *
  704. * No setter as we it is a shared configuration, you can set the values instead.
  705. */
  706. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  707. private _forceWireframe;
  708. /**
  709. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  710. */
  711. forceWireframe: boolean;
  712. private _forcePointsCloud;
  713. /**
  714. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  715. */
  716. forcePointsCloud: boolean;
  717. /**
  718. * Gets or sets the active clipplane 1
  719. */
  720. clipPlane: Nullable<Plane>;
  721. /**
  722. * Gets or sets the active clipplane 2
  723. */
  724. clipPlane2: Nullable<Plane>;
  725. /**
  726. * Gets or sets the active clipplane 3
  727. */
  728. clipPlane3: Nullable<Plane>;
  729. /**
  730. * Gets or sets the active clipplane 4
  731. */
  732. clipPlane4: Nullable<Plane>;
  733. /**
  734. * Gets or sets a boolean indicating if animations are enabled
  735. */
  736. animationsEnabled: boolean;
  737. private _animationPropertiesOverride;
  738. /**
  739. * Gets or sets the animation properties override
  740. */
  741. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  742. /**
  743. * Gets or sets a boolean indicating if a constant deltatime has to be used
  744. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  745. */
  746. useConstantAnimationDeltaTime: boolean;
  747. /**
  748. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  749. * Please note that it requires to run a ray cast through the scene on every frame
  750. */
  751. constantlyUpdateMeshUnderPointer: boolean;
  752. /**
  753. * Defines the HTML cursor to use when hovering over interactive elements
  754. */
  755. hoverCursor: string;
  756. /**
  757. * Defines the HTML default cursor to use (empty by default)
  758. */
  759. defaultCursor: string;
  760. /**
  761. * This is used to call preventDefault() on pointer down
  762. * in order to block unwanted artifacts like system double clicks
  763. */
  764. preventDefaultOnPointerDown: boolean;
  765. /**
  766. * Gets or sets user defined metadata
  767. */
  768. metadata: any;
  769. /**
  770. * Gets the name of the plugin used to load this scene (null by default)
  771. */
  772. loadingPluginName: string;
  773. /**
  774. * Use this array to add regular expressions used to disable offline support for specific urls
  775. */
  776. disableOfflineSupportExceptionRules: RegExp[];
  777. /**
  778. * An event triggered when the scene is disposed.
  779. */
  780. onDisposeObservable: Observable<Scene>;
  781. private _onDisposeObserver;
  782. /** Sets a function to be executed when this scene is disposed. */
  783. onDispose: () => void;
  784. /**
  785. * An event triggered before rendering the scene (right after animations and physics)
  786. */
  787. onBeforeRenderObservable: Observable<Scene>;
  788. private _onBeforeRenderObserver;
  789. /** Sets a function to be executed before rendering this scene */
  790. beforeRender: Nullable<() => void>;
  791. /**
  792. * An event triggered after rendering the scene
  793. */
  794. onAfterRenderObservable: Observable<Scene>;
  795. private _onAfterRenderObserver;
  796. /** Sets a function to be executed after rendering this scene */
  797. afterRender: Nullable<() => void>;
  798. /**
  799. * An event triggered before animating the scene
  800. */
  801. onBeforeAnimationsObservable: Observable<Scene>;
  802. /**
  803. * An event triggered after animations processing
  804. */
  805. onAfterAnimationsObservable: Observable<Scene>;
  806. /**
  807. * An event triggered before draw calls are ready to be sent
  808. */
  809. onBeforeDrawPhaseObservable: Observable<Scene>;
  810. /**
  811. * An event triggered after draw calls have been sent
  812. */
  813. onAfterDrawPhaseObservable: Observable<Scene>;
  814. /**
  815. * An event triggered when the scene is ready
  816. */
  817. onReadyObservable: Observable<Scene>;
  818. /**
  819. * An event triggered before rendering a camera
  820. */
  821. onBeforeCameraRenderObservable: Observable<Camera>;
  822. private _onBeforeCameraRenderObserver;
  823. /** Sets a function to be executed before rendering a camera*/
  824. beforeCameraRender: () => void;
  825. /**
  826. * An event triggered after rendering a camera
  827. */
  828. onAfterCameraRenderObservable: Observable<Camera>;
  829. private _onAfterCameraRenderObserver;
  830. /** Sets a function to be executed after rendering a camera*/
  831. afterCameraRender: () => void;
  832. /**
  833. * An event triggered when active meshes evaluation is about to start
  834. */
  835. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  836. /**
  837. * An event triggered when active meshes evaluation is done
  838. */
  839. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  840. /**
  841. * An event triggered when particles rendering is about to start
  842. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  843. */
  844. onBeforeParticlesRenderingObservable: Observable<Scene>;
  845. /**
  846. * An event triggered when particles rendering is done
  847. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  848. */
  849. onAfterParticlesRenderingObservable: Observable<Scene>;
  850. /**
  851. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  852. */
  853. onDataLoadedObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when a camera is created
  856. */
  857. onNewCameraAddedObservable: Observable<Camera>;
  858. /**
  859. * An event triggered when a camera is removed
  860. */
  861. onCameraRemovedObservable: Observable<Camera>;
  862. /**
  863. * An event triggered when a light is created
  864. */
  865. onNewLightAddedObservable: Observable<Light>;
  866. /**
  867. * An event triggered when a light is removed
  868. */
  869. onLightRemovedObservable: Observable<Light>;
  870. /**
  871. * An event triggered when a geometry is created
  872. */
  873. onNewGeometryAddedObservable: Observable<Geometry>;
  874. /**
  875. * An event triggered when a geometry is removed
  876. */
  877. onGeometryRemovedObservable: Observable<Geometry>;
  878. /**
  879. * An event triggered when a transform node is created
  880. */
  881. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  882. /**
  883. * An event triggered when a transform node is removed
  884. */
  885. onTransformNodeRemovedObservable: Observable<TransformNode>;
  886. /**
  887. * An event triggered when a mesh is created
  888. */
  889. onNewMeshAddedObservable: Observable<AbstractMesh>;
  890. /**
  891. * An event triggered when a mesh is removed
  892. */
  893. onMeshRemovedObservable: Observable<AbstractMesh>;
  894. /**
  895. * An event triggered when a material is created
  896. */
  897. onNewMaterialAddedObservable: Observable<Material>;
  898. /**
  899. * An event triggered when a material is removed
  900. */
  901. onMaterialRemovedObservable: Observable<Material>;
  902. /**
  903. * An event triggered when a texture is created
  904. */
  905. onNewTextureAddedObservable: Observable<BaseTexture>;
  906. /**
  907. * An event triggered when a texture is removed
  908. */
  909. onTextureRemovedObservable: Observable<BaseTexture>;
  910. /**
  911. * An event triggered when render targets are about to be rendered
  912. * Can happen multiple times per frame.
  913. */
  914. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  915. /**
  916. * An event triggered when render targets were rendered.
  917. * Can happen multiple times per frame.
  918. */
  919. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  920. /**
  921. * An event triggered before calculating deterministic simulation step
  922. */
  923. onBeforeStepObservable: Observable<Scene>;
  924. /**
  925. * An event triggered after calculating deterministic simulation step
  926. */
  927. onAfterStepObservable: Observable<Scene>;
  928. /**
  929. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  930. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  931. * 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)
  932. */
  933. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  934. /**
  935. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  936. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  937. * 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)
  938. */
  939. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  940. /**
  941. * This Observable will when a mesh has been imported into the scene.
  942. */
  943. onMeshImportedObservable: Observable<AbstractMesh>;
  944. private _registeredForLateAnimationBindings;
  945. /**
  946. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  947. */
  948. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  949. /**
  950. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  951. */
  952. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  953. /**
  954. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  955. */
  956. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  957. private _onPointerMove;
  958. private _onPointerDown;
  959. private _onPointerUp;
  960. /** Deprecated. Use onPointerObservable instead */
  961. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  962. /** Deprecated. Use onPointerObservable instead */
  963. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  964. /** Deprecated. Use onPointerObservable instead */
  965. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  966. /** Deprecated. Use onPointerObservable instead */
  967. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  968. /**
  969. * 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).
  970. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  971. */
  972. onPrePointerObservable: Observable<PointerInfoPre>;
  973. /**
  974. * Observable event triggered each time an input event is received from the rendering canvas
  975. */
  976. onPointerObservable: Observable<PointerInfo>;
  977. /**
  978. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  979. */
  980. readonly unTranslatedPointer: Vector2;
  981. /** The distance in pixel that you have to move to prevent some events */
  982. static DragMovementThreshold: number;
  983. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  984. static LongPressDelay: number;
  985. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  986. static DoubleClickDelay: number;
  987. /** If you need to check double click without raising a single click at first click, enable this flag */
  988. static ExclusiveDoubleClickMode: boolean;
  989. private _initClickEvent;
  990. private _initActionManager;
  991. private _delayedSimpleClick;
  992. private _delayedSimpleClickTimeout;
  993. private _previousDelayedSimpleClickTimeout;
  994. private _meshPickProceed;
  995. private _previousButtonPressed;
  996. private _currentPickResult;
  997. private _previousPickResult;
  998. private _totalPointersPressed;
  999. private _doubleClickOccured;
  1000. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1001. cameraToUseForPointers: Nullable<Camera>;
  1002. private _pointerX;
  1003. private _pointerY;
  1004. private _unTranslatedPointerX;
  1005. private _unTranslatedPointerY;
  1006. private _startingPointerPosition;
  1007. private _previousStartingPointerPosition;
  1008. private _startingPointerTime;
  1009. private _previousStartingPointerTime;
  1010. private _pointerCaptures;
  1011. private _timeAccumulator;
  1012. private _currentStepId;
  1013. private _currentInternalStep;
  1014. /** @hidden */
  1015. _mirroredCameraPosition: Nullable<Vector3>;
  1016. /**
  1017. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1018. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1019. */
  1020. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1021. /**
  1022. * Observable event triggered each time an keyboard event is received from the hosting window
  1023. */
  1024. onKeyboardObservable: Observable<KeyboardInfo>;
  1025. private _onKeyDown;
  1026. private _onKeyUp;
  1027. private _onCanvasFocusObserver;
  1028. private _onCanvasBlurObserver;
  1029. private _useRightHandedSystem;
  1030. /**
  1031. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1032. */
  1033. useRightHandedSystem: boolean;
  1034. /**
  1035. * Sets the step Id used by deterministic lock step
  1036. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1037. * @param newStepId defines the step Id
  1038. */
  1039. setStepId(newStepId: number): void;
  1040. /**
  1041. * Gets the step Id used by deterministic lock step
  1042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1043. * @returns the step Id
  1044. */
  1045. getStepId(): number;
  1046. /**
  1047. * Gets the internal step used by deterministic lock step
  1048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1049. * @returns the internal step
  1050. */
  1051. getInternalStep(): number;
  1052. private _fogEnabled;
  1053. /**
  1054. * Gets or sets a boolean indicating if fog is enabled on this scene
  1055. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1056. * (Default is true)
  1057. */
  1058. fogEnabled: boolean;
  1059. private _fogMode;
  1060. /**
  1061. * Gets or sets the fog mode to use
  1062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1063. * | mode | value |
  1064. * | --- | --- |
  1065. * | FOGMODE_NONE | 0 |
  1066. * | FOGMODE_EXP | 1 |
  1067. * | FOGMODE_EXP2 | 2 |
  1068. * | FOGMODE_LINEAR | 3 |
  1069. */
  1070. fogMode: number;
  1071. /**
  1072. * Gets or sets the fog color to use
  1073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1074. * (Default is Color3(0.2, 0.2, 0.3))
  1075. */
  1076. fogColor: Color3;
  1077. /**
  1078. * Gets or sets the fog density to use
  1079. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1080. * (Default is 0.1)
  1081. */
  1082. fogDensity: number;
  1083. /**
  1084. * Gets or sets the fog start distance to use
  1085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1086. * (Default is 0)
  1087. */
  1088. fogStart: number;
  1089. /**
  1090. * Gets or sets the fog end distance to use
  1091. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1092. * (Default is 1000)
  1093. */
  1094. fogEnd: number;
  1095. private _shadowsEnabled;
  1096. /**
  1097. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1098. */
  1099. shadowsEnabled: boolean;
  1100. private _lightsEnabled;
  1101. /**
  1102. * Gets or sets a boolean indicating if lights are enabled on this scene
  1103. */
  1104. lightsEnabled: boolean;
  1105. /** All of the active cameras added to this scene. */
  1106. activeCameras: Camera[];
  1107. /** The current active camera */
  1108. activeCamera: Nullable<Camera>;
  1109. private _defaultMaterial;
  1110. /** The default material used on meshes when no material is affected */
  1111. /** The default material used on meshes when no material is affected */
  1112. defaultMaterial: Material;
  1113. private _texturesEnabled;
  1114. /**
  1115. * Gets or sets a boolean indicating if textures are enabled on this scene
  1116. */
  1117. texturesEnabled: boolean;
  1118. /**
  1119. * Gets or sets a boolean indicating if particles are enabled on this scene
  1120. */
  1121. particlesEnabled: boolean;
  1122. /**
  1123. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1124. */
  1125. spritesEnabled: boolean;
  1126. private _skeletonsEnabled;
  1127. /**
  1128. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1129. */
  1130. skeletonsEnabled: boolean;
  1131. /**
  1132. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1133. */
  1134. lensFlaresEnabled: boolean;
  1135. /**
  1136. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1138. */
  1139. collisionsEnabled: boolean;
  1140. private _workerCollisions;
  1141. /** @hidden */
  1142. collisionCoordinator: ICollisionCoordinator;
  1143. /**
  1144. * Defines the gravity applied to this scene (used only for collisions)
  1145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1146. */
  1147. gravity: Vector3;
  1148. /**
  1149. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1150. */
  1151. postProcessesEnabled: boolean;
  1152. /**
  1153. * The list of postprocesses added to the scene
  1154. */
  1155. postProcesses: PostProcess[];
  1156. /**
  1157. * Gets the current postprocess manager
  1158. */
  1159. postProcessManager: PostProcessManager;
  1160. /**
  1161. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1162. */
  1163. renderTargetsEnabled: boolean;
  1164. /**
  1165. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1166. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1167. */
  1168. dumpNextRenderTargets: boolean;
  1169. /**
  1170. * The list of user defined render targets added to the scene
  1171. */
  1172. customRenderTargets: RenderTargetTexture[];
  1173. /**
  1174. * Defines if texture loading must be delayed
  1175. * If true, textures will only be loaded when they need to be rendered
  1176. */
  1177. useDelayedTextureLoading: boolean;
  1178. /**
  1179. * Gets the list of meshes imported to the scene through SceneLoader
  1180. */
  1181. importedMeshesFiles: String[];
  1182. /**
  1183. * Gets or sets a boolean indicating if probes are enabled on this scene
  1184. */
  1185. probesEnabled: boolean;
  1186. /**
  1187. * @hidden
  1188. */
  1189. database: Database;
  1190. /**
  1191. * Gets or sets the action manager associated with the scene
  1192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1193. */
  1194. actionManager: ActionManager;
  1195. private _meshesForIntersections;
  1196. /**
  1197. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1198. */
  1199. proceduralTexturesEnabled: boolean;
  1200. private _engine;
  1201. private _totalVertices;
  1202. /** @hidden */
  1203. _activeIndices: PerfCounter;
  1204. /** @hidden */
  1205. _activeParticles: PerfCounter;
  1206. /** @hidden */
  1207. _activeBones: PerfCounter;
  1208. private _animationRatio;
  1209. private _animationTimeLast;
  1210. private _animationTime;
  1211. /**
  1212. * Gets or sets a general scale for animation speed
  1213. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1214. */
  1215. animationTimeScale: number;
  1216. /** @hidden */
  1217. _cachedMaterial: Nullable<Material>;
  1218. /** @hidden */
  1219. _cachedEffect: Nullable<Effect>;
  1220. /** @hidden */
  1221. _cachedVisibility: Nullable<number>;
  1222. private _renderId;
  1223. private _frameId;
  1224. private _executeWhenReadyTimeoutId;
  1225. private _intermediateRendering;
  1226. private _viewUpdateFlag;
  1227. private _projectionUpdateFlag;
  1228. private _alternateViewUpdateFlag;
  1229. private _alternateProjectionUpdateFlag;
  1230. /** @hidden */
  1231. _toBeDisposed: Nullable<IDisposable>[];
  1232. private _activeRequests;
  1233. private _pendingData;
  1234. private _isDisposed;
  1235. /**
  1236. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1237. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1238. */
  1239. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1240. private _activeMeshes;
  1241. private _processedMaterials;
  1242. private _renderTargets;
  1243. /** @hidden */
  1244. _activeParticleSystems: SmartArray<IParticleSystem>;
  1245. private _activeSkeletons;
  1246. private _softwareSkinnedMeshes;
  1247. private _renderingManager;
  1248. /** @hidden */
  1249. _activeAnimatables: Animatable[];
  1250. private _transformMatrix;
  1251. private _sceneUbo;
  1252. private _alternateSceneUbo;
  1253. private _pickWithRayInverseMatrix;
  1254. private _viewMatrix;
  1255. private _projectionMatrix;
  1256. private _alternateViewMatrix;
  1257. private _alternateProjectionMatrix;
  1258. private _alternateTransformMatrix;
  1259. private _useAlternateCameraConfiguration;
  1260. private _alternateRendering;
  1261. /** @hidden */
  1262. _forcedViewPosition: Nullable<Vector3>;
  1263. /** @hidden */
  1264. readonly _isAlternateRenderingEnabled: boolean;
  1265. private _frustumPlanes;
  1266. /**
  1267. * Gets the list of frustum planes (built from the active camera)
  1268. */
  1269. readonly frustumPlanes: Plane[];
  1270. /**
  1271. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1272. * This is useful if there are more lights that the maximum simulteanous authorized
  1273. */
  1274. requireLightSorting: boolean;
  1275. private _pointerOverMesh;
  1276. private _pickedDownMesh;
  1277. private _pickedUpMesh;
  1278. private _externalData;
  1279. private _uid;
  1280. /**
  1281. * @hidden
  1282. * Backing store of defined scene components.
  1283. */
  1284. _components: ISceneComponent[];
  1285. /**
  1286. * @hidden
  1287. * Backing store of defined scene components.
  1288. */
  1289. _serializableComponents: ISceneSerializableComponent[];
  1290. /**
  1291. * List of components to register on the next registration step.
  1292. */
  1293. private _transientComponents;
  1294. /**
  1295. * Registers the transient components if needed.
  1296. */
  1297. private _registerTransientComponents;
  1298. /**
  1299. * @hidden
  1300. * Add a component to the scene.
  1301. * Note that the ccomponent could be registered on th next frame if this is called after
  1302. * the register component stage.
  1303. * @param component Defines the component to add to the scene
  1304. */
  1305. _addComponent(component: ISceneComponent): void;
  1306. /**
  1307. * @hidden
  1308. * Gets a component from the scene.
  1309. * @param name defines the name of the component to retrieve
  1310. * @returns the component or null if not present
  1311. */
  1312. _getComponent(name: string): Nullable<ISceneComponent>;
  1313. /**
  1314. * @hidden
  1315. * Defines the actions happening before camera updates.
  1316. */
  1317. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1318. /**
  1319. * @hidden
  1320. * Defines the actions happening before clear the canvas.
  1321. */
  1322. _beforeClearStage: Stage<SimpleStageAction>;
  1323. /**
  1324. * @hidden
  1325. * Defines the actions when collecting render targets for the frame.
  1326. */
  1327. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1328. /**
  1329. * @hidden
  1330. * Defines the actions happening for one camera in the frame.
  1331. */
  1332. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1333. /**
  1334. * @hidden
  1335. * Defines the actions happening during the per mesh ready checks.
  1336. */
  1337. _isReadyForMeshStage: Stage<MeshStageAction>;
  1338. /**
  1339. * @hidden
  1340. * Defines the actions happening before evaluate active mesh checks.
  1341. */
  1342. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1343. /**
  1344. * @hidden
  1345. * Defines the actions happening during the evaluate sub mesh checks.
  1346. */
  1347. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1348. /**
  1349. * @hidden
  1350. * Defines the actions happening during the active mesh stage.
  1351. */
  1352. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1353. /**
  1354. * @hidden
  1355. * Defines the actions happening during the per camera render target step.
  1356. */
  1357. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1358. /**
  1359. * @hidden
  1360. * Defines the actions happening just before the active camera is drawing.
  1361. */
  1362. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1363. /**
  1364. * @hidden
  1365. * Defines the actions happening just before a rendering group is drawing.
  1366. */
  1367. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1368. /**
  1369. * @hidden
  1370. * Defines the actions happening just before a mesh is drawing.
  1371. */
  1372. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1373. /**
  1374. * @hidden
  1375. * Defines the actions happening just after a mesh has been drawn.
  1376. */
  1377. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1378. /**
  1379. * @hidden
  1380. * Defines the actions happening just after a rendering group has been drawn.
  1381. */
  1382. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1383. /**
  1384. * @hidden
  1385. * Defines the actions happening just after the active camera has been drawn.
  1386. */
  1387. _afterCameraDrawStage: Stage<CameraStageAction>;
  1388. /**
  1389. * @hidden
  1390. * Defines the actions happening just after rendering all cameras and computing intersections.
  1391. */
  1392. _afterRenderStage: Stage<SimpleStageAction>;
  1393. /**
  1394. * @hidden
  1395. * Defines the actions happening when a pointer move event happens.
  1396. */
  1397. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1398. /**
  1399. * @hidden
  1400. * Defines the actions happening when a pointer down event happens.
  1401. */
  1402. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1403. /**
  1404. * @hidden
  1405. * Defines the actions happening when a pointer up event happens.
  1406. */
  1407. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1408. /**
  1409. * Creates a new Scene
  1410. * @param engine defines the engine to use to render this scene
  1411. */
  1412. constructor(engine: Engine);
  1413. private _defaultMeshCandidates;
  1414. /**
  1415. * @hidden
  1416. */
  1417. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1418. private _defaultSubMeshCandidates;
  1419. /**
  1420. * @hidden
  1421. */
  1422. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1423. /**
  1424. * Sets the default candidate providers for the scene.
  1425. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1426. * and getCollidingSubMeshCandidates to their default function
  1427. */
  1428. setDefaultCandidateProviders(): void;
  1429. /**
  1430. * Gets a boolean indicating if collisions are processed on a web worker
  1431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1432. */
  1433. workerCollisions: boolean;
  1434. /**
  1435. * Gets the mesh that is currently under the pointer
  1436. */
  1437. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1438. /**
  1439. * Gets the current on-screen X position of the pointer
  1440. */
  1441. readonly pointerX: number;
  1442. /**
  1443. * Gets the current on-screen Y position of the pointer
  1444. */
  1445. readonly pointerY: number;
  1446. /**
  1447. * Gets the cached material (ie. the latest rendered one)
  1448. * @returns the cached material
  1449. */
  1450. getCachedMaterial(): Nullable<Material>;
  1451. /**
  1452. * Gets the cached effect (ie. the latest rendered one)
  1453. * @returns the cached effect
  1454. */
  1455. getCachedEffect(): Nullable<Effect>;
  1456. /**
  1457. * Gets the cached visibility state (ie. the latest rendered one)
  1458. * @returns the cached visibility state
  1459. */
  1460. getCachedVisibility(): Nullable<number>;
  1461. /**
  1462. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1463. * @param material defines the current material
  1464. * @param effect defines the current effect
  1465. * @param visibility defines the current visibility state
  1466. * @returns true if one parameter is not cached
  1467. */
  1468. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1469. /**
  1470. * Gets the engine associated with the scene
  1471. * @returns an Engine
  1472. */
  1473. getEngine(): Engine;
  1474. /**
  1475. * Gets the total number of vertices rendered per frame
  1476. * @returns the total number of vertices rendered per frame
  1477. */
  1478. getTotalVertices(): number;
  1479. /**
  1480. * Gets the performance counter for total vertices
  1481. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1482. */
  1483. readonly totalVerticesPerfCounter: PerfCounter;
  1484. /**
  1485. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1486. * @returns the total number of active indices rendered per frame
  1487. */
  1488. getActiveIndices(): number;
  1489. /**
  1490. * Gets the performance counter for active indices
  1491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1492. */
  1493. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1494. /**
  1495. * Gets the total number of active particles rendered per frame
  1496. * @returns the total number of active particles rendered per frame
  1497. */
  1498. getActiveParticles(): number;
  1499. /**
  1500. * Gets the performance counter for active particles
  1501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1502. */
  1503. readonly activeParticlesPerfCounter: PerfCounter;
  1504. /**
  1505. * Gets the total number of active bones rendered per frame
  1506. * @returns the total number of active bones rendered per frame
  1507. */
  1508. getActiveBones(): number;
  1509. /**
  1510. * Gets the performance counter for active bones
  1511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1512. */
  1513. readonly activeBonesPerfCounter: PerfCounter;
  1514. /** @hidden */
  1515. getInterFramePerfCounter(): number;
  1516. /** @hidden */
  1517. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1518. /** @hidden */
  1519. getLastFrameDuration(): number;
  1520. /** @hidden */
  1521. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1522. /** @hidden */
  1523. getEvaluateActiveMeshesDuration(): number;
  1524. /** @hidden */
  1525. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1526. /**
  1527. * Gets the array of active meshes
  1528. * @returns an array of AbstractMesh
  1529. */
  1530. getActiveMeshes(): SmartArray<AbstractMesh>;
  1531. /** @hidden */
  1532. getRenderTargetsDuration(): number;
  1533. /** @hidden */
  1534. getRenderDuration(): number;
  1535. /** @hidden */
  1536. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1537. /** @hidden */
  1538. getParticlesDuration(): number;
  1539. /** @hidden */
  1540. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1541. /** @hidden */
  1542. getSpritesDuration(): number;
  1543. /** @hidden */
  1544. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1545. /**
  1546. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1547. * @returns a number
  1548. */
  1549. getAnimationRatio(): number;
  1550. /**
  1551. * Gets an unique Id for the current render phase
  1552. * @returns a number
  1553. */
  1554. getRenderId(): number;
  1555. /**
  1556. * Gets an unique Id for the current frame
  1557. * @returns a number
  1558. */
  1559. getFrameId(): number;
  1560. /** Call this function if you want to manually increment the render Id*/
  1561. incrementRenderId(): void;
  1562. private _updatePointerPosition;
  1563. private _createUbo;
  1564. private _createAlternateUbo;
  1565. private _setRayOnPointerInfo;
  1566. /**
  1567. * Use this method to simulate a pointer move on a mesh
  1568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1571. * @returns the current scene
  1572. */
  1573. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1574. private _processPointerMove;
  1575. private _checkPrePointerObservable;
  1576. /**
  1577. * Use this method to simulate a pointer down 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. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1584. private _processPointerDown;
  1585. /**
  1586. * Use this method to simulate a pointer up on a mesh
  1587. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1588. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1589. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1590. * @returns the current scene
  1591. */
  1592. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1593. private _processPointerUp;
  1594. /**
  1595. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1596. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1597. * @returns true if the pointer was captured
  1598. */
  1599. isPointerCaptured(pointerId?: number): boolean;
  1600. /** @hidden */
  1601. _isPointerSwiping(): boolean;
  1602. /**
  1603. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1604. * @param attachUp defines if you want to attach events to pointerup
  1605. * @param attachDown defines if you want to attach events to pointerdown
  1606. * @param attachMove defines if you want to attach events to pointermove
  1607. */
  1608. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1609. /** Detaches all event handlers*/
  1610. detachControl(): void;
  1611. /**
  1612. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1613. * Delay loaded resources are not taking in account
  1614. * @return true if all required resources are ready
  1615. */
  1616. isReady(): boolean;
  1617. /** Resets all cached information relative to material (including effect and visibility) */
  1618. resetCachedMaterial(): void;
  1619. /**
  1620. * Registers a function to be called before every frame render
  1621. * @param func defines the function to register
  1622. */
  1623. registerBeforeRender(func: () => void): void;
  1624. /**
  1625. * Unregisters a function called before every frame render
  1626. * @param func defines the function to unregister
  1627. */
  1628. unregisterBeforeRender(func: () => void): void;
  1629. /**
  1630. * Registers a function to be called after every frame render
  1631. * @param func defines the function to register
  1632. */
  1633. registerAfterRender(func: () => void): void;
  1634. /**
  1635. * Unregisters a function called after every frame render
  1636. * @param func defines the function to unregister
  1637. */
  1638. unregisterAfterRender(func: () => void): void;
  1639. private _executeOnceBeforeRender;
  1640. /**
  1641. * The provided function will run before render once and will be disposed afterwards.
  1642. * A timeout delay can be provided so that the function will be executed in N ms.
  1643. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1644. * @param func The function to be executed.
  1645. * @param timeout optional delay in ms
  1646. */
  1647. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1648. /** @hidden */
  1649. _addPendingData(data: any): void;
  1650. /** @hidden */
  1651. _removePendingData(data: any): void;
  1652. /**
  1653. * Returns the number of items waiting to be loaded
  1654. * @returns the number of items waiting to be loaded
  1655. */
  1656. getWaitingItemsCount(): number;
  1657. /**
  1658. * Returns a boolean indicating if the scene is still loading data
  1659. */
  1660. readonly isLoading: boolean;
  1661. /**
  1662. * Registers a function to be executed when the scene is ready
  1663. * @param {Function} func - the function to be executed
  1664. */
  1665. executeWhenReady(func: () => void): void;
  1666. /**
  1667. * Returns a promise that resolves when the scene is ready
  1668. * @returns A promise that resolves when the scene is ready
  1669. */
  1670. whenReadyAsync(): Promise<void>;
  1671. /** @hidden */
  1672. _checkIsReady(): void;
  1673. /**
  1674. * Will start the animation sequence of a given target
  1675. * @param target defines the target
  1676. * @param from defines from which frame should animation start
  1677. * @param to defines until which frame should animation run.
  1678. * @param weight defines the weight to apply to the animation (1.0 by default)
  1679. * @param loop defines if the animation loops
  1680. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1681. * @param onAnimationEnd defines the function to be executed when the animation ends
  1682. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1683. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1684. * @returns the animatable object created for this animation
  1685. */
  1686. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1687. /**
  1688. * Will start the animation sequence of a given target
  1689. * @param target defines the target
  1690. * @param from defines from which frame should animation start
  1691. * @param to defines until which frame should animation run.
  1692. * @param loop defines if the animation loops
  1693. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1694. * @param onAnimationEnd defines the function to be executed when the animation ends
  1695. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1696. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1697. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1698. * @returns the animatable object created for this animation
  1699. */
  1700. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1701. /**
  1702. * Begin a new animation on a given node
  1703. * @param target defines the target where the animation will take place
  1704. * @param animations defines the list of animations to start
  1705. * @param from defines the initial value
  1706. * @param to defines the final value
  1707. * @param loop defines if you want animation to loop (off by default)
  1708. * @param speedRatio defines the speed ratio to apply to all animations
  1709. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1710. * @returns the list of created animatables
  1711. */
  1712. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1713. /**
  1714. * Begin a new animation on a given node and its hierarchy
  1715. * @param target defines the root node where the animation will take place
  1716. * @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.
  1717. * @param animations defines the list of animations to start
  1718. * @param from defines the initial value
  1719. * @param to defines the final value
  1720. * @param loop defines if you want animation to loop (off by default)
  1721. * @param speedRatio defines the speed ratio to apply to all animations
  1722. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1723. * @returns the list of animatables created for all nodes
  1724. */
  1725. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1726. /**
  1727. * Gets the animatable associated with a specific target
  1728. * @param target defines the target of the animatable
  1729. * @returns the required animatable if found
  1730. */
  1731. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1732. /**
  1733. * Gets all animatables associated with a given target
  1734. * @param target defines the target to look animatables for
  1735. * @returns an array of Animatables
  1736. */
  1737. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1738. /**
  1739. * Gets all animatable attached to the scene
  1740. */
  1741. readonly animatables: Animatable[];
  1742. /**
  1743. * Will stop the animation of the given target
  1744. * @param target - the target
  1745. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1746. * @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)
  1747. */
  1748. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1749. /**
  1750. * Stops and removes all animations that have been applied to the scene
  1751. */
  1752. stopAllAnimations(): void;
  1753. private _animate;
  1754. /** @hidden */
  1755. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1756. private _processLateAnimationBindingsForMatrices;
  1757. private _processLateAnimationBindingsForQuaternions;
  1758. private _processLateAnimationBindings;
  1759. /** @hidden */
  1760. _switchToAlternateCameraConfiguration(active: boolean): void;
  1761. /**
  1762. * Gets the current view matrix
  1763. * @returns a Matrix
  1764. */
  1765. getViewMatrix(): Matrix;
  1766. /**
  1767. * Gets the current projection matrix
  1768. * @returns a Matrix
  1769. */
  1770. getProjectionMatrix(): Matrix;
  1771. /**
  1772. * Gets the current transform matrix
  1773. * @returns a Matrix made of View * Projection
  1774. */
  1775. getTransformMatrix(): Matrix;
  1776. /**
  1777. * Sets the current transform matrix
  1778. * @param view defines the View matrix to use
  1779. * @param projection defines the Projection matrix to use
  1780. */
  1781. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1782. /** @hidden */
  1783. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1784. /**
  1785. * Gets the uniform buffer used to store scene data
  1786. * @returns a UniformBuffer
  1787. */
  1788. getSceneUniformBuffer(): UniformBuffer;
  1789. /**
  1790. * Gets an unique (relatively to the current scene) Id
  1791. * @returns an unique number for the scene
  1792. */
  1793. getUniqueId(): number;
  1794. /**
  1795. * Add a mesh to the list of scene's meshes
  1796. * @param newMesh defines the mesh to add
  1797. * @param recursive if all child meshes should also be added to the scene
  1798. */
  1799. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1800. /**
  1801. * Remove a mesh for the list of scene's meshes
  1802. * @param toRemove defines the mesh to remove
  1803. * @param recursive if all child meshes should also be removed from the scene
  1804. * @returns the index where the mesh was in the mesh list
  1805. */
  1806. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1807. /**
  1808. * Add a transform node to the list of scene's transform nodes
  1809. * @param newTransformNode defines the transform node to add
  1810. */
  1811. addTransformNode(newTransformNode: TransformNode): void;
  1812. /**
  1813. * Remove a transform node for the list of scene's transform nodes
  1814. * @param toRemove defines the transform node to remove
  1815. * @returns the index where the transform node was in the transform node list
  1816. */
  1817. removeTransformNode(toRemove: TransformNode): number;
  1818. /**
  1819. * Remove a skeleton for the list of scene's skeletons
  1820. * @param toRemove defines the skeleton to remove
  1821. * @returns the index where the skeleton was in the skeleton list
  1822. */
  1823. removeSkeleton(toRemove: Skeleton): number;
  1824. /**
  1825. * Remove a morph target for the list of scene's morph targets
  1826. * @param toRemove defines the morph target to remove
  1827. * @returns the index where the morph target was in the morph target list
  1828. */
  1829. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1830. /**
  1831. * Remove a light for the list of scene's lights
  1832. * @param toRemove defines the light to remove
  1833. * @returns the index where the light was in the light list
  1834. */
  1835. removeLight(toRemove: Light): number;
  1836. /**
  1837. * Remove a camera for the list of scene's cameras
  1838. * @param toRemove defines the camera to remove
  1839. * @returns the index where the camera was in the camera list
  1840. */
  1841. removeCamera(toRemove: Camera): number;
  1842. /**
  1843. * Remove a particle system for the list of scene's particle systems
  1844. * @param toRemove defines the particle system to remove
  1845. * @returns the index where the particle system was in the particle system list
  1846. */
  1847. removeParticleSystem(toRemove: IParticleSystem): number;
  1848. /**
  1849. * Remove a animation for the list of scene's animations
  1850. * @param toRemove defines the animation to remove
  1851. * @returns the index where the animation was in the animation list
  1852. */
  1853. removeAnimation(toRemove: Animation): number;
  1854. /**
  1855. * Removes the given animation group from this scene.
  1856. * @param toRemove The animation group to remove
  1857. * @returns The index of the removed animation group
  1858. */
  1859. removeAnimationGroup(toRemove: AnimationGroup): number;
  1860. /**
  1861. * Removes the given multi-material from this scene.
  1862. * @param toRemove The multi-material to remove
  1863. * @returns The index of the removed multi-material
  1864. */
  1865. removeMultiMaterial(toRemove: MultiMaterial): number;
  1866. /**
  1867. * Removes the given material from this scene.
  1868. * @param toRemove The material to remove
  1869. * @returns The index of the removed material
  1870. */
  1871. removeMaterial(toRemove: Material): number;
  1872. /**
  1873. * Removes the given action manager from this scene.
  1874. * @param toRemove The action manager to remove
  1875. * @returns The index of the removed action manager
  1876. */
  1877. removeActionManager(toRemove: ActionManager): number;
  1878. /**
  1879. * Removes the given texture from this scene.
  1880. * @param toRemove The texture to remove
  1881. * @returns The index of the removed texture
  1882. */
  1883. removeTexture(toRemove: BaseTexture): number;
  1884. /**
  1885. * Adds the given light to this scene
  1886. * @param newLight The light to add
  1887. */
  1888. addLight(newLight: Light): void;
  1889. /**
  1890. * Sorts the list list based on light priorities
  1891. */
  1892. sortLightsByPriority(): void;
  1893. /**
  1894. * Adds the given camera to this scene
  1895. * @param newCamera The camera to add
  1896. */
  1897. addCamera(newCamera: Camera): void;
  1898. /**
  1899. * Adds the given skeleton to this scene
  1900. * @param newSkeleton The skeleton to add
  1901. */
  1902. addSkeleton(newSkeleton: Skeleton): void;
  1903. /**
  1904. * Adds the given particle system to this scene
  1905. * @param newParticleSystem The particle system to add
  1906. */
  1907. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1908. /**
  1909. * Adds the given animation to this scene
  1910. * @param newAnimation The animation to add
  1911. */
  1912. addAnimation(newAnimation: Animation): void;
  1913. /**
  1914. * Adds the given animation group to this scene.
  1915. * @param newAnimationGroup The animation group to add
  1916. */
  1917. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1918. /**
  1919. * Adds the given multi-material to this scene
  1920. * @param newMultiMaterial The multi-material to add
  1921. */
  1922. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1923. /**
  1924. * Adds the given material to this scene
  1925. * @param newMaterial The material to add
  1926. */
  1927. addMaterial(newMaterial: Material): void;
  1928. /**
  1929. * Adds the given morph target to this scene
  1930. * @param newMorphTargetManager The morph target to add
  1931. */
  1932. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1933. /**
  1934. * Adds the given geometry to this scene
  1935. * @param newGeometry The geometry to add
  1936. */
  1937. addGeometry(newGeometry: Geometry): void;
  1938. /**
  1939. * Adds the given action manager to this scene
  1940. * @param newActionManager The action manager to add
  1941. */
  1942. addActionManager(newActionManager: ActionManager): void;
  1943. /**
  1944. * Adds the given texture to this scene.
  1945. * @param newTexture The texture to add
  1946. */
  1947. addTexture(newTexture: BaseTexture): void;
  1948. /**
  1949. * Switch active camera
  1950. * @param newCamera defines the new active camera
  1951. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1952. */
  1953. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1954. /**
  1955. * sets the active camera of the scene using its ID
  1956. * @param id defines the camera's ID
  1957. * @return the new active camera or null if none found.
  1958. */
  1959. setActiveCameraByID(id: string): Nullable<Camera>;
  1960. /**
  1961. * sets the active camera of the scene using its name
  1962. * @param name defines the camera's name
  1963. * @returns the new active camera or null if none found.
  1964. */
  1965. setActiveCameraByName(name: string): Nullable<Camera>;
  1966. /**
  1967. * get an animation group using its name
  1968. * @param name defines the material's name
  1969. * @return the animation group or null if none found.
  1970. */
  1971. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1972. /**
  1973. * get a material using its id
  1974. * @param id defines the material's ID
  1975. * @return the material or null if none found.
  1976. */
  1977. getMaterialByID(id: string): Nullable<Material>;
  1978. /**
  1979. * Gets a material using its name
  1980. * @param name defines the material's name
  1981. * @return the material or null if none found.
  1982. */
  1983. getMaterialByName(name: string): Nullable<Material>;
  1984. /**
  1985. * Gets a camera using its id
  1986. * @param id defines the id to look for
  1987. * @returns the camera or null if not found
  1988. */
  1989. getCameraByID(id: string): Nullable<Camera>;
  1990. /**
  1991. * Gets a camera using its unique id
  1992. * @param uniqueId defines the unique id to look for
  1993. * @returns the camera or null if not found
  1994. */
  1995. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1996. /**
  1997. * Gets a camera using its name
  1998. * @param name defines the camera's name
  1999. * @return the camera or null if none found.
  2000. */
  2001. getCameraByName(name: string): Nullable<Camera>;
  2002. /**
  2003. * Gets a bone using its id
  2004. * @param id defines the bone's id
  2005. * @return the bone or null if not found
  2006. */
  2007. getBoneByID(id: string): Nullable<Bone>;
  2008. /**
  2009. * Gets a bone using its id
  2010. * @param name defines the bone's name
  2011. * @return the bone or null if not found
  2012. */
  2013. getBoneByName(name: string): Nullable<Bone>;
  2014. /**
  2015. * Gets a light node using its name
  2016. * @param name defines the the light's name
  2017. * @return the light or null if none found.
  2018. */
  2019. getLightByName(name: string): Nullable<Light>;
  2020. /**
  2021. * Gets a light node using its id
  2022. * @param id defines the light's id
  2023. * @return the light or null if none found.
  2024. */
  2025. getLightByID(id: string): Nullable<Light>;
  2026. /**
  2027. * Gets a light node using its scene-generated unique ID
  2028. * @param uniqueId defines the light's unique id
  2029. * @return the light or null if none found.
  2030. */
  2031. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2032. /**
  2033. * Gets a particle system by id
  2034. * @param id defines the particle system id
  2035. * @return the corresponding system or null if none found
  2036. */
  2037. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2038. /**
  2039. * Gets a geometry using its ID
  2040. * @param id defines the geometry's id
  2041. * @return the geometry or null if none found.
  2042. */
  2043. getGeometryByID(id: string): Nullable<Geometry>;
  2044. /**
  2045. * Add a new geometry to this scene
  2046. * @param geometry defines the geometry to be added to the scene.
  2047. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2048. * @return a boolean defining if the geometry was added or not
  2049. */
  2050. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2051. /**
  2052. * Removes an existing geometry
  2053. * @param geometry defines the geometry to be removed from the scene
  2054. * @return a boolean defining if the geometry was removed or not
  2055. */
  2056. removeGeometry(geometry: Geometry): boolean;
  2057. /**
  2058. * Gets the list of geometries attached to the scene
  2059. * @returns an array of Geometry
  2060. */
  2061. getGeometries(): Geometry[];
  2062. /**
  2063. * Gets the first added mesh found of a given ID
  2064. * @param id defines the id to search for
  2065. * @return the mesh found or null if not found at all
  2066. */
  2067. getMeshByID(id: string): Nullable<AbstractMesh>;
  2068. /**
  2069. * Gets a list of meshes using their id
  2070. * @param id defines the id to search for
  2071. * @returns a list of meshes
  2072. */
  2073. getMeshesByID(id: string): Array<AbstractMesh>;
  2074. /**
  2075. * Gets the first added transform node found of a given ID
  2076. * @param id defines the id to search for
  2077. * @return the found transform node or null if not found at all.
  2078. */
  2079. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2080. /**
  2081. * Gets a list of transform nodes using their id
  2082. * @param id defines the id to search for
  2083. * @returns a list of transform nodes
  2084. */
  2085. getTransformNodesByID(id: string): Array<TransformNode>;
  2086. /**
  2087. * Gets a mesh with its auto-generated unique id
  2088. * @param uniqueId defines the unique id to search for
  2089. * @return the found mesh or null if not found at all.
  2090. */
  2091. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2092. /**
  2093. * Gets a the last added mesh using a given id
  2094. * @param id defines the id to search for
  2095. * @return the found mesh or null if not found at all.
  2096. */
  2097. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2098. /**
  2099. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2100. * @param id defines the id to search for
  2101. * @return the found node or null if not found at all
  2102. */
  2103. getLastEntryByID(id: string): Nullable<Node>;
  2104. /**
  2105. * Gets a node (Mesh, Camera, Light) using a given id
  2106. * @param id defines the id to search for
  2107. * @return the found node or null if not found at all
  2108. */
  2109. getNodeByID(id: string): Nullable<Node>;
  2110. /**
  2111. * Gets a node (Mesh, Camera, Light) using a given name
  2112. * @param name defines the name to search for
  2113. * @return the found node or null if not found at all.
  2114. */
  2115. getNodeByName(name: string): Nullable<Node>;
  2116. /**
  2117. * Gets a mesh using a given name
  2118. * @param name defines the name to search for
  2119. * @return the found mesh or null if not found at all.
  2120. */
  2121. getMeshByName(name: string): Nullable<AbstractMesh>;
  2122. /**
  2123. * Gets a transform node using a given name
  2124. * @param name defines the name to search for
  2125. * @return the found transform node or null if not found at all.
  2126. */
  2127. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2128. /**
  2129. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2130. * @param id defines the id to search for
  2131. * @return the found skeleton or null if not found at all.
  2132. */
  2133. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2134. /**
  2135. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2136. * @param id defines the id to search for
  2137. * @return the found skeleton or null if not found at all.
  2138. */
  2139. getSkeletonById(id: string): Nullable<Skeleton>;
  2140. /**
  2141. * Gets a skeleton using a given name
  2142. * @param name defines the name to search for
  2143. * @return the found skeleton or null if not found at all.
  2144. */
  2145. getSkeletonByName(name: string): Nullable<Skeleton>;
  2146. /**
  2147. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2148. * @param id defines the id to search for
  2149. * @return the found morph target manager or null if not found at all.
  2150. */
  2151. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2152. /**
  2153. * Gets a boolean indicating if the given mesh is active
  2154. * @param mesh defines the mesh to look for
  2155. * @returns true if the mesh is in the active list
  2156. */
  2157. isActiveMesh(mesh: AbstractMesh): boolean;
  2158. /**
  2159. * Return a unique id as a string which can serve as an identifier for the scene
  2160. */
  2161. readonly uid: string;
  2162. /**
  2163. * Add an externaly attached data from its key.
  2164. * This method call will fail and return false, if such key already exists.
  2165. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2166. * @param key the unique key that identifies the data
  2167. * @param data the data object to associate to the key for this Engine instance
  2168. * @return true if no such key were already present and the data was added successfully, false otherwise
  2169. */
  2170. addExternalData<T>(key: string, data: T): boolean;
  2171. /**
  2172. * Get an externaly attached data from its key
  2173. * @param key the unique key that identifies the data
  2174. * @return the associated data, if present (can be null), or undefined if not present
  2175. */
  2176. getExternalData<T>(key: string): Nullable<T>;
  2177. /**
  2178. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2179. * @param key the unique key that identifies the data
  2180. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2181. * @return the associated data, can be null if the factory returned null.
  2182. */
  2183. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2184. /**
  2185. * Remove an externaly attached data from the Engine instance
  2186. * @param key the unique key that identifies the data
  2187. * @return true if the data was successfully removed, false if it doesn't exist
  2188. */
  2189. removeExternalData(key: string): boolean;
  2190. private _evaluateSubMesh;
  2191. /**
  2192. * Clear the processed materials smart array preventing retention point in material dispose.
  2193. */
  2194. freeProcessedMaterials(): void;
  2195. /**
  2196. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2197. */
  2198. freeActiveMeshes(): void;
  2199. /**
  2200. * Clear the info related to rendering groups preventing retention points during dispose.
  2201. */
  2202. freeRenderingGroups(): void;
  2203. /** @hidden */
  2204. _isInIntermediateRendering(): boolean;
  2205. /**
  2206. * Lambda returning the list of potentially active meshes.
  2207. */
  2208. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2209. /**
  2210. * Lambda returning the list of potentially active sub meshes.
  2211. */
  2212. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2213. /**
  2214. * Lambda returning the list of potentially intersecting sub meshes.
  2215. */
  2216. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2217. /**
  2218. * Lambda returning the list of potentially colliding sub meshes.
  2219. */
  2220. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2221. private _activeMeshesFrozen;
  2222. /**
  2223. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2224. * @returns the current scene
  2225. */
  2226. freezeActiveMeshes(): Scene;
  2227. /**
  2228. * Use this function to restart evaluating active meshes on every frame
  2229. * @returns the current scene
  2230. */
  2231. unfreezeActiveMeshes(): Scene;
  2232. private _evaluateActiveMeshes;
  2233. private _activeMesh;
  2234. /**
  2235. * Update the transform matrix to update from the current active camera
  2236. * @param force defines a boolean used to force the update even if cache is up to date
  2237. */
  2238. updateTransformMatrix(force?: boolean): void;
  2239. /**
  2240. * 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)
  2241. * @param alternateCamera defines the camera to use
  2242. */
  2243. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2244. /** @hidden */
  2245. _allowPostProcessClearColor: boolean;
  2246. private _renderForCamera;
  2247. private _processSubCameras;
  2248. private _checkIntersections;
  2249. /** @hidden */
  2250. _advancePhysicsEngineStep(step: number): void;
  2251. /**
  2252. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2253. */
  2254. getDeterministicFrameTime: () => number;
  2255. /**
  2256. * Render the scene
  2257. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2258. */
  2259. render(updateCameras?: boolean): void;
  2260. /**
  2261. * Freeze all materials
  2262. * A frozen material will not be updatable but should be faster to render
  2263. */
  2264. freezeMaterials(): void;
  2265. /**
  2266. * Unfreeze all materials
  2267. * A frozen material will not be updatable but should be faster to render
  2268. */
  2269. unfreezeMaterials(): void;
  2270. /**
  2271. * Releases all held ressources
  2272. */
  2273. dispose(): void;
  2274. /**
  2275. * Gets if the scene is already disposed
  2276. */
  2277. readonly isDisposed: boolean;
  2278. /**
  2279. * Call this function to reduce memory footprint of the scene.
  2280. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2281. */
  2282. clearCachedVertexData(): void;
  2283. /**
  2284. * This function will remove the local cached buffer data from texture.
  2285. * It will save memory but will prevent the texture from being rebuilt
  2286. */
  2287. cleanCachedTextureBuffer(): void;
  2288. /**
  2289. * Get the world extend vectors with an optional filter
  2290. *
  2291. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2292. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2293. */
  2294. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2295. min: Vector3;
  2296. max: Vector3;
  2297. };
  2298. /**
  2299. * Creates a ray that can be used to pick in the scene
  2300. * @param x defines the x coordinate of the origin (on-screen)
  2301. * @param y defines the y coordinate of the origin (on-screen)
  2302. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2303. * @param camera defines the camera to use for the picking
  2304. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2305. * @returns a Ray
  2306. */
  2307. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  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 result defines the ray where to store the picking ray
  2314. * @param camera defines the camera to use for the picking
  2315. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2316. * @returns the current scene
  2317. */
  2318. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2319. /**
  2320. * Creates a ray that can be used to pick in the scene
  2321. * @param x defines the x coordinate of the origin (on-screen)
  2322. * @param y defines the y coordinate of the origin (on-screen)
  2323. * @param camera defines the camera to use for the picking
  2324. * @returns a Ray
  2325. */
  2326. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2327. /**
  2328. * Creates a ray that can be used to pick in the scene
  2329. * @param x defines the x coordinate of the origin (on-screen)
  2330. * @param y defines the y coordinate of the origin (on-screen)
  2331. * @param result defines the ray where to store the picking ray
  2332. * @param camera defines the camera to use for the picking
  2333. * @returns the current scene
  2334. */
  2335. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2336. private _internalPick;
  2337. private _internalMultiPick;
  2338. private _tempPickingRay;
  2339. /** Launch a ray to try to pick a mesh in the scene
  2340. * @param x position on screen
  2341. * @param y position on screen
  2342. * @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
  2343. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2344. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2345. * @returns a PickingInfo
  2346. */
  2347. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2348. private _cachedRayForTransform;
  2349. /** Use the given ray to pick a mesh in the scene
  2350. * @param ray The ray to use to pick meshes
  2351. * @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
  2352. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2353. * @returns a PickingInfo
  2354. */
  2355. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2356. /**
  2357. * Launch a ray to try to pick a mesh in the scene
  2358. * @param x X position on screen
  2359. * @param y Y position on screen
  2360. * @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
  2361. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2362. * @returns an array of PickingInfo
  2363. */
  2364. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2365. /**
  2366. * Launch a ray to try to pick a mesh in the scene
  2367. * @param ray Ray to use
  2368. * @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
  2369. * @returns an array of PickingInfo
  2370. */
  2371. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2372. /**
  2373. * Force the value of meshUnderPointer
  2374. * @param mesh defines the mesh to use
  2375. */
  2376. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2377. /**
  2378. * Gets the mesh under the pointer
  2379. * @returns a Mesh or null if no mesh is under the pointer
  2380. */
  2381. getPointerOverMesh(): Nullable<AbstractMesh>;
  2382. /** @hidden */
  2383. _rebuildGeometries(): void;
  2384. /** @hidden */
  2385. _rebuildTextures(): void;
  2386. private _getByTags;
  2387. /**
  2388. * Get a list of meshes by tags
  2389. * @param tagsQuery defines the tags query to use
  2390. * @param forEach defines a predicate used to filter results
  2391. * @returns an array of Mesh
  2392. */
  2393. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2394. /**
  2395. * Get a list of cameras by tags
  2396. * @param tagsQuery defines the tags query to use
  2397. * @param forEach defines a predicate used to filter results
  2398. * @returns an array of Camera
  2399. */
  2400. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2401. /**
  2402. * Get a list of lights by tags
  2403. * @param tagsQuery defines the tags query to use
  2404. * @param forEach defines a predicate used to filter results
  2405. * @returns an array of Light
  2406. */
  2407. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2408. /**
  2409. * Get a list of materials by tags
  2410. * @param tagsQuery defines the tags query to use
  2411. * @param forEach defines a predicate used to filter results
  2412. * @returns an array of Material
  2413. */
  2414. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2415. /**
  2416. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2417. * This allowed control for front to back rendering or reversly depending of the special needs.
  2418. *
  2419. * @param renderingGroupId The rendering group id corresponding to its index
  2420. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2421. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2422. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2423. */
  2424. 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;
  2425. /**
  2426. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2427. *
  2428. * @param renderingGroupId The rendering group id corresponding to its index
  2429. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2430. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2431. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2432. */
  2433. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2434. /**
  2435. * Gets the current auto clear configuration for one rendering group of the rendering
  2436. * manager.
  2437. * @param index the rendering group index to get the information for
  2438. * @returns The auto clear setup for the requested rendering group
  2439. */
  2440. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2441. private _blockMaterialDirtyMechanism;
  2442. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2443. blockMaterialDirtyMechanism: boolean;
  2444. /**
  2445. * Will flag all materials as dirty to trigger new shader compilation
  2446. * @param flag defines the flag used to specify which material part must be marked as dirty
  2447. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2448. */
  2449. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2450. /** @hidden */
  2451. _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;
  2452. /** @hidden */
  2453. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2454. }
  2455. }
  2456. declare module BABYLON {
  2457. /**
  2458. * Groups all the scene component constants in one place to ease maintenance.
  2459. * @hidden
  2460. */
  2461. class SceneComponentConstants {
  2462. static readonly NAME_EFFECTLAYER: string;
  2463. static readonly NAME_LAYER: string;
  2464. static readonly NAME_LENSFLARESYSTEM: string;
  2465. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2466. static readonly NAME_PARTICLESYSTEM: string;
  2467. static readonly NAME_GAMEPAD: string;
  2468. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2469. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2470. static readonly NAME_DEPTHRENDERER: string;
  2471. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2472. static readonly NAME_SPRITE: string;
  2473. static readonly NAME_OUTLINERENDERER: string;
  2474. static readonly NAME_PROCEDURALTEXTURE: string;
  2475. static readonly NAME_SHADOWGENERATOR: string;
  2476. static readonly NAME_OCTREE: string;
  2477. static readonly NAME_PHYSICSENGINE: string;
  2478. static readonly NAME_AUDIO: string;
  2479. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2480. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2481. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2482. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2483. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2484. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2485. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2486. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2487. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2488. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2489. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2490. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2491. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2492. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2493. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2494. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2495. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2496. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2497. static readonly STEP_AFTERRENDER_AUDIO: number;
  2498. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2499. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2500. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2501. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2502. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2503. static readonly STEP_POINTERMOVE_SPRITE: number;
  2504. static readonly STEP_POINTERDOWN_SPRITE: number;
  2505. static readonly STEP_POINTERUP_SPRITE: number;
  2506. }
  2507. /**
  2508. * This represents a scene component.
  2509. *
  2510. * This is used to decouple the dependency the scene is having on the different workloads like
  2511. * layers, post processes...
  2512. */
  2513. interface ISceneComponent {
  2514. /**
  2515. * The name of the component. Each component must have a unique name.
  2516. */
  2517. name: string;
  2518. /**
  2519. * The scene the component belongs to.
  2520. */
  2521. scene: Scene;
  2522. /**
  2523. * Register the component to one instance of a scene.
  2524. */
  2525. register(): void;
  2526. /**
  2527. * Rebuilds the elements related to this component in case of
  2528. * context lost for instance.
  2529. */
  2530. rebuild(): void;
  2531. /**
  2532. * Disposes the component and the associated ressources.
  2533. */
  2534. dispose(): void;
  2535. }
  2536. /**
  2537. * This represents a SERIALIZABLE scene component.
  2538. *
  2539. * This extends Scene Component to add Serialization methods on top.
  2540. */
  2541. interface ISceneSerializableComponent extends ISceneComponent {
  2542. /**
  2543. * Adds all the element from the container to the scene
  2544. * @param container the container holding the elements
  2545. */
  2546. addFromContainer(container: AbstractScene): void;
  2547. /**
  2548. * Removes all the elements in the container from the scene
  2549. * @param container contains the elements to remove
  2550. */
  2551. removeFromContainer(container: AbstractScene): void;
  2552. /**
  2553. * Serializes the component data to the specified json object
  2554. * @param serializationObject The object to serialize to
  2555. */
  2556. serialize(serializationObject: any): void;
  2557. }
  2558. /**
  2559. * Strong typing of a Mesh related stage step action
  2560. */
  2561. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2562. /**
  2563. * Strong typing of a Evaluate Sub Mesh related stage step action
  2564. */
  2565. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2566. /**
  2567. * Strong typing of a Active Mesh related stage step action
  2568. */
  2569. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2570. /**
  2571. * Strong typing of a Camera related stage step action
  2572. */
  2573. type CameraStageAction = (camera: Camera) => void;
  2574. /**
  2575. * Strong typing of a RenderingGroup related stage step action
  2576. */
  2577. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2578. /**
  2579. * Strong typing of a Mesh Render related stage step action
  2580. */
  2581. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2582. /**
  2583. * Strong typing of a simple stage step action
  2584. */
  2585. type SimpleStageAction = () => void;
  2586. /**
  2587. * Strong typing of a render target action.
  2588. */
  2589. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2590. /**
  2591. * Strong typing of a pointer move action.
  2592. */
  2593. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2594. /**
  2595. * Strong typing of a pointer up/down action.
  2596. */
  2597. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2598. /**
  2599. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2600. * @hidden
  2601. */
  2602. class Stage<T extends Function> extends Array<{
  2603. index: number;
  2604. component: ISceneComponent;
  2605. action: T;
  2606. }> {
  2607. /**
  2608. * Hide ctor from the rest of the world.
  2609. * @param items The items to add.
  2610. */
  2611. private constructor();
  2612. /**
  2613. * Creates a new Stage.
  2614. * @returns A new instance of a Stage
  2615. */
  2616. static Create<T extends Function>(): Stage<T>;
  2617. /**
  2618. * Registers a step in an ordered way in the targeted stage.
  2619. * @param index Defines the position to register the step in
  2620. * @param component Defines the component attached to the step
  2621. * @param action Defines the action to launch during the step
  2622. */
  2623. registerStep(index: number, component: ISceneComponent, action: T): void;
  2624. /**
  2625. * Clears all the steps from the stage.
  2626. */
  2627. clear(): void;
  2628. }
  2629. }
  2630. declare module BABYLON {
  2631. /** Alias type for value that can be null */
  2632. type Nullable<T> = T | null;
  2633. /**
  2634. * Alias type for number that are floats
  2635. * @ignorenaming
  2636. */
  2637. type float = number;
  2638. /**
  2639. * Alias type for number that are doubles.
  2640. * @ignorenaming
  2641. */
  2642. type double = number;
  2643. /**
  2644. * Alias type for number that are integer
  2645. * @ignorenaming
  2646. */
  2647. type int = number;
  2648. /** Alias type for number array or Float32Array */
  2649. type FloatArray = number[] | Float32Array;
  2650. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2651. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2652. /**
  2653. * Alias for types that can be used by a Buffer or VertexBuffer.
  2654. */
  2655. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2656. }
  2657. declare module BABYLON {
  2658. /**
  2659. * The action to be carried out following a trigger
  2660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2661. */
  2662. class Action {
  2663. /** the trigger, with or without parameters, for the action */
  2664. triggerOptions: any;
  2665. /**
  2666. * Trigger for the action
  2667. */
  2668. trigger: number;
  2669. /**
  2670. * Internal only - manager for action
  2671. * @hidden
  2672. */
  2673. _actionManager: ActionManager;
  2674. private _nextActiveAction;
  2675. private _child;
  2676. private _condition?;
  2677. private _triggerParameter;
  2678. /**
  2679. * An event triggered prior to action being executed.
  2680. */
  2681. onBeforeExecuteObservable: Observable<Action>;
  2682. /**
  2683. * Creates a new Action
  2684. * @param triggerOptions the trigger, with or without parameters, for the action
  2685. * @param condition an optional determinant of action
  2686. */
  2687. constructor(
  2688. /** the trigger, with or without parameters, for the action */
  2689. triggerOptions: any, condition?: Condition);
  2690. /**
  2691. * Internal only
  2692. * @hidden
  2693. */
  2694. _prepare(): void;
  2695. /**
  2696. * Gets the trigger parameters
  2697. * @returns the trigger parameters
  2698. */
  2699. getTriggerParameter(): any;
  2700. /**
  2701. * Internal only - executes current action event
  2702. * @hidden
  2703. */
  2704. _executeCurrent(evt?: ActionEvent): void;
  2705. /**
  2706. * Execute placeholder for child classes
  2707. * @param evt optional action event
  2708. */
  2709. execute(evt?: ActionEvent): void;
  2710. /**
  2711. * Skips to next active action
  2712. */
  2713. skipToNextActiveAction(): void;
  2714. /**
  2715. * Adds action to chain of actions, may be a DoNothingAction
  2716. * @param action defines the next action to execute
  2717. * @returns The action passed in
  2718. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2719. */
  2720. then(action: Action): Action;
  2721. /**
  2722. * Internal only
  2723. * @hidden
  2724. */
  2725. _getProperty(propertyPath: string): string;
  2726. /**
  2727. * Internal only
  2728. * @hidden
  2729. */
  2730. _getEffectiveTarget(target: any, propertyPath: string): any;
  2731. /**
  2732. * Serialize placeholder for child classes
  2733. * @param parent of child
  2734. * @returns the serialized object
  2735. */
  2736. serialize(parent: any): any;
  2737. /**
  2738. * Internal only called by serialize
  2739. * @hidden
  2740. */
  2741. protected _serialize(serializedAction: any, parent?: any): any;
  2742. /**
  2743. * Internal only
  2744. * @hidden
  2745. */
  2746. static _SerializeValueAsString: (value: any) => string;
  2747. /**
  2748. * Internal only
  2749. * @hidden
  2750. */
  2751. static _GetTargetProperty: (target: Scene | Node) => {
  2752. name: string;
  2753. targetType: string;
  2754. value: string;
  2755. };
  2756. }
  2757. }
  2758. declare module BABYLON {
  2759. /**
  2760. * ActionEvent is the event being sent when an action is triggered.
  2761. */
  2762. class ActionEvent {
  2763. /** The mesh or sprite that triggered the action */
  2764. source: any;
  2765. /** The X mouse cursor position at the time of the event */
  2766. pointerX: number;
  2767. /** The Y mouse cursor position at the time of the event */
  2768. pointerY: number;
  2769. /** The mesh that is currently pointed at (can be null) */
  2770. meshUnderPointer: Nullable<AbstractMesh>;
  2771. /** the original (browser) event that triggered the ActionEvent */
  2772. sourceEvent?: any;
  2773. /** additional data for the event */
  2774. additionalData?: any;
  2775. /**
  2776. * Creates a new ActionEvent
  2777. * @param source The mesh or sprite that triggered the action
  2778. * @param pointerX The X mouse cursor position at the time of the event
  2779. * @param pointerY The Y mouse cursor position at the time of the event
  2780. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2781. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2782. * @param additionalData additional data for the event
  2783. */
  2784. constructor(
  2785. /** The mesh or sprite that triggered the action */
  2786. source: any,
  2787. /** The X mouse cursor position at the time of the event */
  2788. pointerX: number,
  2789. /** The Y mouse cursor position at the time of the event */
  2790. pointerY: number,
  2791. /** The mesh that is currently pointed at (can be null) */
  2792. meshUnderPointer: Nullable<AbstractMesh>,
  2793. /** the original (browser) event that triggered the ActionEvent */
  2794. sourceEvent?: any,
  2795. /** additional data for the event */
  2796. additionalData?: any);
  2797. /**
  2798. * Helper function to auto-create an ActionEvent from a source mesh.
  2799. * @param source The source mesh that triggered the event
  2800. * @param evt The original (browser) event
  2801. * @param additionalData additional data for the event
  2802. * @returns the new ActionEvent
  2803. */
  2804. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2805. /**
  2806. * Helper function to auto-create an ActionEvent from a source sprite
  2807. * @param source The source sprite that triggered the event
  2808. * @param scene Scene associated with the sprite
  2809. * @param evt The original (browser) event
  2810. * @param additionalData additional data for the event
  2811. * @returns the new ActionEvent
  2812. */
  2813. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2814. /**
  2815. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2816. * @param scene the scene where the event occurred
  2817. * @param evt The original (browser) event
  2818. * @returns the new ActionEvent
  2819. */
  2820. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2821. /**
  2822. * Helper function to auto-create an ActionEvent from a primitive
  2823. * @param prim defines the target primitive
  2824. * @param pointerPos defines the pointer position
  2825. * @param evt The original (browser) event
  2826. * @param additionalData additional data for the event
  2827. * @returns the new ActionEvent
  2828. */
  2829. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2830. }
  2831. /**
  2832. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2833. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2835. */
  2836. class ActionManager {
  2837. /**
  2838. * Nothing
  2839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2840. */
  2841. static readonly NothingTrigger: number;
  2842. /**
  2843. * On pick
  2844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2845. */
  2846. static readonly OnPickTrigger: number;
  2847. /**
  2848. * On left pick
  2849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2850. */
  2851. static readonly OnLeftPickTrigger: number;
  2852. /**
  2853. * On right pick
  2854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2855. */
  2856. static readonly OnRightPickTrigger: number;
  2857. /**
  2858. * On center pick
  2859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2860. */
  2861. static readonly OnCenterPickTrigger: number;
  2862. /**
  2863. * On pick down
  2864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2865. */
  2866. static readonly OnPickDownTrigger: number;
  2867. /**
  2868. * On double pick
  2869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2870. */
  2871. static readonly OnDoublePickTrigger: number;
  2872. /**
  2873. * On pick up
  2874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2875. */
  2876. static readonly OnPickUpTrigger: number;
  2877. /**
  2878. * On pick out.
  2879. * This trigger will only be raised if you also declared a OnPickDown
  2880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2881. */
  2882. static readonly OnPickOutTrigger: number;
  2883. /**
  2884. * On long press
  2885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2886. */
  2887. static readonly OnLongPressTrigger: number;
  2888. /**
  2889. * On pointer over
  2890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2891. */
  2892. static readonly OnPointerOverTrigger: number;
  2893. /**
  2894. * On pointer out
  2895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2896. */
  2897. static readonly OnPointerOutTrigger: number;
  2898. /**
  2899. * On every frame
  2900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2901. */
  2902. static readonly OnEveryFrameTrigger: number;
  2903. /**
  2904. * On intersection enter
  2905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2906. */
  2907. static readonly OnIntersectionEnterTrigger: number;
  2908. /**
  2909. * On intersection exit
  2910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2911. */
  2912. static readonly OnIntersectionExitTrigger: number;
  2913. /**
  2914. * On key down
  2915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2916. */
  2917. static readonly OnKeyDownTrigger: number;
  2918. /**
  2919. * On key up
  2920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2921. */
  2922. static readonly OnKeyUpTrigger: number;
  2923. /** Gets the list of active triggers */
  2924. static Triggers: {
  2925. [key: string]: number;
  2926. };
  2927. /** Gets the list of actions */
  2928. actions: Action[];
  2929. /** Gets the cursor to use when hovering items */
  2930. hoverCursor: string;
  2931. private _scene;
  2932. /**
  2933. * Creates a new action manager
  2934. * @param scene defines the hosting scene
  2935. */
  2936. constructor(scene: Scene);
  2937. /**
  2938. * Releases all associated resources
  2939. */
  2940. dispose(): void;
  2941. /**
  2942. * Gets hosting scene
  2943. * @returns the hosting scene
  2944. */
  2945. getScene(): Scene;
  2946. /**
  2947. * Does this action manager handles actions of any of the given triggers
  2948. * @param triggers defines the triggers to be tested
  2949. * @return a boolean indicating whether one (or more) of the triggers is handled
  2950. */
  2951. hasSpecificTriggers(triggers: number[]): boolean;
  2952. /**
  2953. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2954. * speed.
  2955. * @param triggerA defines the trigger to be tested
  2956. * @param triggerB defines the trigger to be tested
  2957. * @return a boolean indicating whether one (or more) of the triggers is handled
  2958. */
  2959. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2960. /**
  2961. * Does this action manager handles actions of a given trigger
  2962. * @param trigger defines the trigger to be tested
  2963. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2964. * @return whether the trigger is handled
  2965. */
  2966. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2967. /**
  2968. * Does this action manager has pointer triggers
  2969. */
  2970. readonly hasPointerTriggers: boolean;
  2971. /**
  2972. * Does this action manager has pick triggers
  2973. */
  2974. readonly hasPickTriggers: boolean;
  2975. /**
  2976. * Does exist one action manager with at least one trigger
  2977. **/
  2978. static readonly HasTriggers: boolean;
  2979. /**
  2980. * Does exist one action manager with at least one pick trigger
  2981. **/
  2982. static readonly HasPickTriggers: boolean;
  2983. /**
  2984. * Does exist one action manager that handles actions of a given trigger
  2985. * @param trigger defines the trigger to be tested
  2986. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2987. **/
  2988. static HasSpecificTrigger(trigger: number): boolean;
  2989. /**
  2990. * Registers an action to this action manager
  2991. * @param action defines the action to be registered
  2992. * @return the action amended (prepared) after registration
  2993. */
  2994. registerAction(action: Action): Nullable<Action>;
  2995. /**
  2996. * Unregisters an action to this action manager
  2997. * @param action defines the action to be unregistered
  2998. * @return a boolean indicating whether the action has been unregistered
  2999. */
  3000. unregisterAction(action: Action): Boolean;
  3001. /**
  3002. * Process a specific trigger
  3003. * @param trigger defines the trigger to process
  3004. * @param evt defines the event details to be processed
  3005. */
  3006. processTrigger(trigger: number, evt?: ActionEvent): void;
  3007. /** @hidden */
  3008. _getEffectiveTarget(target: any, propertyPath: string): any;
  3009. /** @hidden */
  3010. _getProperty(propertyPath: string): string;
  3011. /**
  3012. * Serialize this manager to a JSON object
  3013. * @param name defines the property name to store this manager
  3014. * @returns a JSON representation of this manager
  3015. */
  3016. serialize(name: string): any;
  3017. /**
  3018. * Creates a new ActionManager from a JSON data
  3019. * @param parsedActions defines the JSON data to read from
  3020. * @param object defines the hosting mesh
  3021. * @param scene defines the hosting scene
  3022. */
  3023. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3024. /**
  3025. * Get a trigger name by index
  3026. * @param trigger defines the trigger index
  3027. * @returns a trigger name
  3028. */
  3029. static GetTriggerName(trigger: number): string;
  3030. }
  3031. }
  3032. declare module BABYLON {
  3033. /**
  3034. * A Condition applied to an Action
  3035. */
  3036. class Condition {
  3037. /**
  3038. * Internal only - manager for action
  3039. * @hidden
  3040. */
  3041. _actionManager: ActionManager;
  3042. /**
  3043. * Internal only
  3044. * @hidden
  3045. */
  3046. _evaluationId: number;
  3047. /**
  3048. * Internal only
  3049. * @hidden
  3050. */
  3051. _currentResult: boolean;
  3052. /**
  3053. * Creates a new Condition
  3054. * @param actionManager the manager of the action the condition is applied to
  3055. */
  3056. constructor(actionManager: ActionManager);
  3057. /**
  3058. * Check if the current condition is valid
  3059. * @returns a boolean
  3060. */
  3061. isValid(): boolean;
  3062. /**
  3063. * Internal only
  3064. * @hidden
  3065. */
  3066. _getProperty(propertyPath: string): string;
  3067. /**
  3068. * Internal only
  3069. * @hidden
  3070. */
  3071. _getEffectiveTarget(target: any, propertyPath: string): any;
  3072. /**
  3073. * Serialize placeholder for child classes
  3074. * @returns the serialized object
  3075. */
  3076. serialize(): any;
  3077. /**
  3078. * Internal only
  3079. * @hidden
  3080. */
  3081. protected _serialize(serializedCondition: any): any;
  3082. }
  3083. /**
  3084. * Defines specific conditional operators as extensions of Condition
  3085. */
  3086. class ValueCondition extends Condition {
  3087. /** path to specify the property of the target the conditional operator uses */
  3088. propertyPath: string;
  3089. /** the value compared by the conditional operator against the current value of the property */
  3090. value: any;
  3091. /** the conditional operator, default ValueCondition.IsEqual */
  3092. operator: number;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsEqual;
  3098. /**
  3099. * Internal only
  3100. * @hidden
  3101. */
  3102. private static _IsDifferent;
  3103. /**
  3104. * Internal only
  3105. * @hidden
  3106. */
  3107. private static _IsGreater;
  3108. /**
  3109. * Internal only
  3110. * @hidden
  3111. */
  3112. private static _IsLesser;
  3113. /**
  3114. * returns the number for IsEqual
  3115. */
  3116. static readonly IsEqual: number;
  3117. /**
  3118. * Returns the number for IsDifferent
  3119. */
  3120. static readonly IsDifferent: number;
  3121. /**
  3122. * Returns the number for IsGreater
  3123. */
  3124. static readonly IsGreater: number;
  3125. /**
  3126. * Returns the number for IsLesser
  3127. */
  3128. static readonly IsLesser: number;
  3129. /**
  3130. * Internal only The action manager for the condition
  3131. * @hidden
  3132. */
  3133. _actionManager: ActionManager;
  3134. /**
  3135. * Internal only
  3136. * @hidden
  3137. */
  3138. private _target;
  3139. /**
  3140. * Internal only
  3141. * @hidden
  3142. */
  3143. private _effectiveTarget;
  3144. /**
  3145. * Internal only
  3146. * @hidden
  3147. */
  3148. private _property;
  3149. /**
  3150. * Creates a new ValueCondition
  3151. * @param actionManager manager for the action the condition applies to
  3152. * @param target for the action
  3153. * @param propertyPath path to specify the property of the target the conditional operator uses
  3154. * @param value the value compared by the conditional operator against the current value of the property
  3155. * @param operator the conditional operator, default ValueCondition.IsEqual
  3156. */
  3157. constructor(actionManager: ActionManager, target: any,
  3158. /** path to specify the property of the target the conditional operator uses */
  3159. propertyPath: string,
  3160. /** the value compared by the conditional operator against the current value of the property */
  3161. value: any,
  3162. /** the conditional operator, default ValueCondition.IsEqual */
  3163. operator?: number);
  3164. /**
  3165. * Compares the given value with the property value for the specified conditional operator
  3166. * @returns the result of the comparison
  3167. */
  3168. isValid(): boolean;
  3169. /**
  3170. * Serialize the ValueCondition into a JSON compatible object
  3171. * @returns serialization object
  3172. */
  3173. serialize(): any;
  3174. /**
  3175. * Gets the name of the conditional operator for the ValueCondition
  3176. * @param operator the conditional operator
  3177. * @returns the name
  3178. */
  3179. static GetOperatorName(operator: number): string;
  3180. }
  3181. /**
  3182. * Defines a predicate condition as an extension of Condition
  3183. */
  3184. class PredicateCondition extends Condition {
  3185. /** defines the predicate function used to validate the condition */
  3186. predicate: () => boolean;
  3187. /**
  3188. * Internal only - manager for action
  3189. * @hidden
  3190. */
  3191. _actionManager: ActionManager;
  3192. /**
  3193. * Creates a new PredicateCondition
  3194. * @param actionManager manager for the action the condition applies to
  3195. * @param predicate defines the predicate function used to validate the condition
  3196. */
  3197. constructor(actionManager: ActionManager,
  3198. /** defines the predicate function used to validate the condition */
  3199. predicate: () => boolean);
  3200. /**
  3201. * @returns the validity of the predicate condition
  3202. */
  3203. isValid(): boolean;
  3204. }
  3205. /**
  3206. * Defines a state condition as an extension of Condition
  3207. */
  3208. class StateCondition extends Condition {
  3209. value: string;
  3210. /**
  3211. * Internal only - manager for action
  3212. * @hidden
  3213. */
  3214. _actionManager: ActionManager;
  3215. /**
  3216. * Internal only
  3217. * @hidden
  3218. */
  3219. private _target;
  3220. /**
  3221. * Creates a new StateCondition
  3222. * @param actionManager manager for the action the condition applies to
  3223. * @param target of the condition
  3224. * @param value to compare with target state
  3225. */
  3226. constructor(actionManager: ActionManager, target: any, value: string);
  3227. /**
  3228. * @returns the validity of the state
  3229. */
  3230. isValid(): boolean;
  3231. /**
  3232. * Serialize the StateCondition into a JSON compatible object
  3233. * @returns serialization object
  3234. */
  3235. serialize(): any;
  3236. }
  3237. }
  3238. declare module BABYLON {
  3239. /**
  3240. * This defines an action responsible to toggle a boolean once triggered.
  3241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3242. */
  3243. class SwitchBooleanAction extends Action {
  3244. /**
  3245. * The path to the boolean property in the target object
  3246. */
  3247. propertyPath: string;
  3248. private _target;
  3249. private _effectiveTarget;
  3250. private _property;
  3251. /**
  3252. * Instantiate the action
  3253. * @param triggerOptions defines the trigger options
  3254. * @param target defines the object containing the boolean
  3255. * @param propertyPath defines the path to the boolean property in the target object
  3256. * @param condition defines the trigger related conditions
  3257. */
  3258. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3259. /** @hidden */
  3260. _prepare(): void;
  3261. /**
  3262. * Execute the action toggle the boolean value.
  3263. */
  3264. execute(): void;
  3265. /**
  3266. * Serializes the actions and its related information.
  3267. * @param parent defines the object to serialize in
  3268. * @returns the serialized object
  3269. */
  3270. serialize(parent: any): any;
  3271. }
  3272. /**
  3273. * This defines an action responsible to set a the state field of the target
  3274. * to a desired value once triggered.
  3275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3276. */
  3277. class SetStateAction extends Action {
  3278. /**
  3279. * The value to store in the state field.
  3280. */
  3281. value: string;
  3282. private _target;
  3283. /**
  3284. * Instantiate the action
  3285. * @param triggerOptions defines the trigger options
  3286. * @param target defines the object containing the state property
  3287. * @param value defines the value to store in the state field
  3288. * @param condition defines the trigger related conditions
  3289. */
  3290. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3291. /**
  3292. * Execute the action and store the value on the target state property.
  3293. */
  3294. execute(): void;
  3295. /**
  3296. * Serializes the actions and its related information.
  3297. * @param parent defines the object to serialize in
  3298. * @returns the serialized object
  3299. */
  3300. serialize(parent: any): any;
  3301. }
  3302. /**
  3303. * This defines an action responsible to set a property of the target
  3304. * to a desired value once triggered.
  3305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3306. */
  3307. class SetValueAction extends Action {
  3308. /**
  3309. * The path of the property to set in the target.
  3310. */
  3311. propertyPath: string;
  3312. /**
  3313. * The value to set in the property
  3314. */
  3315. value: any;
  3316. private _target;
  3317. private _effectiveTarget;
  3318. private _property;
  3319. /**
  3320. * Instantiate the action
  3321. * @param triggerOptions defines the trigger options
  3322. * @param target defines the object containing the property
  3323. * @param propertyPath defines the path of the property to set in the target
  3324. * @param value defines the value to set in the property
  3325. * @param condition defines the trigger related conditions
  3326. */
  3327. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3328. /** @hidden */
  3329. _prepare(): void;
  3330. /**
  3331. * Execute the action and set the targetted property to the desired value.
  3332. */
  3333. execute(): void;
  3334. /**
  3335. * Serializes the actions and its related information.
  3336. * @param parent defines the object to serialize in
  3337. * @returns the serialized object
  3338. */
  3339. serialize(parent: any): any;
  3340. }
  3341. /**
  3342. * This defines an action responsible to increment the target value
  3343. * to a desired value once triggered.
  3344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3345. */
  3346. class IncrementValueAction extends Action {
  3347. /**
  3348. * The path of the property to increment in the target.
  3349. */
  3350. propertyPath: string;
  3351. /**
  3352. * The value we should increment the property by.
  3353. */
  3354. value: any;
  3355. private _target;
  3356. private _effectiveTarget;
  3357. private _property;
  3358. /**
  3359. * Instantiate the action
  3360. * @param triggerOptions defines the trigger options
  3361. * @param target defines the object containing the property
  3362. * @param propertyPath defines the path of the property to increment in the target
  3363. * @param value defines the value value we should increment the property by
  3364. * @param condition defines the trigger related conditions
  3365. */
  3366. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3367. /** @hidden */
  3368. _prepare(): void;
  3369. /**
  3370. * Execute the action and increment the target of the value amount.
  3371. */
  3372. execute(): void;
  3373. /**
  3374. * Serializes the actions and its related information.
  3375. * @param parent defines the object to serialize in
  3376. * @returns the serialized object
  3377. */
  3378. serialize(parent: any): any;
  3379. }
  3380. /**
  3381. * This defines an action responsible to start an animation once triggered.
  3382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3383. */
  3384. class PlayAnimationAction extends Action {
  3385. /**
  3386. * Where the animation should start (animation frame)
  3387. */
  3388. from: number;
  3389. /**
  3390. * Where the animation should stop (animation frame)
  3391. */
  3392. to: number;
  3393. /**
  3394. * Define if the animation should loop or stop after the first play.
  3395. */
  3396. loop?: boolean;
  3397. private _target;
  3398. /**
  3399. * Instantiate the action
  3400. * @param triggerOptions defines the trigger options
  3401. * @param target defines the target animation or animation name
  3402. * @param from defines from where the animation should start (animation frame)
  3403. * @param end defines where the animation should stop (animation frame)
  3404. * @param loop defines if the animation should loop or stop after the first play
  3405. * @param condition defines the trigger related conditions
  3406. */
  3407. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3408. /** @hidden */
  3409. _prepare(): void;
  3410. /**
  3411. * Execute the action and play the animation.
  3412. */
  3413. execute(): void;
  3414. /**
  3415. * Serializes the actions and its related information.
  3416. * @param parent defines the object to serialize in
  3417. * @returns the serialized object
  3418. */
  3419. serialize(parent: any): any;
  3420. }
  3421. /**
  3422. * This defines an action responsible to stop an animation once triggered.
  3423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3424. */
  3425. class StopAnimationAction extends Action {
  3426. private _target;
  3427. /**
  3428. * Instantiate the action
  3429. * @param triggerOptions defines the trigger options
  3430. * @param target defines the target animation or animation name
  3431. * @param condition defines the trigger related conditions
  3432. */
  3433. constructor(triggerOptions: any, target: any, condition?: Condition);
  3434. /** @hidden */
  3435. _prepare(): void;
  3436. /**
  3437. * Execute the action and stop the animation.
  3438. */
  3439. execute(): void;
  3440. /**
  3441. * Serializes the actions and its related information.
  3442. * @param parent defines the object to serialize in
  3443. * @returns the serialized object
  3444. */
  3445. serialize(parent: any): any;
  3446. }
  3447. /**
  3448. * This defines an action responsible that does nothing once triggered.
  3449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3450. */
  3451. class DoNothingAction extends Action {
  3452. /**
  3453. * Instantiate the action
  3454. * @param triggerOptions defines the trigger options
  3455. * @param condition defines the trigger related conditions
  3456. */
  3457. constructor(triggerOptions?: any, condition?: Condition);
  3458. /**
  3459. * Execute the action and do nothing.
  3460. */
  3461. execute(): void;
  3462. /**
  3463. * Serializes the actions and its related information.
  3464. * @param parent defines the object to serialize in
  3465. * @returns the serialized object
  3466. */
  3467. serialize(parent: any): any;
  3468. }
  3469. /**
  3470. * This defines an action responsible to trigger several actions once triggered.
  3471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3472. */
  3473. class CombineAction extends Action {
  3474. /**
  3475. * The list of aggregated animations to run.
  3476. */
  3477. children: Action[];
  3478. /**
  3479. * Instantiate the action
  3480. * @param triggerOptions defines the trigger options
  3481. * @param children defines the list of aggregated animations to run
  3482. * @param condition defines the trigger related conditions
  3483. */
  3484. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3485. /** @hidden */
  3486. _prepare(): void;
  3487. /**
  3488. * Execute the action and executes all the aggregated actions.
  3489. */
  3490. execute(evt: ActionEvent): void;
  3491. /**
  3492. * Serializes the actions and its related information.
  3493. * @param parent defines the object to serialize in
  3494. * @returns the serialized object
  3495. */
  3496. serialize(parent: any): any;
  3497. }
  3498. /**
  3499. * This defines an action responsible to run code (external event) once triggered.
  3500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3501. */
  3502. class ExecuteCodeAction extends Action {
  3503. /**
  3504. * The callback function to run.
  3505. */
  3506. func: (evt: ActionEvent) => void;
  3507. /**
  3508. * Instantiate the action
  3509. * @param triggerOptions defines the trigger options
  3510. * @param func defines the callback function to run
  3511. * @param condition defines the trigger related conditions
  3512. */
  3513. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3514. /**
  3515. * Execute the action and run the attached code.
  3516. */
  3517. execute(evt: ActionEvent): void;
  3518. }
  3519. /**
  3520. * This defines an action responsible to set the parent property of the target once triggered.
  3521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3522. */
  3523. class SetParentAction extends Action {
  3524. private _parent;
  3525. private _target;
  3526. /**
  3527. * Instantiate the action
  3528. * @param triggerOptions defines the trigger options
  3529. * @param target defines the target containing the parent property
  3530. * @param parent defines from where the animation should start (animation frame)
  3531. * @param condition defines the trigger related conditions
  3532. */
  3533. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3534. /** @hidden */
  3535. _prepare(): void;
  3536. /**
  3537. * Execute the action and set the parent property.
  3538. */
  3539. execute(): void;
  3540. /**
  3541. * Serializes the actions and its related information.
  3542. * @param parent defines the object to serialize in
  3543. * @returns the serialized object
  3544. */
  3545. serialize(parent: any): any;
  3546. }
  3547. }
  3548. declare module BABYLON {
  3549. /**
  3550. * This defines an action helpful to play a defined sound on a triggered action.
  3551. */
  3552. class PlaySoundAction extends Action {
  3553. private _sound;
  3554. /**
  3555. * Instantiate the action
  3556. * @param triggerOptions defines the trigger options
  3557. * @param sound defines the sound to play
  3558. * @param condition defines the trigger related conditions
  3559. */
  3560. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3561. /** @hidden */
  3562. _prepare(): void;
  3563. /**
  3564. * Execute the action and play the sound.
  3565. */
  3566. execute(): void;
  3567. /**
  3568. * Serializes the actions and its related information.
  3569. * @param parent defines the object to serialize in
  3570. * @returns the serialized object
  3571. */
  3572. serialize(parent: any): any;
  3573. }
  3574. /**
  3575. * This defines an action helpful to stop a defined sound on a triggered action.
  3576. */
  3577. class StopSoundAction extends Action {
  3578. private _sound;
  3579. /**
  3580. * Instantiate the action
  3581. * @param triggerOptions defines the trigger options
  3582. * @param sound defines the sound to stop
  3583. * @param condition defines the trigger related conditions
  3584. */
  3585. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3586. /** @hidden */
  3587. _prepare(): void;
  3588. /**
  3589. * Execute the action and stop the sound.
  3590. */
  3591. execute(): void;
  3592. /**
  3593. * Serializes the actions and its related information.
  3594. * @param parent defines the object to serialize in
  3595. * @returns the serialized object
  3596. */
  3597. serialize(parent: any): any;
  3598. }
  3599. }
  3600. declare module BABYLON {
  3601. /**
  3602. * This defines an action responsible to change the value of a property
  3603. * by interpolating between its current value and the newly set one once triggered.
  3604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3605. */
  3606. class InterpolateValueAction extends Action {
  3607. /**
  3608. * Defines the path of the property where the value should be interpolated
  3609. */
  3610. propertyPath: string;
  3611. /**
  3612. * Defines the target value at the end of the interpolation.
  3613. */
  3614. value: any;
  3615. /**
  3616. * Defines the time it will take for the property to interpolate to the value.
  3617. */
  3618. duration: number;
  3619. /**
  3620. * Defines if the other scene animations should be stopped when the action has been triggered
  3621. */
  3622. stopOtherAnimations?: boolean;
  3623. /**
  3624. * Defines a callback raised once the interpolation animation has been done.
  3625. */
  3626. onInterpolationDone?: () => void;
  3627. /**
  3628. * Observable triggered once the interpolation animation has been done.
  3629. */
  3630. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3631. private _target;
  3632. private _effectiveTarget;
  3633. private _property;
  3634. /**
  3635. * Instantiate the action
  3636. * @param triggerOptions defines the trigger options
  3637. * @param target defines the object containing the value to interpolate
  3638. * @param propertyPath defines the path to the property in the target object
  3639. * @param value defines the target value at the end of the interpolation
  3640. * @param duration deines the time it will take for the property to interpolate to the value.
  3641. * @param condition defines the trigger related conditions
  3642. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3643. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3644. */
  3645. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3646. /** @hidden */
  3647. _prepare(): void;
  3648. /**
  3649. * Execute the action starts the value interpolation.
  3650. */
  3651. execute(): void;
  3652. /**
  3653. * Serializes the actions and its related information.
  3654. * @param parent defines the object to serialize in
  3655. * @returns the serialized object
  3656. */
  3657. serialize(parent: any): any;
  3658. }
  3659. }
  3660. declare module BABYLON {
  3661. /**
  3662. * Class used to store an actual running animation
  3663. */
  3664. class Animatable {
  3665. /** defines the target object */
  3666. target: any;
  3667. /** defines the starting frame number (default is 0) */
  3668. fromFrame: number;
  3669. /** defines the ending frame number (default is 100) */
  3670. toFrame: number;
  3671. /** defines if the animation must loop (default is false) */
  3672. loopAnimation: boolean;
  3673. /** defines a callback to call when animation ends if it is not looping */
  3674. onAnimationEnd?: (() => void) | null | undefined;
  3675. private _localDelayOffset;
  3676. private _pausedDelay;
  3677. private _runtimeAnimations;
  3678. private _paused;
  3679. private _scene;
  3680. private _speedRatio;
  3681. private _weight;
  3682. private _syncRoot;
  3683. /**
  3684. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3685. * This will only apply for non looping animation (default is true)
  3686. */
  3687. disposeOnEnd: boolean;
  3688. /**
  3689. * Gets a boolean indicating if the animation has started
  3690. */
  3691. animationStarted: boolean;
  3692. /**
  3693. * Observer raised when the animation ends
  3694. */
  3695. onAnimationEndObservable: Observable<Animatable>;
  3696. /**
  3697. * Gets the root Animatable used to synchronize and normalize animations
  3698. */
  3699. readonly syncRoot: Animatable;
  3700. /**
  3701. * Gets the current frame of the first RuntimeAnimation
  3702. * Used to synchronize Animatables
  3703. */
  3704. readonly masterFrame: number;
  3705. /**
  3706. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3707. */
  3708. weight: number;
  3709. /**
  3710. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3711. */
  3712. speedRatio: number;
  3713. /**
  3714. * Creates a new Animatable
  3715. * @param scene defines the hosting scene
  3716. * @param target defines the target object
  3717. * @param fromFrame defines the starting frame number (default is 0)
  3718. * @param toFrame defines the ending frame number (default is 100)
  3719. * @param loopAnimation defines if the animation must loop (default is false)
  3720. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3721. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3722. * @param animations defines a group of animation to add to the new Animatable
  3723. */
  3724. constructor(scene: Scene,
  3725. /** defines the target object */
  3726. target: any,
  3727. /** defines the starting frame number (default is 0) */
  3728. fromFrame?: number,
  3729. /** defines the ending frame number (default is 100) */
  3730. toFrame?: number,
  3731. /** defines if the animation must loop (default is false) */
  3732. loopAnimation?: boolean, speedRatio?: number,
  3733. /** defines a callback to call when animation ends if it is not looping */
  3734. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3735. /**
  3736. * Synchronize and normalize current Animatable with a source Animatable
  3737. * This is useful when using animation weights and when animations are not of the same length
  3738. * @param root defines the root Animatable to synchronize with
  3739. * @returns the current Animatable
  3740. */
  3741. syncWith(root: Animatable): Animatable;
  3742. /**
  3743. * Gets the list of runtime animations
  3744. * @returns an array of RuntimeAnimation
  3745. */
  3746. getAnimations(): RuntimeAnimation[];
  3747. /**
  3748. * Adds more animations to the current animatable
  3749. * @param target defines the target of the animations
  3750. * @param animations defines the new animations to add
  3751. */
  3752. appendAnimations(target: any, animations: Animation[]): void;
  3753. /**
  3754. * Gets the source animation for a specific property
  3755. * @param property defines the propertyu to look for
  3756. * @returns null or the source animation for the given property
  3757. */
  3758. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3759. /**
  3760. * Gets the runtime animation for a specific property
  3761. * @param property defines the propertyu to look for
  3762. * @returns null or the runtime animation for the given property
  3763. */
  3764. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3765. /**
  3766. * Resets the animatable to its original state
  3767. */
  3768. reset(): void;
  3769. /**
  3770. * Allows the animatable to blend with current running animations
  3771. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3772. * @param blendingSpeed defines the blending speed to use
  3773. */
  3774. enableBlending(blendingSpeed: number): void;
  3775. /**
  3776. * Disable animation blending
  3777. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3778. */
  3779. disableBlending(): void;
  3780. /**
  3781. * Jump directly to a given frame
  3782. * @param frame defines the frame to jump to
  3783. */
  3784. goToFrame(frame: number): void;
  3785. /**
  3786. * Pause the animation
  3787. */
  3788. pause(): void;
  3789. /**
  3790. * Restart the animation
  3791. */
  3792. restart(): void;
  3793. private _raiseOnAnimationEnd;
  3794. /**
  3795. * Stop and delete the current animation
  3796. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3797. * @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)
  3798. */
  3799. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3800. /**
  3801. * Wait asynchronously for the animation to end
  3802. * @returns a promise which will be fullfilled when the animation ends
  3803. */
  3804. waitAsync(): Promise<Animatable>;
  3805. /** @hidden */
  3806. _animate(delay: number): boolean;
  3807. }
  3808. }
  3809. declare module BABYLON {
  3810. /**
  3811. * Represents the range of an animation
  3812. */
  3813. class AnimationRange {
  3814. /**The name of the animation range**/
  3815. name: string;
  3816. /**The starting frame of the animation */
  3817. from: number;
  3818. /**The ending frame of the animation*/
  3819. to: number;
  3820. /**
  3821. * Initializes the range of an animation
  3822. * @param name The name of the animation range
  3823. * @param from The starting frame of the animation
  3824. * @param to The ending frame of the animation
  3825. */
  3826. constructor(
  3827. /**The name of the animation range**/
  3828. name: string,
  3829. /**The starting frame of the animation */
  3830. from: number,
  3831. /**The ending frame of the animation*/
  3832. to: number);
  3833. /**
  3834. * Makes a copy of the animation range
  3835. * @returns A copy of the animation range
  3836. */
  3837. clone(): AnimationRange;
  3838. }
  3839. /**
  3840. * Composed of a frame, and an action function
  3841. */
  3842. class AnimationEvent {
  3843. /** The frame for which the event is triggered **/
  3844. frame: number;
  3845. /** The event to perform when triggered **/
  3846. action: (currentFrame: number) => void;
  3847. /** Specifies if the event should be triggered only once**/
  3848. onlyOnce?: boolean | undefined;
  3849. /**
  3850. * Specifies if the animation event is done
  3851. */
  3852. isDone: boolean;
  3853. /**
  3854. * Initializes the animation event
  3855. * @param frame The frame for which the event is triggered
  3856. * @param action The event to perform when triggered
  3857. * @param onlyOnce Specifies if the event should be triggered only once
  3858. */
  3859. constructor(
  3860. /** The frame for which the event is triggered **/
  3861. frame: number,
  3862. /** The event to perform when triggered **/
  3863. action: (currentFrame: number) => void,
  3864. /** Specifies if the event should be triggered only once**/
  3865. onlyOnce?: boolean | undefined);
  3866. /** @hidden */
  3867. _clone(): AnimationEvent;
  3868. }
  3869. /**
  3870. * A cursor which tracks a point on a path
  3871. */
  3872. class PathCursor {
  3873. private path;
  3874. /**
  3875. * Stores path cursor callbacks for when an onchange event is triggered
  3876. */
  3877. private _onchange;
  3878. /**
  3879. * The value of the path cursor
  3880. */
  3881. value: number;
  3882. /**
  3883. * The animation array of the path cursor
  3884. */
  3885. animations: Animation[];
  3886. /**
  3887. * Initializes the path cursor
  3888. * @param path The path to track
  3889. */
  3890. constructor(path: Path2);
  3891. /**
  3892. * Gets the cursor point on the path
  3893. * @returns A point on the path cursor at the cursor location
  3894. */
  3895. getPoint(): Vector3;
  3896. /**
  3897. * Moves the cursor ahead by the step amount
  3898. * @param step The amount to move the cursor forward
  3899. * @returns This path cursor
  3900. */
  3901. moveAhead(step?: number): PathCursor;
  3902. /**
  3903. * Moves the cursor behind by the step amount
  3904. * @param step The amount to move the cursor back
  3905. * @returns This path cursor
  3906. */
  3907. moveBack(step?: number): PathCursor;
  3908. /**
  3909. * Moves the cursor by the step amount
  3910. * If the step amount is greater than one, an exception is thrown
  3911. * @param step The amount to move the cursor
  3912. * @returns This path cursor
  3913. */
  3914. move(step: number): PathCursor;
  3915. /**
  3916. * Ensures that the value is limited between zero and one
  3917. * @returns This path cursor
  3918. */
  3919. private ensureLimits;
  3920. /**
  3921. * Runs onchange callbacks on change (used by the animation engine)
  3922. * @returns This path cursor
  3923. */
  3924. private raiseOnChange;
  3925. /**
  3926. * Executes a function on change
  3927. * @param f A path cursor onchange callback
  3928. * @returns This path cursor
  3929. */
  3930. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3931. }
  3932. /**
  3933. * Defines an interface which represents an animation key frame
  3934. */
  3935. interface IAnimationKey {
  3936. /**
  3937. * Frame of the key frame
  3938. */
  3939. frame: number;
  3940. /**
  3941. * Value at the specifies key frame
  3942. */
  3943. value: any;
  3944. /**
  3945. * The input tangent for the cubic hermite spline
  3946. */
  3947. inTangent?: any;
  3948. /**
  3949. * The output tangent for the cubic hermite spline
  3950. */
  3951. outTangent?: any;
  3952. /**
  3953. * The animation interpolation type
  3954. */
  3955. interpolation?: AnimationKeyInterpolation;
  3956. }
  3957. /**
  3958. * Enum for the animation key frame interpolation type
  3959. */
  3960. enum AnimationKeyInterpolation {
  3961. /**
  3962. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3963. */
  3964. STEP = 1
  3965. }
  3966. /**
  3967. * Class used to store any kind of animation
  3968. */
  3969. class Animation {
  3970. /**Name of the animation */
  3971. name: string;
  3972. /**Property to animate */
  3973. targetProperty: string;
  3974. /**The frames per second of the animation */
  3975. framePerSecond: number;
  3976. /**The data type of the animation */
  3977. dataType: number;
  3978. /**The loop mode of the animation */
  3979. loopMode?: number | undefined;
  3980. /**Specifies if blending should be enabled */
  3981. enableBlending?: boolean | undefined;
  3982. /**
  3983. * Use matrix interpolation instead of using direct key value when animating matrices
  3984. */
  3985. static AllowMatricesInterpolation: boolean;
  3986. /**
  3987. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3988. */
  3989. static AllowMatrixDecomposeForInterpolation: boolean;
  3990. /**
  3991. * Stores the key frames of the animation
  3992. */
  3993. private _keys;
  3994. /**
  3995. * Stores the easing function of the animation
  3996. */
  3997. private _easingFunction;
  3998. /**
  3999. * @hidden Internal use only
  4000. */
  4001. _runtimeAnimations: RuntimeAnimation[];
  4002. /**
  4003. * The set of event that will be linked to this animation
  4004. */
  4005. private _events;
  4006. /**
  4007. * Stores an array of target property paths
  4008. */
  4009. targetPropertyPath: string[];
  4010. /**
  4011. * Stores the blending speed of the animation
  4012. */
  4013. blendingSpeed: number;
  4014. /**
  4015. * Stores the animation ranges for the animation
  4016. */
  4017. private _ranges;
  4018. /**
  4019. * @hidden Internal use
  4020. */
  4021. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4022. /**
  4023. * Sets up an animation
  4024. * @param property The property to animate
  4025. * @param animationType The animation type to apply
  4026. * @param framePerSecond The frames per second of the animation
  4027. * @param easingFunction The easing function used in the animation
  4028. * @returns The created animation
  4029. */
  4030. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4031. /**
  4032. * Create and start an animation on a node
  4033. * @param name defines the name of the global animation that will be run on all nodes
  4034. * @param node defines the root node where the animation will take place
  4035. * @param targetProperty defines property to animate
  4036. * @param framePerSecond defines the number of frame per second yo use
  4037. * @param totalFrame defines the number of frames in total
  4038. * @param from defines the initial value
  4039. * @param to defines the final value
  4040. * @param loopMode defines which loop mode you want to use (off by default)
  4041. * @param easingFunction defines the easing function to use (linear by default)
  4042. * @param onAnimationEnd defines the callback to call when animation end
  4043. * @returns the animatable created for this animation
  4044. */
  4045. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4046. /**
  4047. * Create and start an animation on a node and its descendants
  4048. * @param name defines the name of the global animation that will be run on all nodes
  4049. * @param node defines the root node where the animation will take place
  4050. * @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
  4051. * @param targetProperty defines property to animate
  4052. * @param framePerSecond defines the number of frame per second to use
  4053. * @param totalFrame defines the number of frames in total
  4054. * @param from defines the initial value
  4055. * @param to defines the final value
  4056. * @param loopMode defines which loop mode you want to use (off by default)
  4057. * @param easingFunction defines the easing function to use (linear by default)
  4058. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4059. * @returns the list of animatables created for all nodes
  4060. * @example https://www.babylonjs-playground.com/#MH0VLI
  4061. */
  4062. 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[]>;
  4063. /**
  4064. * Creates a new animation, merges it with the existing animations and starts it
  4065. * @param name Name of the animation
  4066. * @param node Node which contains the scene that begins the animations
  4067. * @param targetProperty Specifies which property to animate
  4068. * @param framePerSecond The frames per second of the animation
  4069. * @param totalFrame The total number of frames
  4070. * @param from The frame at the beginning of the animation
  4071. * @param to The frame at the end of the animation
  4072. * @param loopMode Specifies the loop mode of the animation
  4073. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4074. * @param onAnimationEnd Callback to run once the animation is complete
  4075. * @returns Nullable animation
  4076. */
  4077. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4078. /**
  4079. * Transition property of an host to the target Value
  4080. * @param property The property to transition
  4081. * @param targetValue The target Value of the property
  4082. * @param host The object where the property to animate belongs
  4083. * @param scene Scene used to run the animation
  4084. * @param frameRate Framerate (in frame/s) to use
  4085. * @param transition The transition type we want to use
  4086. * @param duration The duration of the animation, in milliseconds
  4087. * @param onAnimationEnd Callback trigger at the end of the animation
  4088. * @returns Nullable animation
  4089. */
  4090. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4091. /**
  4092. * Return the array of runtime animations currently using this animation
  4093. */
  4094. readonly runtimeAnimations: RuntimeAnimation[];
  4095. /**
  4096. * Specifies if any of the runtime animations are currently running
  4097. */
  4098. readonly hasRunningRuntimeAnimations: boolean;
  4099. /**
  4100. * Initializes the animation
  4101. * @param name Name of the animation
  4102. * @param targetProperty Property to animate
  4103. * @param framePerSecond The frames per second of the animation
  4104. * @param dataType The data type of the animation
  4105. * @param loopMode The loop mode of the animation
  4106. * @param enableBlendings Specifies if blending should be enabled
  4107. */
  4108. constructor(
  4109. /**Name of the animation */
  4110. name: string,
  4111. /**Property to animate */
  4112. targetProperty: string,
  4113. /**The frames per second of the animation */
  4114. framePerSecond: number,
  4115. /**The data type of the animation */
  4116. dataType: number,
  4117. /**The loop mode of the animation */
  4118. loopMode?: number | undefined,
  4119. /**Specifies if blending should be enabled */
  4120. enableBlending?: boolean | undefined);
  4121. /**
  4122. * Converts the animation to a string
  4123. * @param fullDetails support for multiple levels of logging within scene loading
  4124. * @returns String form of the animation
  4125. */
  4126. toString(fullDetails?: boolean): string;
  4127. /**
  4128. * Add an event to this animation
  4129. * @param event Event to add
  4130. */
  4131. addEvent(event: AnimationEvent): void;
  4132. /**
  4133. * Remove all events found at the given frame
  4134. * @param frame The frame to remove events from
  4135. */
  4136. removeEvents(frame: number): void;
  4137. /**
  4138. * Retrieves all the events from the animation
  4139. * @returns Events from the animation
  4140. */
  4141. getEvents(): AnimationEvent[];
  4142. /**
  4143. * Creates an animation range
  4144. * @param name Name of the animation range
  4145. * @param from Starting frame of the animation range
  4146. * @param to Ending frame of the animation
  4147. */
  4148. createRange(name: string, from: number, to: number): void;
  4149. /**
  4150. * Deletes an animation range by name
  4151. * @param name Name of the animation range to delete
  4152. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4153. */
  4154. deleteRange(name: string, deleteFrames?: boolean): void;
  4155. /**
  4156. * Gets the animation range by name, or null if not defined
  4157. * @param name Name of the animation range
  4158. * @returns Nullable animation range
  4159. */
  4160. getRange(name: string): Nullable<AnimationRange>;
  4161. /**
  4162. * Gets the key frames from the animation
  4163. * @returns The key frames of the animation
  4164. */
  4165. getKeys(): Array<IAnimationKey>;
  4166. /**
  4167. * Gets the highest frame rate of the animation
  4168. * @returns Highest frame rate of the animation
  4169. */
  4170. getHighestFrame(): number;
  4171. /**
  4172. * Gets the easing function of the animation
  4173. * @returns Easing function of the animation
  4174. */
  4175. getEasingFunction(): IEasingFunction;
  4176. /**
  4177. * Sets the easing function of the animation
  4178. * @param easingFunction A custom mathematical formula for animation
  4179. */
  4180. setEasingFunction(easingFunction: EasingFunction): void;
  4181. /**
  4182. * Interpolates a scalar linearly
  4183. * @param startValue Start value of the animation curve
  4184. * @param endValue End value of the animation curve
  4185. * @param gradient Scalar amount to interpolate
  4186. * @returns Interpolated scalar value
  4187. */
  4188. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4189. /**
  4190. * Interpolates a scalar cubically
  4191. * @param startValue Start value of the animation curve
  4192. * @param outTangent End tangent of the animation
  4193. * @param endValue End value of the animation curve
  4194. * @param inTangent Start tangent of the animation curve
  4195. * @param gradient Scalar amount to interpolate
  4196. * @returns Interpolated scalar value
  4197. */
  4198. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4199. /**
  4200. * Interpolates a quaternion using a spherical linear interpolation
  4201. * @param startValue Start value of the animation curve
  4202. * @param endValue End value of the animation curve
  4203. * @param gradient Scalar amount to interpolate
  4204. * @returns Interpolated quaternion value
  4205. */
  4206. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4207. /**
  4208. * Interpolates a quaternion cubically
  4209. * @param startValue Start value of the animation curve
  4210. * @param outTangent End tangent of the animation curve
  4211. * @param endValue End value of the animation curve
  4212. * @param inTangent Start tangent of the animation curve
  4213. * @param gradient Scalar amount to interpolate
  4214. * @returns Interpolated quaternion value
  4215. */
  4216. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4217. /**
  4218. * Interpolates a Vector3 linearl
  4219. * @param startValue Start value of the animation curve
  4220. * @param endValue End value of the animation curve
  4221. * @param gradient Scalar amount to interpolate
  4222. * @returns Interpolated scalar value
  4223. */
  4224. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4225. /**
  4226. * Interpolates a Vector3 cubically
  4227. * @param startValue Start value of the animation curve
  4228. * @param outTangent End tangent of the animation
  4229. * @param endValue End value of the animation curve
  4230. * @param inTangent Start tangent of the animation curve
  4231. * @param gradient Scalar amount to interpolate
  4232. * @returns InterpolatedVector3 value
  4233. */
  4234. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4235. /**
  4236. * Interpolates a Vector2 linearly
  4237. * @param startValue Start value of the animation curve
  4238. * @param endValue End value of the animation curve
  4239. * @param gradient Scalar amount to interpolate
  4240. * @returns Interpolated Vector2 value
  4241. */
  4242. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4243. /**
  4244. * Interpolates a Vector2 cubically
  4245. * @param startValue Start value of the animation curve
  4246. * @param outTangent End tangent of the animation
  4247. * @param endValue End value of the animation curve
  4248. * @param inTangent Start tangent of the animation curve
  4249. * @param gradient Scalar amount to interpolate
  4250. * @returns Interpolated Vector2 value
  4251. */
  4252. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4253. /**
  4254. * Interpolates a size linearly
  4255. * @param startValue Start value of the animation curve
  4256. * @param endValue End value of the animation curve
  4257. * @param gradient Scalar amount to interpolate
  4258. * @returns Interpolated Size value
  4259. */
  4260. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4261. /**
  4262. * Interpolates a Color3 linearly
  4263. * @param startValue Start value of the animation curve
  4264. * @param endValue End value of the animation curve
  4265. * @param gradient Scalar amount to interpolate
  4266. * @returns Interpolated Color3 value
  4267. */
  4268. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4269. /**
  4270. * @hidden Internal use only
  4271. */
  4272. _getKeyValue(value: any): any;
  4273. /**
  4274. * @hidden Internal use only
  4275. */
  4276. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4277. /**
  4278. * Defines the function to use to interpolate matrices
  4279. * @param startValue defines the start matrix
  4280. * @param endValue defines the end matrix
  4281. * @param gradient defines the gradient between both matrices
  4282. * @param result defines an optional target matrix where to store the interpolation
  4283. * @returns the interpolated matrix
  4284. */
  4285. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4286. /**
  4287. * Makes a copy of the animation
  4288. * @returns Cloned animation
  4289. */
  4290. clone(): Animation;
  4291. /**
  4292. * Sets the key frames of the animation
  4293. * @param values The animation key frames to set
  4294. */
  4295. setKeys(values: Array<IAnimationKey>): void;
  4296. /**
  4297. * Serializes the animation to an object
  4298. * @returns Serialized object
  4299. */
  4300. serialize(): any;
  4301. /**
  4302. * Float animation type
  4303. */
  4304. private static _ANIMATIONTYPE_FLOAT;
  4305. /**
  4306. * Vector3 animation type
  4307. */
  4308. private static _ANIMATIONTYPE_VECTOR3;
  4309. /**
  4310. * Quaternion animation type
  4311. */
  4312. private static _ANIMATIONTYPE_QUATERNION;
  4313. /**
  4314. * Matrix animation type
  4315. */
  4316. private static _ANIMATIONTYPE_MATRIX;
  4317. /**
  4318. * Color3 animation type
  4319. */
  4320. private static _ANIMATIONTYPE_COLOR3;
  4321. /**
  4322. * Vector2 animation type
  4323. */
  4324. private static _ANIMATIONTYPE_VECTOR2;
  4325. /**
  4326. * Size animation type
  4327. */
  4328. private static _ANIMATIONTYPE_SIZE;
  4329. /**
  4330. * Relative Loop Mode
  4331. */
  4332. private static _ANIMATIONLOOPMODE_RELATIVE;
  4333. /**
  4334. * Cycle Loop Mode
  4335. */
  4336. private static _ANIMATIONLOOPMODE_CYCLE;
  4337. /**
  4338. * Constant Loop Mode
  4339. */
  4340. private static _ANIMATIONLOOPMODE_CONSTANT;
  4341. /**
  4342. * Get the float animation type
  4343. */
  4344. static readonly ANIMATIONTYPE_FLOAT: number;
  4345. /**
  4346. * Get the Vector3 animation type
  4347. */
  4348. static readonly ANIMATIONTYPE_VECTOR3: number;
  4349. /**
  4350. * Get the Vector2 animation type
  4351. */
  4352. static readonly ANIMATIONTYPE_VECTOR2: number;
  4353. /**
  4354. * Get the Size animation type
  4355. */
  4356. static readonly ANIMATIONTYPE_SIZE: number;
  4357. /**
  4358. * Get the Quaternion animation type
  4359. */
  4360. static readonly ANIMATIONTYPE_QUATERNION: number;
  4361. /**
  4362. * Get the Matrix animation type
  4363. */
  4364. static readonly ANIMATIONTYPE_MATRIX: number;
  4365. /**
  4366. * Get the Color3 animation type
  4367. */
  4368. static readonly ANIMATIONTYPE_COLOR3: number;
  4369. /**
  4370. * Get the Relative Loop Mode
  4371. */
  4372. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4373. /**
  4374. * Get the Cycle Loop Mode
  4375. */
  4376. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4377. /**
  4378. * Get the Constant Loop Mode
  4379. */
  4380. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4381. /** @hidden */
  4382. static _UniversalLerp(left: any, right: any, amount: number): any;
  4383. /**
  4384. * Parses an animation object and creates an animation
  4385. * @param parsedAnimation Parsed animation object
  4386. * @returns Animation object
  4387. */
  4388. static Parse(parsedAnimation: any): Animation;
  4389. /**
  4390. * Appends the serialized animations from the source animations
  4391. * @param source Source containing the animations
  4392. * @param destination Target to store the animations
  4393. */
  4394. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4395. }
  4396. }
  4397. declare module BABYLON {
  4398. /**
  4399. * This class defines the direct association between an animation and a target
  4400. */
  4401. class TargetedAnimation {
  4402. animation: Animation;
  4403. target: any;
  4404. }
  4405. /**
  4406. * Use this class to create coordinated animations on multiple targets
  4407. */
  4408. class AnimationGroup implements IDisposable {
  4409. /** The name of the animation group */
  4410. name: string;
  4411. private _scene;
  4412. private _targetedAnimations;
  4413. private _animatables;
  4414. private _from;
  4415. private _to;
  4416. private _isStarted;
  4417. private _speedRatio;
  4418. /**
  4419. * This observable will notify when one animation have ended.
  4420. */
  4421. onAnimationEndObservable: Observable<TargetedAnimation>;
  4422. /**
  4423. * This observable will notify when all animations have ended.
  4424. */
  4425. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4426. /**
  4427. * This observable will notify when all animations have paused.
  4428. */
  4429. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4430. /**
  4431. * Gets the first frame
  4432. */
  4433. readonly from: number;
  4434. /**
  4435. * Gets the last frame
  4436. */
  4437. readonly to: number;
  4438. /**
  4439. * Define if the animations are started
  4440. */
  4441. readonly isStarted: boolean;
  4442. /**
  4443. * Gets or sets the speed ratio to use for all animations
  4444. */
  4445. /**
  4446. * Gets or sets the speed ratio to use for all animations
  4447. */
  4448. speedRatio: number;
  4449. /**
  4450. * Gets the targeted animations for this animation group
  4451. */
  4452. readonly targetedAnimations: Array<TargetedAnimation>;
  4453. /**
  4454. * returning the list of animatables controlled by this animation group.
  4455. */
  4456. readonly animatables: Array<Animatable>;
  4457. /**
  4458. * Instantiates a new Animation Group.
  4459. * This helps managing several animations at once.
  4460. * @see http://doc.babylonjs.com/how_to/group
  4461. * @param name Defines the name of the group
  4462. * @param scene Defines the scene the group belongs to
  4463. */
  4464. constructor(
  4465. /** The name of the animation group */
  4466. name: string, scene?: Nullable<Scene>);
  4467. /**
  4468. * Add an animation (with its target) in the group
  4469. * @param animation defines the animation we want to add
  4470. * @param target defines the target of the animation
  4471. * @returns the {BABYLON.TargetedAnimation} object
  4472. */
  4473. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4474. /**
  4475. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4476. * It can add constant keys at begin or end
  4477. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4478. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4479. * @returns the animation group
  4480. */
  4481. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4482. /**
  4483. * Start all animations on given targets
  4484. * @param loop defines if animations must loop
  4485. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4486. * @param from defines the from key (optional)
  4487. * @param to defines the to key (optional)
  4488. * @returns the current animation group
  4489. */
  4490. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4491. /**
  4492. * Pause all animations
  4493. * @returns the animation group
  4494. */
  4495. pause(): AnimationGroup;
  4496. /**
  4497. * Play all animations to initial state
  4498. * This function will start() the animations if they were not started or will restart() them if they were paused
  4499. * @param loop defines if animations must loop
  4500. * @returns the animation group
  4501. */
  4502. play(loop?: boolean): AnimationGroup;
  4503. /**
  4504. * Reset all animations to initial state
  4505. * @returns the animation group
  4506. */
  4507. reset(): AnimationGroup;
  4508. /**
  4509. * Restart animations from key 0
  4510. * @returns the animation group
  4511. */
  4512. restart(): AnimationGroup;
  4513. /**
  4514. * Stop all animations
  4515. * @returns the animation group
  4516. */
  4517. stop(): AnimationGroup;
  4518. /**
  4519. * Set animation weight for all animatables
  4520. * @param weight defines the weight to use
  4521. * @return the animationGroup
  4522. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4523. */
  4524. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4525. /**
  4526. * Synchronize and normalize all animatables with a source animatable
  4527. * @param root defines the root animatable to synchronize with
  4528. * @return the animationGroup
  4529. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4530. */
  4531. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4532. /**
  4533. * Goes to a specific frame in this animation group
  4534. * @param frame the frame number to go to
  4535. * @return the animationGroup
  4536. */
  4537. goToFrame(frame: number): AnimationGroup;
  4538. /**
  4539. * Dispose all associated resources
  4540. */
  4541. dispose(): void;
  4542. private _checkAnimationGroupEnded;
  4543. /**
  4544. * Returns a new AnimationGroup object parsed from the source provided.
  4545. * @param parsedAnimationGroup defines the source
  4546. * @param scene defines the scene that will receive the animationGroup
  4547. * @returns a new AnimationGroup
  4548. */
  4549. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4550. /**
  4551. * Returns the string "AnimationGroup"
  4552. * @returns "AnimationGroup"
  4553. */
  4554. getClassName(): string;
  4555. /**
  4556. * Creates a detailled string about the object
  4557. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4558. * @returns a string representing the object
  4559. */
  4560. toString(fullDetails?: boolean): string;
  4561. }
  4562. }
  4563. declare module BABYLON {
  4564. /**
  4565. * Class used to override all child animations of a given target
  4566. */
  4567. class AnimationPropertiesOverride {
  4568. /**
  4569. * Gets or sets a value indicating if animation blending must be used
  4570. */
  4571. enableBlending: boolean;
  4572. /**
  4573. * Gets or sets the blending speed to use when enableBlending is true
  4574. */
  4575. blendingSpeed: number;
  4576. /**
  4577. * Gets or sets the default loop mode to use
  4578. */
  4579. loopMode: number;
  4580. }
  4581. }
  4582. declare module BABYLON {
  4583. /**
  4584. * This represents the main contract an easing function should follow.
  4585. * Easing functions are used throughout the animation system.
  4586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4587. */
  4588. interface IEasingFunction {
  4589. /**
  4590. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4591. * of the easing function.
  4592. * The link below provides some of the most common examples of easing functions.
  4593. * @see https://easings.net/
  4594. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4595. * @returns the corresponding value on the curve defined by the easing function
  4596. */
  4597. ease(gradient: number): number;
  4598. }
  4599. /**
  4600. * Base class used for every default easing function.
  4601. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4602. */
  4603. class EasingFunction implements IEasingFunction {
  4604. /**
  4605. * Interpolation follows the mathematical formula associated with the easing function.
  4606. */
  4607. static readonly EASINGMODE_EASEIN: number;
  4608. /**
  4609. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4610. */
  4611. static readonly EASINGMODE_EASEOUT: number;
  4612. /**
  4613. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4614. */
  4615. static readonly EASINGMODE_EASEINOUT: number;
  4616. private _easingMode;
  4617. /**
  4618. * Sets the easing mode of the current function.
  4619. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4620. */
  4621. setEasingMode(easingMode: number): void;
  4622. /**
  4623. * Gets the current easing mode.
  4624. * @returns the easing mode
  4625. */
  4626. getEasingMode(): number;
  4627. /**
  4628. * @hidden
  4629. */
  4630. easeInCore(gradient: number): number;
  4631. /**
  4632. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4633. * of the easing function.
  4634. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4635. * @returns the corresponding value on the curve defined by the easing function
  4636. */
  4637. ease(gradient: number): number;
  4638. }
  4639. /**
  4640. * Easing function with a circle shape (see link below).
  4641. * @see https://easings.net/#easeInCirc
  4642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4643. */
  4644. class CircleEase extends EasingFunction implements IEasingFunction {
  4645. /** @hidden */
  4646. easeInCore(gradient: number): number;
  4647. }
  4648. /**
  4649. * Easing function with a ease back shape (see link below).
  4650. * @see https://easings.net/#easeInBack
  4651. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4652. */
  4653. class BackEase extends EasingFunction implements IEasingFunction {
  4654. /** Defines the amplitude of the function */
  4655. amplitude: number;
  4656. /**
  4657. * Instantiates a back ease easing
  4658. * @see https://easings.net/#easeInBack
  4659. * @param amplitude Defines the amplitude of the function
  4660. */
  4661. constructor(
  4662. /** Defines the amplitude of the function */
  4663. amplitude?: number);
  4664. /** @hidden */
  4665. easeInCore(gradient: number): number;
  4666. }
  4667. /**
  4668. * Easing function with a bouncing shape (see link below).
  4669. * @see https://easings.net/#easeInBounce
  4670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4671. */
  4672. class BounceEase extends EasingFunction implements IEasingFunction {
  4673. /** Defines the number of bounces */
  4674. bounces: number;
  4675. /** Defines the amplitude of the bounce */
  4676. bounciness: number;
  4677. /**
  4678. * Instantiates a bounce easing
  4679. * @see https://easings.net/#easeInBounce
  4680. * @param bounces Defines the number of bounces
  4681. * @param bounciness Defines the amplitude of the bounce
  4682. */
  4683. constructor(
  4684. /** Defines the number of bounces */
  4685. bounces?: number,
  4686. /** Defines the amplitude of the bounce */
  4687. bounciness?: number);
  4688. /** @hidden */
  4689. easeInCore(gradient: number): number;
  4690. }
  4691. /**
  4692. * Easing function with a power of 3 shape (see link below).
  4693. * @see https://easings.net/#easeInCubic
  4694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4695. */
  4696. class CubicEase extends EasingFunction implements IEasingFunction {
  4697. /** @hidden */
  4698. easeInCore(gradient: number): number;
  4699. }
  4700. /**
  4701. * Easing function with an elastic shape (see link below).
  4702. * @see https://easings.net/#easeInElastic
  4703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4704. */
  4705. class ElasticEase extends EasingFunction implements IEasingFunction {
  4706. /** Defines the number of oscillations*/
  4707. oscillations: number;
  4708. /** Defines the amplitude of the oscillations*/
  4709. springiness: number;
  4710. /**
  4711. * Instantiates an elastic easing function
  4712. * @see https://easings.net/#easeInElastic
  4713. * @param oscillations Defines the number of oscillations
  4714. * @param springiness Defines the amplitude of the oscillations
  4715. */
  4716. constructor(
  4717. /** Defines the number of oscillations*/
  4718. oscillations?: number,
  4719. /** Defines the amplitude of the oscillations*/
  4720. springiness?: number);
  4721. /** @hidden */
  4722. easeInCore(gradient: number): number;
  4723. }
  4724. /**
  4725. * Easing function with an exponential shape (see link below).
  4726. * @see https://easings.net/#easeInExpo
  4727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4728. */
  4729. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4730. /** Defines the exponent of the function */
  4731. exponent: number;
  4732. /**
  4733. * Instantiates an exponential easing function
  4734. * @see https://easings.net/#easeInExpo
  4735. * @param exponent Defines the exponent of the function
  4736. */
  4737. constructor(
  4738. /** Defines the exponent of the function */
  4739. exponent?: number);
  4740. /** @hidden */
  4741. easeInCore(gradient: number): number;
  4742. }
  4743. /**
  4744. * Easing function with a power shape (see link below).
  4745. * @see https://easings.net/#easeInQuad
  4746. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4747. */
  4748. class PowerEase extends EasingFunction implements IEasingFunction {
  4749. /** Defines the power of the function */
  4750. power: number;
  4751. /**
  4752. * Instantiates an power base easing function
  4753. * @see https://easings.net/#easeInQuad
  4754. * @param power Defines the power of the function
  4755. */
  4756. constructor(
  4757. /** Defines the power of the function */
  4758. power?: number);
  4759. /** @hidden */
  4760. easeInCore(gradient: number): number;
  4761. }
  4762. /**
  4763. * Easing function with a power of 2 shape (see link below).
  4764. * @see https://easings.net/#easeInQuad
  4765. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4766. */
  4767. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4768. /** @hidden */
  4769. easeInCore(gradient: number): number;
  4770. }
  4771. /**
  4772. * Easing function with a power of 4 shape (see link below).
  4773. * @see https://easings.net/#easeInQuart
  4774. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4775. */
  4776. class QuarticEase extends EasingFunction implements IEasingFunction {
  4777. /** @hidden */
  4778. easeInCore(gradient: number): number;
  4779. }
  4780. /**
  4781. * Easing function with a power of 5 shape (see link below).
  4782. * @see https://easings.net/#easeInQuint
  4783. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4784. */
  4785. class QuinticEase extends EasingFunction implements IEasingFunction {
  4786. /** @hidden */
  4787. easeInCore(gradient: number): number;
  4788. }
  4789. /**
  4790. * Easing function with a sin shape (see link below).
  4791. * @see https://easings.net/#easeInSine
  4792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4793. */
  4794. class SineEase extends EasingFunction implements IEasingFunction {
  4795. /** @hidden */
  4796. easeInCore(gradient: number): number;
  4797. }
  4798. /**
  4799. * Easing function with a bezier shape (see link below).
  4800. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4801. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4802. */
  4803. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4804. /** Defines the x component of the start tangent in the bezier curve */
  4805. x1: number;
  4806. /** Defines the y component of the start tangent in the bezier curve */
  4807. y1: number;
  4808. /** Defines the x component of the end tangent in the bezier curve */
  4809. x2: number;
  4810. /** Defines the y component of the end tangent in the bezier curve */
  4811. y2: number;
  4812. /**
  4813. * Instantiates a bezier function
  4814. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4815. * @param x1 Defines the x component of the start tangent in the bezier curve
  4816. * @param y1 Defines the y component of the start tangent in the bezier curve
  4817. * @param x2 Defines the x component of the end tangent in the bezier curve
  4818. * @param y2 Defines the y component of the end tangent in the bezier curve
  4819. */
  4820. constructor(
  4821. /** Defines the x component of the start tangent in the bezier curve */
  4822. x1?: number,
  4823. /** Defines the y component of the start tangent in the bezier curve */
  4824. y1?: number,
  4825. /** Defines the x component of the end tangent in the bezier curve */
  4826. x2?: number,
  4827. /** Defines the y component of the end tangent in the bezier curve */
  4828. y2?: number);
  4829. /** @hidden */
  4830. easeInCore(gradient: number): number;
  4831. }
  4832. }
  4833. declare module BABYLON {
  4834. /**
  4835. * Defines a runtime animation
  4836. */
  4837. class RuntimeAnimation {
  4838. private _events;
  4839. /**
  4840. * The current frame of the runtime animation
  4841. */
  4842. private _currentFrame;
  4843. /**
  4844. * The animation used by the runtime animation
  4845. */
  4846. private _animation;
  4847. /**
  4848. * The target of the runtime animation
  4849. */
  4850. private _target;
  4851. /**
  4852. * The initiating animatable
  4853. */
  4854. private _host;
  4855. /**
  4856. * The original value of the runtime animation
  4857. */
  4858. private _originalValue;
  4859. /**
  4860. * The original blend value of the runtime animation
  4861. */
  4862. private _originalBlendValue;
  4863. /**
  4864. * The offsets cache of the runtime animation
  4865. */
  4866. private _offsetsCache;
  4867. /**
  4868. * The high limits cache of the runtime animation
  4869. */
  4870. private _highLimitsCache;
  4871. /**
  4872. * Specifies if the runtime animation has been stopped
  4873. */
  4874. private _stopped;
  4875. /**
  4876. * The blending factor of the runtime animation
  4877. */
  4878. private _blendingFactor;
  4879. /**
  4880. * The BabylonJS scene
  4881. */
  4882. private _scene;
  4883. /**
  4884. * The current value of the runtime animation
  4885. */
  4886. private _currentValue;
  4887. /** @hidden */
  4888. _workValue: any;
  4889. /**
  4890. * The active target of the runtime animation
  4891. */
  4892. private _activeTarget;
  4893. /**
  4894. * The target path of the runtime animation
  4895. */
  4896. private _targetPath;
  4897. /**
  4898. * The weight of the runtime animation
  4899. */
  4900. private _weight;
  4901. /**
  4902. * The ratio offset of the runtime animation
  4903. */
  4904. private _ratioOffset;
  4905. /**
  4906. * The previous delay of the runtime animation
  4907. */
  4908. private _previousDelay;
  4909. /**
  4910. * The previous ratio of the runtime animation
  4911. */
  4912. private _previousRatio;
  4913. /**
  4914. * Gets the current frame of the runtime animation
  4915. */
  4916. readonly currentFrame: number;
  4917. /**
  4918. * Gets the weight of the runtime animation
  4919. */
  4920. readonly weight: number;
  4921. /**
  4922. * Gets the current value of the runtime animation
  4923. */
  4924. readonly currentValue: any;
  4925. /**
  4926. * Gets the target path of the runtime animation
  4927. */
  4928. readonly targetPath: string;
  4929. /**
  4930. * Gets the actual target of the runtime animation
  4931. */
  4932. readonly target: any;
  4933. /**
  4934. * Create a new RuntimeAnimation object
  4935. * @param target defines the target of the animation
  4936. * @param animation defines the source animation object
  4937. * @param scene defines the hosting scene
  4938. * @param host defines the initiating Animatable
  4939. */
  4940. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4941. /**
  4942. * Gets the animation from the runtime animation
  4943. */
  4944. readonly animation: Animation;
  4945. /**
  4946. * Resets the runtime animation to the beginning
  4947. * @param restoreOriginal defines whether to restore the target property to the original value
  4948. */
  4949. reset(restoreOriginal?: boolean): void;
  4950. /**
  4951. * Specifies if the runtime animation is stopped
  4952. * @returns Boolean specifying if the runtime animation is stopped
  4953. */
  4954. isStopped(): boolean;
  4955. /**
  4956. * Disposes of the runtime animation
  4957. */
  4958. dispose(): void;
  4959. /**
  4960. * Interpolates the animation from the current frame
  4961. * @param currentFrame The frame to interpolate the animation to
  4962. * @param repeatCount The number of times that the animation should loop
  4963. * @param loopMode The type of looping mode to use
  4964. * @param offsetValue Animation offset value
  4965. * @param highLimitValue The high limit value
  4966. * @returns The interpolated value
  4967. */
  4968. private _interpolate;
  4969. /**
  4970. * Apply the interpolated value to the target
  4971. * @param currentValue defines the value computed by the animation
  4972. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4973. */
  4974. setValue(currentValue: any, weight?: number): void;
  4975. private _setValue;
  4976. /**
  4977. * Gets the loop pmode of the runtime animation
  4978. * @returns Loop Mode
  4979. */
  4980. private _getCorrectLoopMode;
  4981. /**
  4982. * Move the current animation to a given frame
  4983. * @param frame defines the frame to move to
  4984. */
  4985. goToFrame(frame: number): void;
  4986. /**
  4987. * @hidden Internal use only
  4988. */
  4989. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4990. /**
  4991. * Execute the current animation
  4992. * @param delay defines the delay to add to the current frame
  4993. * @param from defines the lower bound of the animation range
  4994. * @param to defines the upper bound of the animation range
  4995. * @param loop defines if the current animation must loop
  4996. * @param speedRatio defines the current speed ratio
  4997. * @param weight defines the weight of the animation (default is -1 so no weight)
  4998. * @returns a boolean indicating if the animation is running
  4999. */
  5000. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5001. }
  5002. }
  5003. declare module BABYLON {
  5004. /**
  5005. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5006. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5007. */
  5008. class Analyser {
  5009. /**
  5010. * Gets or sets the smoothing
  5011. * @ignorenaming
  5012. */
  5013. SMOOTHING: number;
  5014. /**
  5015. * Gets or sets the FFT table size
  5016. * @ignorenaming
  5017. */
  5018. FFT_SIZE: number;
  5019. /**
  5020. * Gets or sets the bar graph amplitude
  5021. * @ignorenaming
  5022. */
  5023. BARGRAPHAMPLITUDE: number;
  5024. /**
  5025. * Gets or sets the position of the debug canvas
  5026. * @ignorenaming
  5027. */
  5028. DEBUGCANVASPOS: {
  5029. x: number;
  5030. y: number;
  5031. };
  5032. /**
  5033. * Gets or sets the debug canvas size
  5034. * @ignorenaming
  5035. */
  5036. DEBUGCANVASSIZE: {
  5037. width: number;
  5038. height: number;
  5039. };
  5040. private _byteFreqs;
  5041. private _byteTime;
  5042. private _floatFreqs;
  5043. private _webAudioAnalyser;
  5044. private _debugCanvas;
  5045. private _debugCanvasContext;
  5046. private _scene;
  5047. private _registerFunc;
  5048. private _audioEngine;
  5049. /**
  5050. * Creates a new analyser
  5051. * @param scene defines hosting scene
  5052. */
  5053. constructor(scene: Scene);
  5054. /**
  5055. * Get the number of data values you will have to play with for the visualization
  5056. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5057. * @returns a number
  5058. */
  5059. getFrequencyBinCount(): number;
  5060. /**
  5061. * Gets the current frequency data as a byte array
  5062. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5063. * @returns a Uint8Array
  5064. */
  5065. getByteFrequencyData(): Uint8Array;
  5066. /**
  5067. * Gets the current waveform as a byte array
  5068. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5069. * @returns a Uint8Array
  5070. */
  5071. getByteTimeDomainData(): Uint8Array;
  5072. /**
  5073. * Gets the current frequency data as a float array
  5074. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5075. * @returns a Float32Array
  5076. */
  5077. getFloatFrequencyData(): Float32Array;
  5078. /**
  5079. * Renders the debug canvas
  5080. */
  5081. drawDebugCanvas(): void;
  5082. /**
  5083. * Stops rendering the debug canvas and removes it
  5084. */
  5085. stopDebugCanvas(): void;
  5086. /**
  5087. * Connects two audio nodes
  5088. * @param inputAudioNode defines first node to connect
  5089. * @param outputAudioNode defines second node to connect
  5090. */
  5091. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5092. /**
  5093. * Releases all associated resources
  5094. */
  5095. dispose(): void;
  5096. }
  5097. }
  5098. declare module BABYLON {
  5099. /**
  5100. * This represents an audio engine and it is responsible
  5101. * to play, synchronize and analyse sounds throughout the application.
  5102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5103. */
  5104. interface IAudioEngine extends IDisposable {
  5105. /**
  5106. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5107. */
  5108. readonly canUseWebAudio: boolean;
  5109. /**
  5110. * Gets the current AudioContext if available.
  5111. */
  5112. readonly audioContext: Nullable<AudioContext>;
  5113. /**
  5114. * The master gain node defines the global audio volume of your audio engine.
  5115. */
  5116. readonly masterGain: GainNode;
  5117. /**
  5118. * Gets whether or not mp3 are supported by your browser.
  5119. */
  5120. readonly isMP3supported: boolean;
  5121. /**
  5122. * Gets whether or not ogg are supported by your browser.
  5123. */
  5124. readonly isOGGsupported: boolean;
  5125. /**
  5126. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5127. * @ignoreNaming
  5128. */
  5129. WarnedWebAudioUnsupported: boolean;
  5130. /**
  5131. * Defines if the audio engine relies on a custom unlocked button.
  5132. * In this case, the embedded button will not be displayed.
  5133. */
  5134. useCustomUnlockedButton: boolean;
  5135. /**
  5136. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5137. */
  5138. readonly unlocked: boolean;
  5139. /**
  5140. * Event raised when audio has been unlocked on the browser.
  5141. */
  5142. onAudioUnlockedObservable: Observable<AudioEngine>;
  5143. /**
  5144. * Event raised when audio has been locked on the browser.
  5145. */
  5146. onAudioLockedObservable: Observable<AudioEngine>;
  5147. /**
  5148. * Flags the audio engine in Locked state.
  5149. * This happens due to new browser policies preventing audio to autoplay.
  5150. */
  5151. lock(): void;
  5152. /**
  5153. * Unlocks the audio engine once a user action has been done on the dom.
  5154. * This is helpful to resume play once browser policies have been satisfied.
  5155. */
  5156. unlock(): void;
  5157. }
  5158. /**
  5159. * This represents the default audio engine used in babylon.
  5160. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5162. */
  5163. class AudioEngine implements IAudioEngine {
  5164. private _audioContext;
  5165. private _audioContextInitialized;
  5166. private _muteButton;
  5167. private _engine;
  5168. /**
  5169. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5170. */
  5171. canUseWebAudio: boolean;
  5172. /**
  5173. * The master gain node defines the global audio volume of your audio engine.
  5174. */
  5175. masterGain: GainNode;
  5176. /**
  5177. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5178. * @ignoreNaming
  5179. */
  5180. WarnedWebAudioUnsupported: boolean;
  5181. /**
  5182. * Gets whether or not mp3 are supported by your browser.
  5183. */
  5184. isMP3supported: boolean;
  5185. /**
  5186. * Gets whether or not ogg are supported by your browser.
  5187. */
  5188. isOGGsupported: boolean;
  5189. private _canvas;
  5190. /**
  5191. * Gets whether audio has been unlocked on the device.
  5192. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5193. * a user interaction has happened.
  5194. */
  5195. unlocked: boolean;
  5196. /**
  5197. * Defines if the audio engine relies on a custom unlocked button.
  5198. * In this case, the embedded button will not be displayed.
  5199. */
  5200. useCustomUnlockedButton: boolean;
  5201. /**
  5202. * Event raised when audio has been unlocked on the browser.
  5203. */
  5204. onAudioUnlockedObservable: Observable<AudioEngine>;
  5205. /**
  5206. * Event raised when audio has been locked on the browser.
  5207. */
  5208. onAudioLockedObservable: Observable<AudioEngine>;
  5209. /**
  5210. * Gets the current AudioContext if available.
  5211. */
  5212. readonly audioContext: Nullable<AudioContext>;
  5213. private _connectedAnalyser;
  5214. /**
  5215. * Instantiates a new audio engine.
  5216. *
  5217. * There should be only one per page as some browsers restrict the number
  5218. * of audio contexts you can create.
  5219. * @param engine defines the hosting engine
  5220. */
  5221. constructor(engine?: Nullable<Engine>);
  5222. /**
  5223. * Flags the audio engine in Locked state.
  5224. * This happens due to new browser policies preventing audio to autoplay.
  5225. */
  5226. lock(): void;
  5227. /**
  5228. * Unlocks the audio engine once a user action has been done on the dom.
  5229. * This is helpful to resume play once browser policies have been satisfied.
  5230. */
  5231. unlock(): void;
  5232. private _resumeAudioContext;
  5233. private _initializeAudioContext;
  5234. private _tryToRun;
  5235. private _triggerRunningState;
  5236. private _triggerSuspendedState;
  5237. private _displayMuteButton;
  5238. private _moveButtonToTopLeft;
  5239. private _onResize;
  5240. private _hideMuteButton;
  5241. /**
  5242. * Destroy and release the resources associated with the audio ccontext.
  5243. */
  5244. dispose(): void;
  5245. /**
  5246. * Gets the global volume sets on the master gain.
  5247. * @returns the global volume if set or -1 otherwise
  5248. */
  5249. getGlobalVolume(): number;
  5250. /**
  5251. * Sets the global volume of your experience (sets on the master gain).
  5252. * @param newVolume Defines the new global volume of the application
  5253. */
  5254. setGlobalVolume(newVolume: number): void;
  5255. /**
  5256. * Connect the audio engine to an audio analyser allowing some amazing
  5257. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5259. * @param analyser The analyser to connect to the engine
  5260. */
  5261. connectToAnalyser(analyser: Analyser): void;
  5262. }
  5263. }
  5264. declare module BABYLON {
  5265. interface AbstractScene {
  5266. /**
  5267. * The list of sounds used in the scene.
  5268. */
  5269. sounds: Nullable<Array<Sound>>;
  5270. }
  5271. interface Scene {
  5272. /**
  5273. * @hidden
  5274. * Backing field
  5275. */
  5276. _mainSoundTrack: SoundTrack;
  5277. /**
  5278. * The main sound track played by the scene.
  5279. * It cotains your primary collection of sounds.
  5280. */
  5281. mainSoundTrack: SoundTrack;
  5282. /**
  5283. * The list of sound tracks added to the scene
  5284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5285. */
  5286. soundTracks: Nullable<Array<SoundTrack>>;
  5287. /**
  5288. * Gets a sound using a given name
  5289. * @param name defines the name to search for
  5290. * @return the found sound or null if not found at all.
  5291. */
  5292. getSoundByName(name: string): Nullable<Sound>;
  5293. /**
  5294. * Gets or sets if audio support is enabled
  5295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5296. */
  5297. audioEnabled: boolean;
  5298. /**
  5299. * Gets or sets if audio will be output to headphones
  5300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5301. */
  5302. headphone: boolean;
  5303. }
  5304. /**
  5305. * Defines the sound scene component responsible to manage any sounds
  5306. * in a given scene.
  5307. */
  5308. class AudioSceneComponent implements ISceneSerializableComponent {
  5309. /**
  5310. * The component name helpfull to identify the component in the list of scene components.
  5311. */
  5312. readonly name: string;
  5313. /**
  5314. * The scene the component belongs to.
  5315. */
  5316. scene: Scene;
  5317. private _audioEnabled;
  5318. /**
  5319. * Gets whether audio is enabled or not.
  5320. * Please use related enable/disable method to switch state.
  5321. */
  5322. readonly audioEnabled: boolean;
  5323. private _headphone;
  5324. /**
  5325. * Gets whether audio is outputing to headphone or not.
  5326. * Please use the according Switch methods to change output.
  5327. */
  5328. readonly headphone: boolean;
  5329. /**
  5330. * Creates a new instance of the component for the given scene
  5331. * @param scene Defines the scene to register the component in
  5332. */
  5333. constructor(scene: Scene);
  5334. /**
  5335. * Registers the component in a given scene
  5336. */
  5337. register(): void;
  5338. /**
  5339. * Rebuilds the elements related to this component in case of
  5340. * context lost for instance.
  5341. */
  5342. rebuild(): void;
  5343. /**
  5344. * Serializes the component data to the specified json object
  5345. * @param serializationObject The object to serialize to
  5346. */
  5347. serialize(serializationObject: any): void;
  5348. /**
  5349. * Adds all the element from the container to the scene
  5350. * @param container the container holding the elements
  5351. */
  5352. addFromContainer(container: AbstractScene): void;
  5353. /**
  5354. * Removes all the elements in the container from the scene
  5355. * @param container contains the elements to remove
  5356. */
  5357. removeFromContainer(container: AbstractScene): void;
  5358. /**
  5359. * Disposes the component and the associated ressources.
  5360. */
  5361. dispose(): void;
  5362. /**
  5363. * Disables audio in the associated scene.
  5364. */
  5365. disableAudio(): void;
  5366. /**
  5367. * Enables audio in the associated scene.
  5368. */
  5369. enableAudio(): void;
  5370. /**
  5371. * Switch audio to headphone output.
  5372. */
  5373. switchAudioModeForHeadphones(): void;
  5374. /**
  5375. * Switch audio to normal speakers.
  5376. */
  5377. switchAudioModeForNormalSpeakers(): void;
  5378. private _afterRender;
  5379. }
  5380. }
  5381. declare module BABYLON {
  5382. /**
  5383. * Defines a sound that can be played in the application.
  5384. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5386. */
  5387. class Sound {
  5388. /**
  5389. * The name of the sound in the scene.
  5390. */
  5391. name: string;
  5392. /**
  5393. * Does the sound autoplay once loaded.
  5394. */
  5395. autoplay: boolean;
  5396. /**
  5397. * Does the sound loop after it finishes playing once.
  5398. */
  5399. loop: boolean;
  5400. /**
  5401. * Does the sound use a custom attenuation curve to simulate the falloff
  5402. * happening when the source gets further away from the camera.
  5403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5404. */
  5405. useCustomAttenuation: boolean;
  5406. /**
  5407. * The sound track id this sound belongs to.
  5408. */
  5409. soundTrackId: number;
  5410. /**
  5411. * Is this sound currently played.
  5412. */
  5413. isPlaying: boolean;
  5414. /**
  5415. * Is this sound currently paused.
  5416. */
  5417. isPaused: boolean;
  5418. /**
  5419. * Does this sound enables spatial sound.
  5420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5421. */
  5422. spatialSound: boolean;
  5423. /**
  5424. * Define the reference distance the sound should be heard perfectly.
  5425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5426. */
  5427. refDistance: number;
  5428. /**
  5429. * Define the roll off factor of spatial sounds.
  5430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5431. */
  5432. rolloffFactor: number;
  5433. /**
  5434. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5436. */
  5437. maxDistance: number;
  5438. /**
  5439. * Define the distance attenuation model the sound will follow.
  5440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5441. */
  5442. distanceModel: string;
  5443. /**
  5444. * @hidden
  5445. * Back Compat
  5446. **/
  5447. onended: () => any;
  5448. /**
  5449. * Observable event when the current playing sound finishes.
  5450. */
  5451. onEndedObservable: Observable<Sound>;
  5452. private _panningModel;
  5453. private _playbackRate;
  5454. private _streaming;
  5455. private _startTime;
  5456. private _startOffset;
  5457. private _position;
  5458. /** @hidden */
  5459. _positionInEmitterSpace: boolean;
  5460. private _localDirection;
  5461. private _volume;
  5462. private _isReadyToPlay;
  5463. private _isDirectional;
  5464. private _readyToPlayCallback;
  5465. private _audioBuffer;
  5466. private _soundSource;
  5467. private _streamingSource;
  5468. private _soundPanner;
  5469. private _soundGain;
  5470. private _inputAudioNode;
  5471. private _outputAudioNode;
  5472. private _coneInnerAngle;
  5473. private _coneOuterAngle;
  5474. private _coneOuterGain;
  5475. private _scene;
  5476. private _connectedMesh;
  5477. private _customAttenuationFunction;
  5478. private _registerFunc;
  5479. private _isOutputConnected;
  5480. private _htmlAudioElement;
  5481. private _urlType;
  5482. /**
  5483. * Create a sound and attach it to a scene
  5484. * @param name Name of your sound
  5485. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5486. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5487. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5488. */
  5489. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5490. /**
  5491. * Release the sound and its associated resources
  5492. */
  5493. dispose(): void;
  5494. /**
  5495. * Gets if the sounds is ready to be played or not.
  5496. * @returns true if ready, otherwise false
  5497. */
  5498. isReady(): boolean;
  5499. private _soundLoaded;
  5500. /**
  5501. * Sets the data of the sound from an audiobuffer
  5502. * @param audioBuffer The audioBuffer containing the data
  5503. */
  5504. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5505. /**
  5506. * Updates the current sounds options such as maxdistance, loop...
  5507. * @param options A JSON object containing values named as the object properties
  5508. */
  5509. updateOptions(options: any): void;
  5510. private _createSpatialParameters;
  5511. private _updateSpatialParameters;
  5512. /**
  5513. * Switch the panning model to HRTF:
  5514. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5516. */
  5517. switchPanningModelToHRTF(): void;
  5518. /**
  5519. * Switch the panning model to Equal Power:
  5520. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5522. */
  5523. switchPanningModelToEqualPower(): void;
  5524. private _switchPanningModel;
  5525. /**
  5526. * Connect this sound to a sound track audio node like gain...
  5527. * @param soundTrackAudioNode the sound track audio node to connect to
  5528. */
  5529. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5530. /**
  5531. * Transform this sound into a directional source
  5532. * @param coneInnerAngle Size of the inner cone in degree
  5533. * @param coneOuterAngle Size of the outer cone in degree
  5534. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5535. */
  5536. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5537. /**
  5538. * Gets or sets the inner angle for the directional cone.
  5539. */
  5540. /**
  5541. * Gets or sets the inner angle for the directional cone.
  5542. */
  5543. directionalConeInnerAngle: number;
  5544. /**
  5545. * Gets or sets the outer angle for the directional cone.
  5546. */
  5547. /**
  5548. * Gets or sets the outer angle for the directional cone.
  5549. */
  5550. directionalConeOuterAngle: number;
  5551. /**
  5552. * Sets the position of the emitter if spatial sound is enabled
  5553. * @param newPosition Defines the new posisiton
  5554. */
  5555. setPosition(newPosition: Vector3): void;
  5556. /**
  5557. * Sets the local direction of the emitter if spatial sound is enabled
  5558. * @param newLocalDirection Defines the new local direction
  5559. */
  5560. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5561. private _updateDirection;
  5562. /** @hidden */
  5563. updateDistanceFromListener(): void;
  5564. /**
  5565. * Sets a new custom attenuation function for the sound.
  5566. * @param callback Defines the function used for the attenuation
  5567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5568. */
  5569. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5570. /**
  5571. * Play the sound
  5572. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5573. * @param offset (optional) Start the sound setting it at a specific time
  5574. */
  5575. play(time?: number, offset?: number): void;
  5576. private _onended;
  5577. /**
  5578. * Stop the sound
  5579. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5580. */
  5581. stop(time?: number): void;
  5582. /**
  5583. * Put the sound in pause
  5584. */
  5585. pause(): void;
  5586. /**
  5587. * Sets a dedicated volume for this sounds
  5588. * @param newVolume Define the new volume of the sound
  5589. * @param time Define in how long the sound should be at this value
  5590. */
  5591. setVolume(newVolume: number, time?: number): void;
  5592. /**
  5593. * Set the sound play back rate
  5594. * @param newPlaybackRate Define the playback rate the sound should be played at
  5595. */
  5596. setPlaybackRate(newPlaybackRate: number): void;
  5597. /**
  5598. * Gets the volume of the sound.
  5599. * @returns the volume of the sound
  5600. */
  5601. getVolume(): number;
  5602. /**
  5603. * Attach the sound to a dedicated mesh
  5604. * @param meshToConnectTo The mesh to connect the sound with
  5605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5606. */
  5607. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5608. /**
  5609. * Detach the sound from the previously attached mesh
  5610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5611. */
  5612. detachFromMesh(): void;
  5613. private _onRegisterAfterWorldMatrixUpdate;
  5614. /**
  5615. * Clone the current sound in the scene.
  5616. * @returns the new sound clone
  5617. */
  5618. clone(): Nullable<Sound>;
  5619. /**
  5620. * Gets the current underlying audio buffer containing the data
  5621. * @returns the audio buffer
  5622. */
  5623. getAudioBuffer(): Nullable<AudioBuffer>;
  5624. /**
  5625. * Serializes the Sound in a JSON representation
  5626. * @returns the JSON representation of the sound
  5627. */
  5628. serialize(): any;
  5629. /**
  5630. * Parse a JSON representation of a sound to innstantiate in a given scene
  5631. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5632. * @param scene Define the scene the new parsed sound should be created in
  5633. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5634. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5635. * @returns the newly parsed sound
  5636. */
  5637. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5638. }
  5639. }
  5640. declare module BABYLON {
  5641. /**
  5642. * Options allowed during the creation of a sound track.
  5643. */
  5644. interface ISoundTrackOptions {
  5645. /**
  5646. * The volume the sound track should take during creation
  5647. */
  5648. volume?: number;
  5649. /**
  5650. * Define if the sound track is the main sound track of the scene
  5651. */
  5652. mainTrack?: boolean;
  5653. }
  5654. /**
  5655. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5656. * It will be also used in a future release to apply effects on a specific track.
  5657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5658. */
  5659. class SoundTrack {
  5660. /**
  5661. * The unique identifier of the sound track in the scene.
  5662. */
  5663. id: number;
  5664. /**
  5665. * The list of sounds included in the sound track.
  5666. */
  5667. soundCollection: Array<Sound>;
  5668. private _outputAudioNode;
  5669. private _scene;
  5670. private _isMainTrack;
  5671. private _connectedAnalyser;
  5672. private _options;
  5673. private _isInitialized;
  5674. /**
  5675. * Creates a new sound track.
  5676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5677. * @param scene Define the scene the sound track belongs to
  5678. * @param options
  5679. */
  5680. constructor(scene: Scene, options?: ISoundTrackOptions);
  5681. private _initializeSoundTrackAudioGraph;
  5682. /**
  5683. * Release the sound track and its associated resources
  5684. */
  5685. dispose(): void;
  5686. /**
  5687. * Adds a sound to this sound track
  5688. * @param sound define the cound to add
  5689. * @ignoreNaming
  5690. */
  5691. AddSound(sound: Sound): void;
  5692. /**
  5693. * Removes a sound to this sound track
  5694. * @param sound define the cound to remove
  5695. * @ignoreNaming
  5696. */
  5697. RemoveSound(sound: Sound): void;
  5698. /**
  5699. * Set a global volume for the full sound track.
  5700. * @param newVolume Define the new volume of the sound track
  5701. */
  5702. setVolume(newVolume: number): void;
  5703. /**
  5704. * Switch the panning model to HRTF:
  5705. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5707. */
  5708. switchPanningModelToHRTF(): void;
  5709. /**
  5710. * Switch the panning model to Equal Power:
  5711. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5713. */
  5714. switchPanningModelToEqualPower(): void;
  5715. /**
  5716. * Connect the sound track to an audio analyser allowing some amazing
  5717. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5719. * @param analyser The analyser to connect to the engine
  5720. */
  5721. connectToAnalyser(analyser: Analyser): void;
  5722. }
  5723. }
  5724. declare module BABYLON {
  5725. /**
  5726. * Wraps one or more Sound objects and selects one with random weight for playback.
  5727. */
  5728. class WeightedSound {
  5729. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5730. loop: boolean;
  5731. private _coneInnerAngle;
  5732. private _coneOuterAngle;
  5733. private _volume;
  5734. /** A Sound is currently playing. */
  5735. isPlaying: boolean;
  5736. /** A Sound is currently paused. */
  5737. isPaused: boolean;
  5738. private _sounds;
  5739. private _weights;
  5740. private _currentIndex?;
  5741. /**
  5742. * Creates a new WeightedSound from the list of sounds given.
  5743. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5744. * @param sounds Array of Sounds that will be selected from.
  5745. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5746. */
  5747. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5748. /**
  5749. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5750. */
  5751. /**
  5752. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5753. */
  5754. directionalConeInnerAngle: number;
  5755. /**
  5756. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5757. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5758. */
  5759. /**
  5760. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5761. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5762. */
  5763. directionalConeOuterAngle: number;
  5764. /**
  5765. * Playback volume.
  5766. */
  5767. /**
  5768. * Playback volume.
  5769. */
  5770. volume: number;
  5771. private _onended;
  5772. /**
  5773. * Suspend playback
  5774. */
  5775. pause(): void;
  5776. /**
  5777. * Stop playback
  5778. */
  5779. stop(): void;
  5780. /**
  5781. * Start playback.
  5782. * @param startOffset Position the clip head at a specific time in seconds.
  5783. */
  5784. play(startOffset?: number): void;
  5785. }
  5786. }
  5787. declare module BABYLON {
  5788. /**
  5789. * Interface used to define a behavior
  5790. */
  5791. interface Behavior<T> {
  5792. /** gets or sets behavior's name */
  5793. name: string;
  5794. /**
  5795. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5796. */
  5797. init(): void;
  5798. /**
  5799. * Called when the behavior is attached to a target
  5800. * @param target defines the target where the behavior is attached to
  5801. */
  5802. attach(target: T): void;
  5803. /**
  5804. * Called when the behavior is detached from its target
  5805. */
  5806. detach(): void;
  5807. }
  5808. /**
  5809. * Interface implemented by classes supporting behaviors
  5810. */
  5811. interface IBehaviorAware<T> {
  5812. /**
  5813. * Attach a behavior
  5814. * @param behavior defines the behavior to attach
  5815. * @returns the current host
  5816. */
  5817. addBehavior(behavior: Behavior<T>): T;
  5818. /**
  5819. * Remove a behavior from the current object
  5820. * @param behavior defines the behavior to detach
  5821. * @returns the current host
  5822. */
  5823. removeBehavior(behavior: Behavior<T>): T;
  5824. /**
  5825. * Gets a behavior using its name to search
  5826. * @param name defines the name to search
  5827. * @returns the behavior or null if not found
  5828. */
  5829. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5830. }
  5831. }
  5832. declare module BABYLON {
  5833. /**
  5834. * Class used to store bone information
  5835. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5836. */
  5837. class Bone extends Node {
  5838. /**
  5839. * defines the bone name
  5840. */
  5841. name: string;
  5842. private static _tmpVecs;
  5843. private static _tmpQuat;
  5844. private static _tmpMats;
  5845. /**
  5846. * Gets the list of child bones
  5847. */
  5848. children: Bone[];
  5849. /** Gets the animations associated with this bone */
  5850. animations: Animation[];
  5851. /**
  5852. * Gets or sets bone length
  5853. */
  5854. length: number;
  5855. /**
  5856. * @hidden Internal only
  5857. * Set this value to map this bone to a different index in the transform matrices
  5858. * Set this value to -1 to exclude the bone from the transform matrices
  5859. */
  5860. _index: Nullable<number>;
  5861. private _skeleton;
  5862. private _localMatrix;
  5863. private _restPose;
  5864. private _baseMatrix;
  5865. private _absoluteTransform;
  5866. private _invertedAbsoluteTransform;
  5867. private _parent;
  5868. private _scalingDeterminant;
  5869. private _worldTransform;
  5870. private _localScaling;
  5871. private _localRotation;
  5872. private _localPosition;
  5873. private _needToDecompose;
  5874. private _needToCompose;
  5875. /** @hidden */
  5876. /** @hidden */
  5877. _matrix: Matrix;
  5878. /**
  5879. * Create a new bone
  5880. * @param name defines the bone name
  5881. * @param skeleton defines the parent skeleton
  5882. * @param parentBone defines the parent (can be null if the bone is the root)
  5883. * @param localMatrix defines the local matrix
  5884. * @param restPose defines the rest pose matrix
  5885. * @param baseMatrix defines the base matrix
  5886. * @param index defines index of the bone in the hiearchy
  5887. */
  5888. constructor(
  5889. /**
  5890. * defines the bone name
  5891. */
  5892. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5893. /**
  5894. * Gets the parent skeleton
  5895. * @returns a skeleton
  5896. */
  5897. getSkeleton(): Skeleton;
  5898. /**
  5899. * Gets parent bone
  5900. * @returns a bone or null if the bone is the root of the bone hierarchy
  5901. */
  5902. getParent(): Nullable<Bone>;
  5903. /**
  5904. * Sets the parent bone
  5905. * @param parent defines the parent (can be null if the bone is the root)
  5906. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5907. */
  5908. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5909. /**
  5910. * Gets the local matrix
  5911. * @returns a matrix
  5912. */
  5913. getLocalMatrix(): Matrix;
  5914. /**
  5915. * Gets the base matrix (initial matrix which remains unchanged)
  5916. * @returns a matrix
  5917. */
  5918. getBaseMatrix(): Matrix;
  5919. /**
  5920. * Gets the rest pose matrix
  5921. * @returns a matrix
  5922. */
  5923. getRestPose(): Matrix;
  5924. /**
  5925. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5926. */
  5927. getWorldMatrix(): Matrix;
  5928. /**
  5929. * Sets the local matrix to rest pose matrix
  5930. */
  5931. returnToRest(): void;
  5932. /**
  5933. * Gets the inverse of the absolute transform matrix.
  5934. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5935. * @returns a matrix
  5936. */
  5937. getInvertedAbsoluteTransform(): Matrix;
  5938. /**
  5939. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5940. * @returns a matrix
  5941. */
  5942. getAbsoluteTransform(): Matrix;
  5943. /** Gets or sets current position (in local space) */
  5944. position: Vector3;
  5945. /** Gets or sets current rotation (in local space) */
  5946. rotation: Vector3;
  5947. /** Gets or sets current rotation quaternion (in local space) */
  5948. rotationQuaternion: Quaternion;
  5949. /** Gets or sets current scaling (in local space) */
  5950. scaling: Vector3;
  5951. /**
  5952. * Gets the animation properties override
  5953. */
  5954. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5955. private _decompose;
  5956. private _compose;
  5957. /**
  5958. * Update the base and local matrices
  5959. * @param matrix defines the new base or local matrix
  5960. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5961. * @param updateLocalMatrix defines if the local matrix should be updated
  5962. */
  5963. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  5964. /** @hidden */
  5965. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  5966. /**
  5967. * Flag the bone as dirty (Forcing it to update everything)
  5968. */
  5969. markAsDirty(): void;
  5970. private _markAsDirtyAndCompose;
  5971. private _markAsDirtyAndDecompose;
  5972. /**
  5973. * Copy an animation range from another bone
  5974. * @param source defines the source bone
  5975. * @param rangeName defines the range name to copy
  5976. * @param frameOffset defines the frame offset
  5977. * @param rescaleAsRequired defines if rescaling must be applied if required
  5978. * @param skelDimensionsRatio defines the scaling ratio
  5979. * @returns true if operation was successful
  5980. */
  5981. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  5982. /**
  5983. * Translate the bone in local or world space
  5984. * @param vec The amount to translate the bone
  5985. * @param space The space that the translation is in
  5986. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5987. */
  5988. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5989. /**
  5990. * Set the postion of the bone in local or world space
  5991. * @param position The position to set the bone
  5992. * @param space The space that the position is in
  5993. * @param mesh The mesh that this bone is attached to. This is only used in world space
  5994. */
  5995. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  5996. /**
  5997. * Set the absolute position of the bone (world space)
  5998. * @param position The position to set the bone
  5999. * @param mesh The mesh that this bone is attached to
  6000. */
  6001. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6002. /**
  6003. * Scale the bone on the x, y and z axes (in local space)
  6004. * @param x The amount to scale the bone on the x axis
  6005. * @param y The amount to scale the bone on the y axis
  6006. * @param z The amount to scale the bone on the z axis
  6007. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6008. */
  6009. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6010. /**
  6011. * Set the bone scaling in local space
  6012. * @param scale defines the scaling vector
  6013. */
  6014. setScale(scale: Vector3): void;
  6015. /**
  6016. * Gets the current scaling in local space
  6017. * @returns the current scaling vector
  6018. */
  6019. getScale(): Vector3;
  6020. /**
  6021. * Gets the current scaling in local space and stores it in a target vector
  6022. * @param result defines the target vector
  6023. */
  6024. getScaleToRef(result: Vector3): void;
  6025. /**
  6026. * Set the yaw, pitch, and roll of the bone in local or world space
  6027. * @param yaw The rotation of the bone on the y axis
  6028. * @param pitch The rotation of the bone on the x axis
  6029. * @param roll The rotation of the bone on the z axis
  6030. * @param space The space that the axes of rotation are in
  6031. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6032. */
  6033. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6034. /**
  6035. * Add a rotation to the bone on an axis in local or world space
  6036. * @param axis The axis to rotate the bone on
  6037. * @param amount The amount to rotate the bone
  6038. * @param space The space that the axis is in
  6039. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6040. */
  6041. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6042. /**
  6043. * Set the rotation of the bone to a particular axis angle in local or world space
  6044. * @param axis The axis to rotate the bone on
  6045. * @param angle The angle that the bone should be rotated to
  6046. * @param space The space that the axis is in
  6047. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6048. */
  6049. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6050. /**
  6051. * Set the euler rotation of the bone in local of world space
  6052. * @param rotation The euler rotation that the bone should be set to
  6053. * @param space The space that the rotation is in
  6054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6055. */
  6056. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6057. /**
  6058. * Set the quaternion rotation of the bone in local of world space
  6059. * @param quat The quaternion rotation that the bone should be set to
  6060. * @param space The space that the rotation is in
  6061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6062. */
  6063. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6064. /**
  6065. * Set the rotation matrix of the bone in local of world space
  6066. * @param rotMat The rotation matrix that the bone should be set to
  6067. * @param space The space that the rotation is in
  6068. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6069. */
  6070. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6071. private _rotateWithMatrix;
  6072. private _getNegativeRotationToRef;
  6073. /**
  6074. * Get the position of the bone in local or world space
  6075. * @param space The space that the returned position is in
  6076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6077. * @returns The position of the bone
  6078. */
  6079. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6080. /**
  6081. * Copy the position of the bone to a vector3 in local or world space
  6082. * @param space The space that the returned position is in
  6083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6084. * @param result The vector3 to copy the position to
  6085. */
  6086. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6087. /**
  6088. * Get the absolute position of the bone (world space)
  6089. * @param mesh The mesh that this bone is attached to
  6090. * @returns The absolute position of the bone
  6091. */
  6092. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6093. /**
  6094. * Copy the absolute position of the bone (world space) to the result param
  6095. * @param mesh The mesh that this bone is attached to
  6096. * @param result The vector3 to copy the absolute position to
  6097. */
  6098. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6099. /**
  6100. * Compute the absolute transforms of this bone and its children
  6101. */
  6102. computeAbsoluteTransforms(): void;
  6103. /**
  6104. * Get the world direction from an axis that is in the local space of the bone
  6105. * @param localAxis The local direction that is used to compute the world direction
  6106. * @param mesh The mesh that this bone is attached to
  6107. * @returns The world direction
  6108. */
  6109. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6110. /**
  6111. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6112. * @param localAxis The local direction that is used to compute the world direction
  6113. * @param mesh The mesh that this bone is attached to
  6114. * @param result The vector3 that the world direction will be copied to
  6115. */
  6116. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6117. /**
  6118. * Get the euler rotation of the bone in local or world space
  6119. * @param space The space that the rotation should be in
  6120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6121. * @returns The euler rotation
  6122. */
  6123. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6124. /**
  6125. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6126. * @param space The space that the rotation should be in
  6127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6128. * @param result The vector3 that the rotation should be copied to
  6129. */
  6130. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6131. /**
  6132. * Get the quaternion rotation of the bone in either local or world space
  6133. * @param space The space that the rotation should be in
  6134. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6135. * @returns The quaternion rotation
  6136. */
  6137. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6138. /**
  6139. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6140. * @param space The space that the rotation should be in
  6141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6142. * @param result The quaternion that the rotation should be copied to
  6143. */
  6144. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6145. /**
  6146. * Get the rotation matrix of the bone in local or world space
  6147. * @param space The space that the rotation should be in
  6148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6149. * @returns The rotation matrix
  6150. */
  6151. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6152. /**
  6153. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6154. * @param space The space that the rotation should be in
  6155. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6156. * @param result The quaternion that the rotation should be copied to
  6157. */
  6158. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6159. /**
  6160. * Get the world position of a point that is in the local space of the bone
  6161. * @param position The local position
  6162. * @param mesh The mesh that this bone is attached to
  6163. * @returns The world position
  6164. */
  6165. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6166. /**
  6167. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6168. * @param position The local position
  6169. * @param mesh The mesh that this bone is attached to
  6170. * @param result The vector3 that the world position should be copied to
  6171. */
  6172. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6173. /**
  6174. * Get the local position of a point that is in world space
  6175. * @param position The world position
  6176. * @param mesh The mesh that this bone is attached to
  6177. * @returns The local position
  6178. */
  6179. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6180. /**
  6181. * Get the local position of a point that is in world space and copy it to the result param
  6182. * @param position The world position
  6183. * @param mesh The mesh that this bone is attached to
  6184. * @param result The vector3 that the local position should be copied to
  6185. */
  6186. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6187. }
  6188. }
  6189. declare module BABYLON {
  6190. /**
  6191. * Class used to apply inverse kinematics to bones
  6192. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6193. */
  6194. class BoneIKController {
  6195. private static _tmpVecs;
  6196. private static _tmpQuat;
  6197. private static _tmpMats;
  6198. /**
  6199. * Gets or sets the target mesh
  6200. */
  6201. targetMesh: AbstractMesh;
  6202. /** Gets or sets the mesh used as pole */
  6203. poleTargetMesh: AbstractMesh;
  6204. /**
  6205. * Gets or sets the bone used as pole
  6206. */
  6207. poleTargetBone: Nullable<Bone>;
  6208. /**
  6209. * Gets or sets the target position
  6210. */
  6211. targetPosition: Vector3;
  6212. /**
  6213. * Gets or sets the pole target position
  6214. */
  6215. poleTargetPosition: Vector3;
  6216. /**
  6217. * Gets or sets the pole target local offset
  6218. */
  6219. poleTargetLocalOffset: Vector3;
  6220. /**
  6221. * Gets or sets the pole angle
  6222. */
  6223. poleAngle: number;
  6224. /**
  6225. * Gets or sets the mesh associated with the controller
  6226. */
  6227. mesh: AbstractMesh;
  6228. /**
  6229. * 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)
  6230. */
  6231. slerpAmount: number;
  6232. private _bone1Quat;
  6233. private _bone1Mat;
  6234. private _bone2Ang;
  6235. private _bone1;
  6236. private _bone2;
  6237. private _bone1Length;
  6238. private _bone2Length;
  6239. private _maxAngle;
  6240. private _maxReach;
  6241. private _rightHandedSystem;
  6242. private _bendAxis;
  6243. private _slerping;
  6244. private _adjustRoll;
  6245. /**
  6246. * Gets or sets maximum allowed angle
  6247. */
  6248. maxAngle: number;
  6249. /**
  6250. * Creates a new BoneIKController
  6251. * @param mesh defines the mesh to control
  6252. * @param bone defines the bone to control
  6253. * @param options defines options to set up the controller
  6254. */
  6255. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6256. targetMesh?: AbstractMesh;
  6257. poleTargetMesh?: AbstractMesh;
  6258. poleTargetBone?: Bone;
  6259. poleTargetLocalOffset?: Vector3;
  6260. poleAngle?: number;
  6261. bendAxis?: Vector3;
  6262. maxAngle?: number;
  6263. slerpAmount?: number;
  6264. });
  6265. private _setMaxAngle;
  6266. /**
  6267. * Force the controller to update the bones
  6268. */
  6269. update(): void;
  6270. }
  6271. }
  6272. declare module BABYLON {
  6273. /**
  6274. * Class used to make a bone look toward a point in space
  6275. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6276. */
  6277. class BoneLookController {
  6278. private static _tmpVecs;
  6279. private static _tmpQuat;
  6280. private static _tmpMats;
  6281. /**
  6282. * The target Vector3 that the bone will look at
  6283. */
  6284. target: Vector3;
  6285. /**
  6286. * The mesh that the bone is attached to
  6287. */
  6288. mesh: AbstractMesh;
  6289. /**
  6290. * The bone that will be looking to the target
  6291. */
  6292. bone: Bone;
  6293. /**
  6294. * The up axis of the coordinate system that is used when the bone is rotated
  6295. */
  6296. upAxis: Vector3;
  6297. /**
  6298. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6299. */
  6300. upAxisSpace: Space;
  6301. /**
  6302. * Used to make an adjustment to the yaw of the bone
  6303. */
  6304. adjustYaw: number;
  6305. /**
  6306. * Used to make an adjustment to the pitch of the bone
  6307. */
  6308. adjustPitch: number;
  6309. /**
  6310. * Used to make an adjustment to the roll of the bone
  6311. */
  6312. adjustRoll: number;
  6313. /**
  6314. * 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)
  6315. */
  6316. slerpAmount: number;
  6317. private _minYaw;
  6318. private _maxYaw;
  6319. private _minPitch;
  6320. private _maxPitch;
  6321. private _minYawSin;
  6322. private _minYawCos;
  6323. private _maxYawSin;
  6324. private _maxYawCos;
  6325. private _midYawConstraint;
  6326. private _minPitchTan;
  6327. private _maxPitchTan;
  6328. private _boneQuat;
  6329. private _slerping;
  6330. private _transformYawPitch;
  6331. private _transformYawPitchInv;
  6332. private _firstFrameSkipped;
  6333. private _yawRange;
  6334. private _fowardAxis;
  6335. /**
  6336. * Gets or sets the minimum yaw angle that the bone can look to
  6337. */
  6338. minYaw: number;
  6339. /**
  6340. * Gets or sets the maximum yaw angle that the bone can look to
  6341. */
  6342. maxYaw: number;
  6343. /**
  6344. * Gets or sets the minimum pitch angle that the bone can look to
  6345. */
  6346. minPitch: number;
  6347. /**
  6348. * Gets or sets the maximum pitch angle that the bone can look to
  6349. */
  6350. maxPitch: number;
  6351. /**
  6352. * Create a BoneLookController
  6353. * @param mesh the mesh that the bone belongs to
  6354. * @param bone the bone that will be looking to the target
  6355. * @param target the target Vector3 to look at
  6356. * @param settings optional settings:
  6357. * * maxYaw: the maximum angle the bone will yaw to
  6358. * * minYaw: the minimum angle the bone will yaw to
  6359. * * maxPitch: the maximum angle the bone will pitch to
  6360. * * minPitch: the minimum angle the bone will yaw to
  6361. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6362. * * upAxis: the up axis of the coordinate system
  6363. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6364. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6365. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6366. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6367. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6368. * * adjustRoll: used to make an adjustment to the roll of the bone
  6369. **/
  6370. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6371. maxYaw?: number;
  6372. minYaw?: number;
  6373. maxPitch?: number;
  6374. minPitch?: number;
  6375. slerpAmount?: number;
  6376. upAxis?: Vector3;
  6377. upAxisSpace?: Space;
  6378. yawAxis?: Vector3;
  6379. pitchAxis?: Vector3;
  6380. adjustYaw?: number;
  6381. adjustPitch?: number;
  6382. adjustRoll?: number;
  6383. });
  6384. /**
  6385. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6386. */
  6387. update(): void;
  6388. private _getAngleDiff;
  6389. private _getAngleBetween;
  6390. private _isAngleBetween;
  6391. }
  6392. }
  6393. declare module BABYLON {
  6394. /**
  6395. * Class used to handle skinning animations
  6396. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6397. */
  6398. class Skeleton implements IAnimatable {
  6399. /** defines the skeleton name */
  6400. name: string;
  6401. /** defines the skeleton Id */
  6402. id: string;
  6403. /**
  6404. * Gets the list of child bones
  6405. */
  6406. bones: Bone[];
  6407. /**
  6408. * Gets an estimate of the dimension of the skeleton at rest
  6409. */
  6410. dimensionsAtRest: Vector3;
  6411. /**
  6412. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6413. */
  6414. needInitialSkinMatrix: boolean;
  6415. /**
  6416. * Gets the list of animations attached to this skeleton
  6417. */
  6418. animations: Array<Animation>;
  6419. private _scene;
  6420. private _isDirty;
  6421. private _transformMatrices;
  6422. private _meshesWithPoseMatrix;
  6423. private _animatables;
  6424. private _identity;
  6425. private _synchronizedWithMesh;
  6426. private _ranges;
  6427. private _lastAbsoluteTransformsUpdateId;
  6428. /**
  6429. * Specifies if the skeleton should be serialized
  6430. */
  6431. doNotSerialize: boolean;
  6432. private _animationPropertiesOverride;
  6433. /**
  6434. * Gets or sets the animation properties override
  6435. */
  6436. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6437. /**
  6438. * An observable triggered before computing the skeleton's matrices
  6439. */
  6440. onBeforeComputeObservable: Observable<Skeleton>;
  6441. /**
  6442. * Creates a new skeleton
  6443. * @param name defines the skeleton name
  6444. * @param id defines the skeleton Id
  6445. * @param scene defines the hosting scene
  6446. */
  6447. constructor(
  6448. /** defines the skeleton name */
  6449. name: string,
  6450. /** defines the skeleton Id */
  6451. id: string, scene: Scene);
  6452. /**
  6453. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6454. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6455. * @returns a Float32Array containing matrices data
  6456. */
  6457. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6458. /**
  6459. * Gets the current hosting scene
  6460. * @returns a scene object
  6461. */
  6462. getScene(): Scene;
  6463. /**
  6464. * Gets a string representing the current skeleton data
  6465. * @param fullDetails defines a boolean indicating if we want a verbose version
  6466. * @returns a string representing the current skeleton data
  6467. */
  6468. toString(fullDetails?: boolean): string;
  6469. /**
  6470. * Get bone's index searching by name
  6471. * @param name defines bone's name to search for
  6472. * @return the indice of the bone. Returns -1 if not found
  6473. */
  6474. getBoneIndexByName(name: string): number;
  6475. /**
  6476. * Creater a new animation range
  6477. * @param name defines the name of the range
  6478. * @param from defines the start key
  6479. * @param to defines the end key
  6480. */
  6481. createAnimationRange(name: string, from: number, to: number): void;
  6482. /**
  6483. * Delete a specific animation range
  6484. * @param name defines the name of the range
  6485. * @param deleteFrames defines if frames must be removed as well
  6486. */
  6487. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6488. /**
  6489. * Gets a specific animation range
  6490. * @param name defines the name of the range to look for
  6491. * @returns the requested animation range or null if not found
  6492. */
  6493. getAnimationRange(name: string): Nullable<AnimationRange>;
  6494. /**
  6495. * Gets the list of all animation ranges defined on this skeleton
  6496. * @returns an array
  6497. */
  6498. getAnimationRanges(): Nullable<AnimationRange>[];
  6499. /**
  6500. * Copy animation range from a source skeleton.
  6501. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6502. * @param source defines the source skeleton
  6503. * @param name defines the name of the range to copy
  6504. * @param rescaleAsRequired defines if rescaling must be applied if required
  6505. * @returns true if operation was successful
  6506. */
  6507. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6508. /**
  6509. * Forces the skeleton to go to rest pose
  6510. */
  6511. returnToRest(): void;
  6512. private _getHighestAnimationFrame;
  6513. /**
  6514. * Begin a specific animation range
  6515. * @param name defines the name of the range to start
  6516. * @param loop defines if looping must be turned on (false by default)
  6517. * @param speedRatio defines the speed ratio to apply (1 by default)
  6518. * @param onAnimationEnd defines a callback which will be called when animation will end
  6519. * @returns a new animatable
  6520. */
  6521. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6522. /** @hidden */
  6523. _markAsDirty(): void;
  6524. /** @hidden */
  6525. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6526. /** @hidden */
  6527. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6528. /** @hidden */
  6529. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6530. /**
  6531. * Build all resources required to render a skeleton
  6532. */
  6533. prepare(): void;
  6534. /**
  6535. * Gets the list of animatables currently running for this skeleton
  6536. * @returns an array of animatables
  6537. */
  6538. getAnimatables(): IAnimatable[];
  6539. /**
  6540. * Clone the current skeleton
  6541. * @param name defines the name of the new skeleton
  6542. * @param id defines the id of the enw skeleton
  6543. * @returns the new skeleton
  6544. */
  6545. clone(name: string, id: string): Skeleton;
  6546. /**
  6547. * Enable animation blending for this skeleton
  6548. * @param blendingSpeed defines the blending speed to apply
  6549. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6550. */
  6551. enableBlending(blendingSpeed?: number): void;
  6552. /**
  6553. * Releases all resources associated with the current skeleton
  6554. */
  6555. dispose(): void;
  6556. /**
  6557. * Serialize the skeleton in a JSON object
  6558. * @returns a JSON object
  6559. */
  6560. serialize(): any;
  6561. /**
  6562. * Creates a new skeleton from serialized data
  6563. * @param parsedSkeleton defines the serialized data
  6564. * @param scene defines the hosting scene
  6565. * @returns a new skeleton
  6566. */
  6567. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6568. /**
  6569. * Compute all node absolute transforms
  6570. * @param forceUpdate defines if computation must be done even if cache is up to date
  6571. */
  6572. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6573. /**
  6574. * Gets the root pose matrix
  6575. * @returns a matrix
  6576. */
  6577. getPoseMatrix(): Nullable<Matrix>;
  6578. /**
  6579. * Sorts bones per internal index
  6580. */
  6581. sortBones(): void;
  6582. private _sortBones;
  6583. }
  6584. }
  6585. declare module BABYLON {
  6586. /** @hidden */
  6587. class Collider {
  6588. /** Define if a collision was found */
  6589. collisionFound: boolean;
  6590. /**
  6591. * Define last intersection point in local space
  6592. */
  6593. intersectionPoint: Vector3;
  6594. /**
  6595. * Define last collided mesh
  6596. */
  6597. collidedMesh: Nullable<AbstractMesh>;
  6598. private _collisionPoint;
  6599. private _planeIntersectionPoint;
  6600. private _tempVector;
  6601. private _tempVector2;
  6602. private _tempVector3;
  6603. private _tempVector4;
  6604. private _edge;
  6605. private _baseToVertex;
  6606. private _destinationPoint;
  6607. private _slidePlaneNormal;
  6608. private _displacementVector;
  6609. /** @hidden */
  6610. _radius: Vector3;
  6611. /** @hidden */
  6612. _retry: number;
  6613. private _velocity;
  6614. private _basePoint;
  6615. private _epsilon;
  6616. /** @hidden */
  6617. _velocityWorldLength: number;
  6618. /** @hidden */
  6619. _basePointWorld: Vector3;
  6620. private _velocityWorld;
  6621. private _normalizedVelocity;
  6622. /** @hidden */
  6623. _initialVelocity: Vector3;
  6624. /** @hidden */
  6625. _initialPosition: Vector3;
  6626. private _nearestDistance;
  6627. private _collisionMask;
  6628. collisionMask: number;
  6629. /**
  6630. * Gets the plane normal used to compute the sliding response (in local space)
  6631. */
  6632. readonly slidePlaneNormal: Vector3;
  6633. /** @hidden */
  6634. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6635. /** @hidden */
  6636. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6637. /** @hidden */
  6638. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6639. /** @hidden */
  6640. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6641. /** @hidden */
  6642. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6643. /** @hidden */
  6644. _getResponse(pos: Vector3, vel: Vector3): void;
  6645. }
  6646. }
  6647. declare module BABYLON {
  6648. /** @hidden */
  6649. var CollisionWorker: string;
  6650. /** @hidden */
  6651. interface ICollisionCoordinator {
  6652. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6653. init(scene: Scene): void;
  6654. destroy(): void;
  6655. onMeshAdded(mesh: AbstractMesh): void;
  6656. onMeshUpdated(mesh: AbstractMesh): void;
  6657. onMeshRemoved(mesh: AbstractMesh): void;
  6658. onGeometryAdded(geometry: Geometry): void;
  6659. onGeometryUpdated(geometry: Geometry): void;
  6660. onGeometryDeleted(geometry: Geometry): void;
  6661. }
  6662. /** @hidden */
  6663. interface SerializedMesh {
  6664. id: string;
  6665. name: string;
  6666. uniqueId: number;
  6667. geometryId: Nullable<string>;
  6668. sphereCenter: Array<number>;
  6669. sphereRadius: number;
  6670. boxMinimum: Array<number>;
  6671. boxMaximum: Array<number>;
  6672. worldMatrixFromCache: any;
  6673. subMeshes: Array<SerializedSubMesh>;
  6674. checkCollisions: boolean;
  6675. }
  6676. /** @hidden */
  6677. interface SerializedSubMesh {
  6678. position: number;
  6679. verticesStart: number;
  6680. verticesCount: number;
  6681. indexStart: number;
  6682. indexCount: number;
  6683. hasMaterial: boolean;
  6684. sphereCenter: Array<number>;
  6685. sphereRadius: number;
  6686. boxMinimum: Array<number>;
  6687. boxMaximum: Array<number>;
  6688. }
  6689. /**
  6690. * Interface describing the value associated with a geometry.
  6691. * @hidden
  6692. */
  6693. interface SerializedGeometry {
  6694. /**
  6695. * Defines the unique ID of the geometry
  6696. */
  6697. id: string;
  6698. /**
  6699. * Defines the array containing the positions
  6700. */
  6701. positions: Float32Array;
  6702. /**
  6703. * Defines the array containing the indices
  6704. */
  6705. indices: Uint32Array;
  6706. /**
  6707. * Defines the array containing the normals
  6708. */
  6709. normals: Float32Array;
  6710. }
  6711. /** @hidden */
  6712. interface BabylonMessage {
  6713. taskType: WorkerTaskType;
  6714. payload: InitPayload | CollidePayload | UpdatePayload;
  6715. }
  6716. /** @hidden */
  6717. interface SerializedColliderToWorker {
  6718. position: Array<number>;
  6719. velocity: Array<number>;
  6720. radius: Array<number>;
  6721. }
  6722. /** Defines supported task for worker process */
  6723. enum WorkerTaskType {
  6724. /** Initialization */
  6725. INIT = 0,
  6726. /** Update of geometry */
  6727. UPDATE = 1,
  6728. /** Evaluate collision */
  6729. COLLIDE = 2
  6730. }
  6731. /** @hidden */
  6732. interface WorkerReply {
  6733. error: WorkerReplyType;
  6734. taskType: WorkerTaskType;
  6735. payload?: any;
  6736. }
  6737. /** @hidden */
  6738. interface CollisionReplyPayload {
  6739. newPosition: Array<number>;
  6740. collisionId: number;
  6741. collidedMeshUniqueId: number;
  6742. }
  6743. /** @hidden */
  6744. interface InitPayload {
  6745. }
  6746. /** @hidden */
  6747. interface CollidePayload {
  6748. collisionId: number;
  6749. collider: SerializedColliderToWorker;
  6750. maximumRetry: number;
  6751. excludedMeshUniqueId: Nullable<number>;
  6752. }
  6753. /** @hidden */
  6754. interface UpdatePayload {
  6755. updatedMeshes: {
  6756. [n: number]: SerializedMesh;
  6757. };
  6758. updatedGeometries: {
  6759. [s: string]: SerializedGeometry;
  6760. };
  6761. removedMeshes: Array<number>;
  6762. removedGeometries: Array<string>;
  6763. }
  6764. /** Defines kind of replies returned by worker */
  6765. enum WorkerReplyType {
  6766. /** Success */
  6767. SUCCESS = 0,
  6768. /** Unkown error */
  6769. UNKNOWN_ERROR = 1
  6770. }
  6771. /** @hidden */
  6772. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6773. private _scene;
  6774. private _scaledPosition;
  6775. private _scaledVelocity;
  6776. private _collisionsCallbackArray;
  6777. private _init;
  6778. private _runningUpdated;
  6779. private _worker;
  6780. private _addUpdateMeshesList;
  6781. private _addUpdateGeometriesList;
  6782. private _toRemoveMeshesArray;
  6783. private _toRemoveGeometryArray;
  6784. constructor();
  6785. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6786. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6787. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6788. init(scene: Scene): void;
  6789. destroy(): void;
  6790. onMeshAdded(mesh: AbstractMesh): void;
  6791. onMeshUpdated: (transformNode: TransformNode) => void;
  6792. onMeshRemoved(mesh: AbstractMesh): void;
  6793. onGeometryAdded(geometry: Geometry): void;
  6794. onGeometryUpdated: (geometry: Geometry) => void;
  6795. onGeometryDeleted(geometry: Geometry): void;
  6796. private _afterRender;
  6797. private _onMessageFromWorker;
  6798. }
  6799. /** @hidden */
  6800. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6801. private _scene;
  6802. private _scaledPosition;
  6803. private _scaledVelocity;
  6804. private _finalPosition;
  6805. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6806. init(scene: Scene): void;
  6807. destroy(): void;
  6808. onMeshAdded(mesh: AbstractMesh): void;
  6809. onMeshUpdated(mesh: AbstractMesh): void;
  6810. onMeshRemoved(mesh: AbstractMesh): void;
  6811. onGeometryAdded(geometry: Geometry): void;
  6812. onGeometryUpdated(geometry: Geometry): void;
  6813. onGeometryDeleted(geometry: Geometry): void;
  6814. private _collideWithWorld;
  6815. }
  6816. }
  6817. declare function importScripts(...urls: string[]): void;
  6818. declare const safePostMessage: any;
  6819. declare module BABYLON {
  6820. /** @hidden */
  6821. var WorkerIncluded: boolean;
  6822. /** @hidden */
  6823. class CollisionCache {
  6824. private _meshes;
  6825. private _geometries;
  6826. getMeshes(): {
  6827. [n: number]: SerializedMesh;
  6828. };
  6829. getGeometries(): {
  6830. [s: number]: SerializedGeometry;
  6831. };
  6832. getMesh(id: any): SerializedMesh;
  6833. addMesh(mesh: SerializedMesh): void;
  6834. removeMesh(uniqueId: number): void;
  6835. getGeometry(id: string): SerializedGeometry;
  6836. addGeometry(geometry: SerializedGeometry): void;
  6837. removeGeometry(id: string): void;
  6838. }
  6839. /** @hidden */
  6840. class CollideWorker {
  6841. collider: Collider;
  6842. private _collisionCache;
  6843. private finalPosition;
  6844. private collisionsScalingMatrix;
  6845. private collisionTranformationMatrix;
  6846. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6847. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6848. private checkCollision;
  6849. private processCollisionsForSubMeshes;
  6850. private collideForSubMesh;
  6851. private checkSubmeshCollision;
  6852. }
  6853. /** @hidden */
  6854. interface ICollisionDetector {
  6855. onInit(payload: InitPayload): void;
  6856. onUpdate(payload: UpdatePayload): void;
  6857. onCollision(payload: CollidePayload): void;
  6858. }
  6859. /** @hidden */
  6860. class CollisionDetectorTransferable implements ICollisionDetector {
  6861. private _collisionCache;
  6862. onInit(payload: InitPayload): void;
  6863. onUpdate(payload: UpdatePayload): void;
  6864. onCollision(payload: CollidePayload): void;
  6865. }
  6866. }
  6867. declare module BABYLON {
  6868. /**
  6869. * @hidden
  6870. */
  6871. class IntersectionInfo {
  6872. bu: Nullable<number>;
  6873. bv: Nullable<number>;
  6874. distance: number;
  6875. faceId: number;
  6876. subMeshId: number;
  6877. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6878. }
  6879. /**
  6880. * Information about the result of picking within a scene
  6881. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  6882. */
  6883. class PickingInfo {
  6884. /**
  6885. * If the pick collided with an object
  6886. */
  6887. hit: boolean;
  6888. /**
  6889. * Distance away where the pick collided
  6890. */
  6891. distance: number;
  6892. /**
  6893. * The location of pick collision
  6894. */
  6895. pickedPoint: Nullable<Vector3>;
  6896. /**
  6897. * The mesh corresponding the the pick collision
  6898. */
  6899. pickedMesh: Nullable<AbstractMesh>;
  6900. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6901. bu: number;
  6902. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6903. bv: number;
  6904. /** The id of the face on the mesh that was picked */
  6905. faceId: number;
  6906. /** Id of the the submesh that was picked */
  6907. subMeshId: number;
  6908. /** If a sprite was picked, this will be the sprite the pick collided with */
  6909. pickedSprite: Nullable<Sprite>;
  6910. /**
  6911. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6912. */
  6913. originMesh: Nullable<AbstractMesh>;
  6914. /**
  6915. * The ray that was used to perform the picking.
  6916. */
  6917. ray: Nullable<Ray>;
  6918. /**
  6919. * Gets the normal correspodning to the face the pick collided with
  6920. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6921. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6922. * @returns The normal correspodning to the face the pick collided with
  6923. */
  6924. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6925. /**
  6926. * Gets the texture coordinates of where the pick occured
  6927. * @returns the vector containing the coordnates of the texture
  6928. */
  6929. getTextureCoordinates(): Nullable<Vector2>;
  6930. }
  6931. }
  6932. declare module BABYLON {
  6933. /**
  6934. * This represents an orbital type of camera.
  6935. *
  6936. * 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.
  6937. * 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.
  6938. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6939. */
  6940. class ArcRotateCamera extends TargetCamera {
  6941. /**
  6942. * Defines the rotation angle of the camera along the longitudinal axis.
  6943. */
  6944. alpha: number;
  6945. /**
  6946. * Defines the rotation angle of the camera along the latitudinal axis.
  6947. */
  6948. beta: number;
  6949. /**
  6950. * Defines the radius of the camera from it s target point.
  6951. */
  6952. radius: number;
  6953. protected _target: Vector3;
  6954. protected _targetHost: Nullable<AbstractMesh>;
  6955. /**
  6956. * Defines the target point of the camera.
  6957. * The camera looks towards it form the radius distance.
  6958. */
  6959. target: Vector3;
  6960. /**
  6961. * Current inertia value on the longitudinal axis.
  6962. * The bigger this number the longer it will take for the camera to stop.
  6963. */
  6964. inertialAlphaOffset: number;
  6965. /**
  6966. * Current inertia value on the latitudinal axis.
  6967. * The bigger this number the longer it will take for the camera to stop.
  6968. */
  6969. inertialBetaOffset: number;
  6970. /**
  6971. * Current inertia value on the radius axis.
  6972. * The bigger this number the longer it will take for the camera to stop.
  6973. */
  6974. inertialRadiusOffset: number;
  6975. /**
  6976. * Minimum allowed angle on the longitudinal axis.
  6977. * This can help limiting how the Camera is able to move in the scene.
  6978. */
  6979. lowerAlphaLimit: Nullable<number>;
  6980. /**
  6981. * Maximum allowed angle on the longitudinal axis.
  6982. * This can help limiting how the Camera is able to move in the scene.
  6983. */
  6984. upperAlphaLimit: Nullable<number>;
  6985. /**
  6986. * Minimum allowed angle on the latitudinal axis.
  6987. * This can help limiting how the Camera is able to move in the scene.
  6988. */
  6989. lowerBetaLimit: number;
  6990. /**
  6991. * Maximum allowed angle on the latitudinal axis.
  6992. * This can help limiting how the Camera is able to move in the scene.
  6993. */
  6994. upperBetaLimit: number;
  6995. /**
  6996. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6997. * This can help limiting how the Camera is able to move in the scene.
  6998. */
  6999. lowerRadiusLimit: Nullable<number>;
  7000. /**
  7001. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7002. * This can help limiting how the Camera is able to move in the scene.
  7003. */
  7004. upperRadiusLimit: Nullable<number>;
  7005. /**
  7006. * Defines the current inertia value used during panning of the camera along the X axis.
  7007. */
  7008. inertialPanningX: number;
  7009. /**
  7010. * Defines the current inertia value used during panning of the camera along the Y axis.
  7011. */
  7012. inertialPanningY: number;
  7013. /**
  7014. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7015. * Basically if your fingers moves away from more than this distance you will be considered
  7016. * in pinch mode.
  7017. */
  7018. pinchToPanMaxDistance: number;
  7019. /**
  7020. * Defines the maximum distance the camera can pan.
  7021. * This could help keeping the cammera always in your scene.
  7022. */
  7023. panningDistanceLimit: Nullable<number>;
  7024. /**
  7025. * Defines the target of the camera before paning.
  7026. */
  7027. panningOriginTarget: Vector3;
  7028. /**
  7029. * Defines the value of the inertia used during panning.
  7030. * 0 would mean stop inertia and one would mean no decelleration at all.
  7031. */
  7032. panningInertia: number;
  7033. /**
  7034. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7035. */
  7036. angularSensibilityX: number;
  7037. /**
  7038. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7039. */
  7040. angularSensibilityY: number;
  7041. /**
  7042. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7043. */
  7044. pinchPrecision: number;
  7045. /**
  7046. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7047. * It will be used instead of pinchDeltaPrecision if different from 0.
  7048. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7049. */
  7050. pinchDeltaPercentage: number;
  7051. /**
  7052. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7053. */
  7054. panningSensibility: number;
  7055. /**
  7056. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7057. */
  7058. keysUp: number[];
  7059. /**
  7060. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7061. */
  7062. keysDown: number[];
  7063. /**
  7064. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7065. */
  7066. keysLeft: number[];
  7067. /**
  7068. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7069. */
  7070. keysRight: number[];
  7071. /**
  7072. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7073. */
  7074. wheelPrecision: number;
  7075. /**
  7076. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7077. * It will be used instead of pinchDeltaPrecision if different from 0.
  7078. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7079. */
  7080. wheelDeltaPercentage: number;
  7081. /**
  7082. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7083. */
  7084. zoomOnFactor: number;
  7085. /**
  7086. * Defines a screen offset for the camera position.
  7087. */
  7088. targetScreenOffset: Vector2;
  7089. /**
  7090. * Allows the camera to be completely reversed.
  7091. * If false the camera can not arrive upside down.
  7092. */
  7093. allowUpsideDown: boolean;
  7094. /**
  7095. * Define if double tap/click is used to restore the previously saved state of the camera.
  7096. */
  7097. useInputToRestoreState: boolean;
  7098. /** @hidden */
  7099. _viewMatrix: Matrix;
  7100. /** @hidden */
  7101. _useCtrlForPanning: boolean;
  7102. /** @hidden */
  7103. _panningMouseButton: number;
  7104. /**
  7105. * Defines the inpute associated to the camera.
  7106. */
  7107. inputs: ArcRotateCameraInputsManager;
  7108. /** @hidden */
  7109. _reset: () => void;
  7110. /**
  7111. * Defines the allowed panning axis.
  7112. */
  7113. panningAxis: Vector3;
  7114. protected _localDirection: Vector3;
  7115. protected _transformedDirection: Vector3;
  7116. private _bouncingBehavior;
  7117. /**
  7118. * Gets the bouncing behavior of the camera if it has been enabled.
  7119. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7120. */
  7121. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7122. /**
  7123. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7124. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7125. */
  7126. useBouncingBehavior: boolean;
  7127. private _framingBehavior;
  7128. /**
  7129. * Gets the framing behavior of the camera if it has been enabled.
  7130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7131. */
  7132. readonly framingBehavior: Nullable<FramingBehavior>;
  7133. /**
  7134. * Defines if the framing behavior of the camera is enabled on the camera.
  7135. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7136. */
  7137. useFramingBehavior: boolean;
  7138. private _autoRotationBehavior;
  7139. /**
  7140. * Gets the auto rotation behavior of the camera if it has been enabled.
  7141. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7142. */
  7143. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7144. /**
  7145. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7146. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7147. */
  7148. useAutoRotationBehavior: boolean;
  7149. /**
  7150. * Observable triggered when the mesh target has been changed on the camera.
  7151. */
  7152. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7153. /**
  7154. * Event raised when the camera is colliding with a mesh.
  7155. */
  7156. onCollide: (collidedMesh: AbstractMesh) => void;
  7157. /**
  7158. * Defines whether the camera should check collision with the objects oh the scene.
  7159. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7160. */
  7161. checkCollisions: boolean;
  7162. /**
  7163. * Defines the collision radius of the camera.
  7164. * This simulates a sphere around the camera.
  7165. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7166. */
  7167. collisionRadius: Vector3;
  7168. protected _collider: Collider;
  7169. protected _previousPosition: Vector3;
  7170. protected _collisionVelocity: Vector3;
  7171. protected _newPosition: Vector3;
  7172. protected _previousAlpha: number;
  7173. protected _previousBeta: number;
  7174. protected _previousRadius: number;
  7175. protected _collisionTriggered: boolean;
  7176. protected _targetBoundingCenter: Nullable<Vector3>;
  7177. private _computationVector;
  7178. /**
  7179. * Instantiates a new ArcRotateCamera in a given scene
  7180. * @param name Defines the name of the camera
  7181. * @param alpha Defines the camera rotation along the logitudinal axis
  7182. * @param beta Defines the camera rotation along the latitudinal axis
  7183. * @param radius Defines the camera distance from its target
  7184. * @param target Defines the camera target
  7185. * @param scene Defines the scene the camera belongs to
  7186. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7187. */
  7188. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7189. /** @hidden */
  7190. _initCache(): void;
  7191. /** @hidden */
  7192. _updateCache(ignoreParentClass?: boolean): void;
  7193. protected _getTargetPosition(): Vector3;
  7194. private _storedAlpha;
  7195. private _storedBeta;
  7196. private _storedRadius;
  7197. private _storedTarget;
  7198. /**
  7199. * Stores the current state of the camera (alpha, beta, radius and target)
  7200. * @returns the camera itself
  7201. */
  7202. storeState(): Camera;
  7203. /**
  7204. * @hidden
  7205. * Restored camera state. You must call storeState() first
  7206. */
  7207. _restoreStateValues(): boolean;
  7208. /** @hidden */
  7209. _isSynchronizedViewMatrix(): boolean;
  7210. /**
  7211. * Attached controls to the current camera.
  7212. * @param element Defines the element the controls should be listened from
  7213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7214. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7215. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7216. */
  7217. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7218. /**
  7219. * Detach the current controls from the camera.
  7220. * The camera will stop reacting to inputs.
  7221. * @param element Defines the element to stop listening the inputs from
  7222. */
  7223. detachControl(element: HTMLElement): void;
  7224. /** @hidden */
  7225. _checkInputs(): void;
  7226. protected _checkLimits(): void;
  7227. /**
  7228. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7229. */
  7230. rebuildAnglesAndRadius(): void;
  7231. /**
  7232. * Use a position to define the current camera related information like aplha, beta and radius
  7233. * @param position Defines the position to set the camera at
  7234. */
  7235. setPosition(position: Vector3): void;
  7236. /**
  7237. * Defines the target the camera should look at.
  7238. * This will automatically adapt alpha beta and radius to fit within the new target.
  7239. * @param target Defines the new target as a Vector or a mesh
  7240. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7241. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7242. */
  7243. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7244. /** @hidden */
  7245. _getViewMatrix(): Matrix;
  7246. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7247. /**
  7248. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7249. * @param meshes Defines the mesh to zoom on
  7250. * @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)
  7251. */
  7252. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7253. /**
  7254. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7255. * The target will be changed but the radius
  7256. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7257. * @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)
  7258. */
  7259. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7260. min: Vector3;
  7261. max: Vector3;
  7262. distance: number;
  7263. }, doNotUpdateMaxZ?: boolean): void;
  7264. /**
  7265. * @override
  7266. * Override Camera.createRigCamera
  7267. */
  7268. createRigCamera(name: string, cameraIndex: number): Camera;
  7269. /**
  7270. * @hidden
  7271. * @override
  7272. * Override Camera._updateRigCameras
  7273. */
  7274. _updateRigCameras(): void;
  7275. /**
  7276. * Destroy the camera and release the current resources hold by it.
  7277. */
  7278. dispose(): void;
  7279. /**
  7280. * Gets the current object class name.
  7281. * @return the class name
  7282. */
  7283. getClassName(): string;
  7284. }
  7285. }
  7286. declare module BABYLON {
  7287. /**
  7288. * Default Inputs manager for the ArcRotateCamera.
  7289. * It groups all the default supported inputs for ease of use.
  7290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7291. */
  7292. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7293. /**
  7294. * Instantiates a new ArcRotateCameraInputsManager.
  7295. * @param camera Defines the camera the inputs belong to
  7296. */
  7297. constructor(camera: ArcRotateCamera);
  7298. /**
  7299. * Add mouse wheel input support to the input manager.
  7300. * @returns the current input manager
  7301. */
  7302. addMouseWheel(): ArcRotateCameraInputsManager;
  7303. /**
  7304. * Add pointers input support to the input manager.
  7305. * @returns the current input manager
  7306. */
  7307. addPointers(): ArcRotateCameraInputsManager;
  7308. /**
  7309. * Add keyboard input support to the input manager.
  7310. * @returns the current input manager
  7311. */
  7312. addKeyboard(): ArcRotateCameraInputsManager;
  7313. /**
  7314. * Add orientation input support to the input manager.
  7315. * @returns the current input manager
  7316. */
  7317. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * This is the base class of all the camera used in the application.
  7323. * @see http://doc.babylonjs.com/features/cameras
  7324. */
  7325. class Camera extends Node {
  7326. /**
  7327. * This is the default projection mode used by the cameras.
  7328. * It helps recreating a feeling of perspective and better appreciate depth.
  7329. * This is the best way to simulate real life cameras.
  7330. */
  7331. static readonly PERSPECTIVE_CAMERA: number;
  7332. /**
  7333. * This helps creating camera with an orthographic mode.
  7334. * 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.
  7335. */
  7336. static readonly ORTHOGRAPHIC_CAMERA: number;
  7337. /**
  7338. * This is the default FOV mode for perspective cameras.
  7339. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7340. */
  7341. static readonly FOVMODE_VERTICAL_FIXED: number;
  7342. /**
  7343. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7344. */
  7345. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7346. /**
  7347. * This specifies ther is no need for a camera rig.
  7348. * Basically only one eye is rendered corresponding to the camera.
  7349. */
  7350. static readonly RIG_MODE_NONE: number;
  7351. /**
  7352. * Simulates a camera Rig with one blue eye and one red eye.
  7353. * This can be use with 3d blue and red glasses.
  7354. */
  7355. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7356. /**
  7357. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7358. */
  7359. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7360. /**
  7361. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7362. */
  7363. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7364. /**
  7365. * Defines that both eyes of the camera will be rendered over under each other.
  7366. */
  7367. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7368. /**
  7369. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7370. */
  7371. static readonly RIG_MODE_VR: number;
  7372. /**
  7373. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7374. */
  7375. static readonly RIG_MODE_WEBVR: number;
  7376. /**
  7377. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7378. */
  7379. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7380. /**
  7381. * @hidden
  7382. * Might be removed once multiview will be a thing
  7383. */
  7384. static UseAlternateWebVRRendering: boolean;
  7385. /**
  7386. * Define the input manager associated with the camera.
  7387. */
  7388. inputs: CameraInputsManager<Camera>;
  7389. /**
  7390. * Define the current local position of the camera in the scene
  7391. */
  7392. position: Vector3;
  7393. /**
  7394. * The vector the camera should consider as up.
  7395. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7396. */
  7397. upVector: Vector3;
  7398. /**
  7399. * Define the current limit on the left side for an orthographic camera
  7400. * In scene unit
  7401. */
  7402. orthoLeft: Nullable<number>;
  7403. /**
  7404. * Define the current limit on the right side for an orthographic camera
  7405. * In scene unit
  7406. */
  7407. orthoRight: Nullable<number>;
  7408. /**
  7409. * Define the current limit on the bottom side for an orthographic camera
  7410. * In scene unit
  7411. */
  7412. orthoBottom: Nullable<number>;
  7413. /**
  7414. * Define the current limit on the top side for an orthographic camera
  7415. * In scene unit
  7416. */
  7417. orthoTop: Nullable<number>;
  7418. /**
  7419. * Field Of View is set in Radians. (default is 0.8)
  7420. */
  7421. fov: number;
  7422. /**
  7423. * Define the minimum distance the camera can see from.
  7424. * This is important to note that the depth buffer are not infinite and the closer it starts
  7425. * the more your scene might encounter depth fighting issue.
  7426. */
  7427. minZ: number;
  7428. /**
  7429. * Define the maximum distance the camera can see to.
  7430. * This is important to note that the depth buffer are not infinite and the further it end
  7431. * the more your scene might encounter depth fighting issue.
  7432. */
  7433. maxZ: number;
  7434. /**
  7435. * Define the default inertia of the camera.
  7436. * This helps giving a smooth feeling to the camera movement.
  7437. */
  7438. inertia: number;
  7439. /**
  7440. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7441. */
  7442. mode: number;
  7443. /**
  7444. * Define wether the camera is intermediate.
  7445. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7446. */
  7447. isIntermediate: boolean;
  7448. /**
  7449. * Define the viewport of the camera.
  7450. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7451. */
  7452. viewport: Viewport;
  7453. /**
  7454. * Restricts the camera to viewing objects with the same layerMask.
  7455. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7456. */
  7457. layerMask: number;
  7458. /**
  7459. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7460. */
  7461. fovMode: number;
  7462. /**
  7463. * Rig mode of the camera.
  7464. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7465. * This is normally controlled byt the camera themselves as internal use.
  7466. */
  7467. cameraRigMode: number;
  7468. /**
  7469. * Defines the distance between both "eyes" in case of a RIG
  7470. */
  7471. interaxialDistance: number;
  7472. /**
  7473. * Defines if stereoscopic rendering is done side by side or over under.
  7474. */
  7475. isStereoscopicSideBySide: boolean;
  7476. /**
  7477. * Defines the list of custom render target the camera should render to.
  7478. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7479. * else in the scene.
  7480. */
  7481. customRenderTargets: RenderTargetTexture[];
  7482. /**
  7483. * Observable triggered when the camera view matrix has changed.
  7484. */
  7485. onViewMatrixChangedObservable: Observable<Camera>;
  7486. /**
  7487. * Observable triggered when the camera Projection matrix has changed.
  7488. */
  7489. onProjectionMatrixChangedObservable: Observable<Camera>;
  7490. /**
  7491. * Observable triggered when the inputs have been processed.
  7492. */
  7493. onAfterCheckInputsObservable: Observable<Camera>;
  7494. /**
  7495. * Observable triggered when reset has been called and applied to the camera.
  7496. */
  7497. onRestoreStateObservable: Observable<Camera>;
  7498. /** @hidden */
  7499. _cameraRigParams: any;
  7500. /** @hidden */
  7501. _rigCameras: Camera[];
  7502. /** @hidden */
  7503. _rigPostProcess: Nullable<PostProcess>;
  7504. protected _webvrViewMatrix: Matrix;
  7505. /** @hidden */
  7506. _skipRendering: boolean;
  7507. /** @hidden */
  7508. _alternateCamera: Camera;
  7509. /** @hidden */
  7510. _projectionMatrix: Matrix;
  7511. /** @hidden */
  7512. _postProcesses: Nullable<PostProcess>[];
  7513. /** @hidden */
  7514. _activeMeshes: SmartArray<AbstractMesh>;
  7515. protected _globalPosition: Vector3;
  7516. private _computedViewMatrix;
  7517. private _doNotComputeProjectionMatrix;
  7518. private _transformMatrix;
  7519. private _frustumPlanes;
  7520. private _refreshFrustumPlanes;
  7521. private _storedFov;
  7522. private _stateStored;
  7523. /**
  7524. * Instantiates a new camera object.
  7525. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7526. * @see http://doc.babylonjs.com/features/cameras
  7527. * @param name Defines the name of the camera in the scene
  7528. * @param position Defines the position of the camera
  7529. * @param scene Defines the scene the camera belongs too
  7530. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7531. */
  7532. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7533. /**
  7534. * Store current camera state (fov, position, etc..)
  7535. * @returns the camera
  7536. */
  7537. storeState(): Camera;
  7538. /**
  7539. * Restores the camera state values if it has been stored. You must call storeState() first
  7540. */
  7541. protected _restoreStateValues(): boolean;
  7542. /**
  7543. * Restored camera state. You must call storeState() first.
  7544. * @returns true if restored and false otherwise
  7545. */
  7546. restoreState(): boolean;
  7547. /**
  7548. * Gets the class name of the camera.
  7549. * @returns the class name
  7550. */
  7551. getClassName(): string;
  7552. /**
  7553. * Gets a string representation of the camera usefull for debug purpose.
  7554. * @param fullDetails Defines that a more verboe level of logging is required
  7555. * @returns the string representation
  7556. */
  7557. toString(fullDetails?: boolean): string;
  7558. /**
  7559. * Gets the current world space position of the camera.
  7560. */
  7561. readonly globalPosition: Vector3;
  7562. /**
  7563. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7564. * @returns the active meshe list
  7565. */
  7566. getActiveMeshes(): SmartArray<AbstractMesh>;
  7567. /**
  7568. * Check wether a mesh is part of the current active mesh list of the camera
  7569. * @param mesh Defines the mesh to check
  7570. * @returns true if active, false otherwise
  7571. */
  7572. isActiveMesh(mesh: Mesh): boolean;
  7573. /**
  7574. * Is this camera ready to be used/rendered
  7575. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7576. * @return true if the camera is ready
  7577. */
  7578. isReady(completeCheck?: boolean): boolean;
  7579. /** @hidden */
  7580. _initCache(): void;
  7581. /** @hidden */
  7582. _updateCache(ignoreParentClass?: boolean): void;
  7583. /** @hidden */
  7584. _isSynchronized(): boolean;
  7585. /** @hidden */
  7586. _isSynchronizedViewMatrix(): boolean;
  7587. /** @hidden */
  7588. _isSynchronizedProjectionMatrix(): boolean;
  7589. /**
  7590. * Attach the input controls to a specific dom element to get the input from.
  7591. * @param element Defines the element the controls should be listened from
  7592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7593. */
  7594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7595. /**
  7596. * Detach the current controls from the specified dom element.
  7597. * @param element Defines the element to stop listening the inputs from
  7598. */
  7599. detachControl(element: HTMLElement): void;
  7600. /**
  7601. * Update the camera state according to the different inputs gathered during the frame.
  7602. */
  7603. update(): void;
  7604. /** @hidden */
  7605. _checkInputs(): void;
  7606. /** @hidden */
  7607. readonly rigCameras: Camera[];
  7608. /**
  7609. * Gets the post process used by the rig cameras
  7610. */
  7611. readonly rigPostProcess: Nullable<PostProcess>;
  7612. /**
  7613. * Internal, gets the first post proces.
  7614. * @returns the first post process to be run on this camera.
  7615. */
  7616. _getFirstPostProcess(): Nullable<PostProcess>;
  7617. private _cascadePostProcessesToRigCams;
  7618. /**
  7619. * Attach a post process to the camera.
  7620. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7621. * @param postProcess The post process to attach to the camera
  7622. * @param insertAt The position of the post process in case several of them are in use in the scene
  7623. * @returns the position the post process has been inserted at
  7624. */
  7625. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7626. /**
  7627. * Detach a post process to the camera.
  7628. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7629. * @param postProcess The post process to detach from the camera
  7630. */
  7631. detachPostProcess(postProcess: PostProcess): void;
  7632. /**
  7633. * Gets the current world matrix of the camera
  7634. */
  7635. getWorldMatrix(): Matrix;
  7636. /** @hidden */
  7637. protected _getViewMatrix(): Matrix;
  7638. /**
  7639. * Gets the current view matrix of the camera.
  7640. * @param force forces the camera to recompute the matrix without looking at the cached state
  7641. * @returns the view matrix
  7642. */
  7643. getViewMatrix(force?: boolean): Matrix;
  7644. /**
  7645. * Freeze the projection matrix.
  7646. * It will prevent the cache check of the camera projection compute and can speed up perf
  7647. * if no parameter of the camera are meant to change
  7648. * @param projection Defines manually a projection if necessary
  7649. */
  7650. freezeProjectionMatrix(projection?: Matrix): void;
  7651. /**
  7652. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7653. */
  7654. unfreezeProjectionMatrix(): void;
  7655. /**
  7656. * Gets the current projection matrix of the camera.
  7657. * @param force forces the camera to recompute the matrix without looking at the cached state
  7658. * @returns the projection matrix
  7659. */
  7660. getProjectionMatrix(force?: boolean): Matrix;
  7661. /**
  7662. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7663. * @returns a Matrix
  7664. */
  7665. getTransformationMatrix(): Matrix;
  7666. private _updateFrustumPlanes;
  7667. /**
  7668. * Checks if a cullable object (mesh...) is in the camera frustum
  7669. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7670. * @param target The object to check
  7671. * @returns true if the object is in frustum otherwise false
  7672. */
  7673. isInFrustum(target: ICullable): boolean;
  7674. /**
  7675. * Checks if a cullable object (mesh...) is in the camera frustum
  7676. * Unlike isInFrustum this cheks the full bounding box
  7677. * @param target The object to check
  7678. * @returns true if the object is in frustum otherwise false
  7679. */
  7680. isCompletelyInFrustum(target: ICullable): boolean;
  7681. /**
  7682. * Gets a ray in the forward direction from the camera.
  7683. * @param length Defines the length of the ray to create
  7684. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7685. * @param origin Defines the start point of the ray which defaults to the camera position
  7686. * @returns the forward ray
  7687. */
  7688. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7689. /**
  7690. * Releases resources associated with this node.
  7691. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7692. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7693. */
  7694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7695. /**
  7696. * Gets the left camera of a rig setup in case of Rigged Camera
  7697. */
  7698. readonly leftCamera: Nullable<FreeCamera>;
  7699. /**
  7700. * Gets the right camera of a rig setup in case of Rigged Camera
  7701. */
  7702. readonly rightCamera: Nullable<FreeCamera>;
  7703. /**
  7704. * Gets the left camera target of a rig setup in case of Rigged Camera
  7705. * @returns the target position
  7706. */
  7707. getLeftTarget(): Nullable<Vector3>;
  7708. /**
  7709. * Gets the right camera target of a rig setup in case of Rigged Camera
  7710. * @returns the target position
  7711. */
  7712. getRightTarget(): Nullable<Vector3>;
  7713. /**
  7714. * @hidden
  7715. */
  7716. setCameraRigMode(mode: number, rigParams: any): void;
  7717. private _getVRProjectionMatrix;
  7718. protected _updateCameraRotationMatrix(): void;
  7719. protected _updateWebVRCameraRotationMatrix(): void;
  7720. /**
  7721. * This function MUST be overwritten by the different WebVR cameras available.
  7722. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7723. */
  7724. protected _getWebVRProjectionMatrix(): Matrix;
  7725. /**
  7726. * This function MUST be overwritten by the different WebVR cameras available.
  7727. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7728. */
  7729. protected _getWebVRViewMatrix(): Matrix;
  7730. /** @hidden */
  7731. setCameraRigParameter(name: string, value: any): void;
  7732. /**
  7733. * needs to be overridden by children so sub has required properties to be copied
  7734. * @hidden
  7735. */
  7736. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7737. /**
  7738. * May need to be overridden by children
  7739. * @hidden
  7740. */
  7741. _updateRigCameras(): void;
  7742. /** @hidden */
  7743. _setupInputs(): void;
  7744. /**
  7745. * Serialiaze the camera setup to a json represention
  7746. * @returns the JSON representation
  7747. */
  7748. serialize(): any;
  7749. /**
  7750. * Clones the current camera.
  7751. * @param name The cloned camera name
  7752. * @returns the cloned camera
  7753. */
  7754. clone(name: string): Camera;
  7755. /**
  7756. * Gets the direction of the camera relative to a given local axis.
  7757. * @param localAxis Defines the reference axis to provide a relative direction.
  7758. * @return the direction
  7759. */
  7760. getDirection(localAxis: Vector3): Vector3;
  7761. /**
  7762. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7763. * @param localAxis Defines the reference axis to provide a relative direction.
  7764. * @param result Defines the vector to store the result in
  7765. */
  7766. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7767. /**
  7768. * Gets a camera constructor for a given camera type
  7769. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7770. * @param name The name of the camera the result will be able to instantiate
  7771. * @param scene The scene the result will construct the camera in
  7772. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7773. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7774. * @returns a factory method to construc the camera
  7775. */
  7776. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7777. /**
  7778. * Compute the world matrix of the camera.
  7779. * @returns the camera workd matrix
  7780. */
  7781. computeWorldMatrix(): Matrix;
  7782. /**
  7783. * Parse a JSON and creates the camera from the parsed information
  7784. * @param parsedCamera The JSON to parse
  7785. * @param scene The scene to instantiate the camera in
  7786. * @returns the newly constructed camera
  7787. */
  7788. static Parse(parsedCamera: any, scene: Scene): Camera;
  7789. }
  7790. }
  7791. declare module BABYLON {
  7792. /**
  7793. * This is a list of all the different input types that are available in the application.
  7794. * Fo instance: ArcRotateCameraGamepadInput...
  7795. */
  7796. var CameraInputTypes: {};
  7797. /**
  7798. * This is the contract to implement in order to create a new input class.
  7799. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7800. */
  7801. interface ICameraInput<TCamera extends Camera> {
  7802. /**
  7803. * Defines the camera the input is attached to.
  7804. */
  7805. camera: Nullable<TCamera>;
  7806. /**
  7807. * Gets the class name of the current intput.
  7808. * @returns the class name
  7809. */
  7810. getClassName(): string;
  7811. /**
  7812. * Get the friendly name associated with the input class.
  7813. * @returns the input friendly name
  7814. */
  7815. getSimpleName(): string;
  7816. /**
  7817. * Attach the input controls to a specific dom element to get the input from.
  7818. * @param element Defines the element the controls should be listened from
  7819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7820. */
  7821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7822. /**
  7823. * Detach the current controls from the specified dom element.
  7824. * @param element Defines the element to stop listening the inputs from
  7825. */
  7826. detachControl(element: Nullable<HTMLElement>): void;
  7827. /**
  7828. * Update the current camera state depending on the inputs that have been used this frame.
  7829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7830. */
  7831. checkInputs?: () => void;
  7832. }
  7833. /**
  7834. * Represents a map of input types to input instance or input index to input instance.
  7835. */
  7836. interface CameraInputsMap<TCamera extends Camera> {
  7837. /**
  7838. * Accessor to the input by input type.
  7839. */
  7840. [name: string]: ICameraInput<TCamera>;
  7841. /**
  7842. * Accessor to the input by input index.
  7843. */
  7844. [idx: number]: ICameraInput<TCamera>;
  7845. }
  7846. /**
  7847. * This represents the input manager used within a camera.
  7848. * It helps dealing with all the different kind of input attached to a camera.
  7849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7850. */
  7851. class CameraInputsManager<TCamera extends Camera> {
  7852. /**
  7853. * Defines the list of inputs attahed to the camera.
  7854. */
  7855. attached: CameraInputsMap<TCamera>;
  7856. /**
  7857. * Defines the dom element the camera is collecting inputs from.
  7858. * This is null if the controls have not been attached.
  7859. */
  7860. attachedElement: Nullable<HTMLElement>;
  7861. /**
  7862. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7863. */
  7864. noPreventDefault: boolean;
  7865. /**
  7866. * Defined the camera the input manager belongs to.
  7867. */
  7868. camera: TCamera;
  7869. /**
  7870. * Update the current camera state depending on the inputs that have been used this frame.
  7871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7872. */
  7873. checkInputs: () => void;
  7874. /**
  7875. * Instantiate a new Camera Input Manager.
  7876. * @param camera Defines the camera the input manager blongs to
  7877. */
  7878. constructor(camera: TCamera);
  7879. /**
  7880. * Add an input method to a camera
  7881. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7882. * @param input camera input method
  7883. */
  7884. add(input: ICameraInput<TCamera>): void;
  7885. /**
  7886. * Remove a specific input method from a camera
  7887. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7888. * @param inputToRemove camera input method
  7889. */
  7890. remove(inputToRemove: ICameraInput<TCamera>): void;
  7891. /**
  7892. * Remove a specific input type from a camera
  7893. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7894. * @param inputType the type of the input to remove
  7895. */
  7896. removeByType(inputType: string): void;
  7897. private _addCheckInputs;
  7898. /**
  7899. * Attach the input controls to the currently attached dom element to listen the events from.
  7900. * @param input Defines the input to attach
  7901. */
  7902. attachInput(input: ICameraInput<TCamera>): void;
  7903. /**
  7904. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7905. * @param element Defines the dom element to collect the events from
  7906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7907. */
  7908. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7909. /**
  7910. * Detach the current manager inputs controls from a specific dom element.
  7911. * @param element Defines the dom element to collect the events from
  7912. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7913. */
  7914. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7915. /**
  7916. * Rebuild the dynamic inputCheck function from the current list of
  7917. * defined inputs in the manager.
  7918. */
  7919. rebuildInputCheck(): void;
  7920. /**
  7921. * Remove all attached input methods from a camera
  7922. */
  7923. clear(): void;
  7924. /**
  7925. * Serialize the current input manager attached to a camera.
  7926. * This ensures than once parsed,
  7927. * the input associated to the camera will be identical to the current ones
  7928. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7929. */
  7930. serialize(serializedCamera: any): void;
  7931. /**
  7932. * Parses an input manager serialized JSON to restore the previous list of inputs
  7933. * and states associated to a camera.
  7934. * @param parsedCamera Defines the JSON to parse
  7935. */
  7936. parse(parsedCamera: any): void;
  7937. }
  7938. }
  7939. declare module BABYLON {
  7940. /**
  7941. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7942. * being tilted forward or back and left or right.
  7943. */
  7944. class DeviceOrientationCamera extends FreeCamera {
  7945. private _initialQuaternion;
  7946. private _quaternionCache;
  7947. /**
  7948. * Creates a new device orientation camera
  7949. * @param name The name of the camera
  7950. * @param position The start position camera
  7951. * @param scene The scene the camera belongs to
  7952. */
  7953. constructor(name: string, position: Vector3, scene: Scene);
  7954. /**
  7955. * Gets the current instance class name ("DeviceOrientationCamera").
  7956. * This helps avoiding instanceof at run time.
  7957. * @returns the class name
  7958. */
  7959. getClassName(): string;
  7960. /**
  7961. * @hidden
  7962. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7963. */
  7964. _checkInputs(): void;
  7965. /**
  7966. * Reset the camera to its default orientation on the specified axis only.
  7967. * @param axis The axis to reset
  7968. */
  7969. resetToCurrentRotation(axis?: Axis): void;
  7970. }
  7971. }
  7972. declare module BABYLON {
  7973. /**
  7974. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7975. * an arc rotate version arcFollowCamera are available.
  7976. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7977. */
  7978. class FollowCamera extends TargetCamera {
  7979. /**
  7980. * Distance the follow camera should follow an object at
  7981. */
  7982. radius: number;
  7983. /**
  7984. * Define a rotation offset between the camera and the object it follows
  7985. */
  7986. rotationOffset: number;
  7987. /**
  7988. * Define a height offset between the camera and the object it follows.
  7989. * It can help following an object from the top (like a car chaing a plane)
  7990. */
  7991. heightOffset: number;
  7992. /**
  7993. * Define how fast the camera can accelerate to follow it s target.
  7994. */
  7995. cameraAcceleration: number;
  7996. /**
  7997. * Define the speed limit of the camera following an object.
  7998. */
  7999. maxCameraSpeed: number;
  8000. /**
  8001. * Define the target of the camera.
  8002. */
  8003. lockedTarget: Nullable<AbstractMesh>;
  8004. /**
  8005. * Instantiates the follow camera.
  8006. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8007. * @param name Define the name of the camera in the scene
  8008. * @param position Define the position of the camera
  8009. * @param scene Define the scene the camera belong to
  8010. * @param lockedTarget Define the target of the camera
  8011. */
  8012. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8013. private _follow;
  8014. /** @hidden */
  8015. _checkInputs(): void;
  8016. /**
  8017. * Gets the camera class name.
  8018. * @returns the class name
  8019. */
  8020. getClassName(): string;
  8021. }
  8022. /**
  8023. * Arc Rotate version of the follow camera.
  8024. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8025. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8026. */
  8027. class ArcFollowCamera extends TargetCamera {
  8028. /** The longitudinal angle of the camera */
  8029. alpha: number;
  8030. /** The latitudinal angle of the camera */
  8031. beta: number;
  8032. /** The radius of the camera from its target */
  8033. radius: number;
  8034. /** Define the camera target (the messh it should follow) */
  8035. target: Nullable<AbstractMesh>;
  8036. private _cartesianCoordinates;
  8037. /**
  8038. * Instantiates a new ArcFollowCamera
  8039. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8040. * @param name Define the name of the camera
  8041. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8042. * @param beta Define the rotation angle of the camera around the elevation axis
  8043. * @param radius Define the radius of the camera from its target point
  8044. * @param target Define the target of the camera
  8045. * @param scene Define the scene the camera belongs to
  8046. */
  8047. constructor(name: string,
  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>, scene: Scene);
  8056. private _follow;
  8057. /** @hidden */
  8058. _checkInputs(): void;
  8059. /**
  8060. * Returns the class name of the object.
  8061. * It is mostly used internally for serialization purposes.
  8062. */
  8063. getClassName(): string;
  8064. }
  8065. }
  8066. declare module BABYLON {
  8067. /**
  8068. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8069. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8070. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8071. */
  8072. class FreeCamera extends TargetCamera {
  8073. /**
  8074. * Define the collision ellipsoid of the camera.
  8075. * This is helpful to simulate a camera body like the player body around the camera
  8076. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8077. */
  8078. ellipsoid: Vector3;
  8079. /**
  8080. * Define an offset for the position of the ellipsoid around the camera.
  8081. * This can be helpful to determine the center of the body near the gravity center of the body
  8082. * instead of its head.
  8083. */
  8084. ellipsoidOffset: Vector3;
  8085. /**
  8086. * Enable or disable collisions of the camera with the rest of the scene objects.
  8087. */
  8088. checkCollisions: boolean;
  8089. /**
  8090. * Enable or disable gravity on the camera.
  8091. */
  8092. applyGravity: boolean;
  8093. /**
  8094. * Define the input manager associated to the camera.
  8095. */
  8096. inputs: FreeCameraInputsManager;
  8097. /**
  8098. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8099. * Higher values reduce sensitivity.
  8100. */
  8101. /**
  8102. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8103. * Higher values reduce sensitivity.
  8104. */
  8105. angularSensibility: number;
  8106. /**
  8107. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8108. */
  8109. keysUp: number[];
  8110. /**
  8111. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8112. */
  8113. keysDown: number[];
  8114. /**
  8115. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8116. */
  8117. keysLeft: number[];
  8118. /**
  8119. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8120. */
  8121. keysRight: number[];
  8122. /**
  8123. * Event raised when the camera collide with a mesh in the scene.
  8124. */
  8125. onCollide: (collidedMesh: AbstractMesh) => void;
  8126. private _collider;
  8127. private _needMoveForGravity;
  8128. private _oldPosition;
  8129. private _diffPosition;
  8130. private _newPosition;
  8131. /** @hidden */
  8132. _localDirection: Vector3;
  8133. /** @hidden */
  8134. _transformedDirection: Vector3;
  8135. /**
  8136. * Instantiates a Free Camera.
  8137. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8138. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8140. * @param name Define the name of the camera in the scene
  8141. * @param position Define the start position of the camera in the scene
  8142. * @param scene Define the scene the camera belongs to
  8143. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8144. */
  8145. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8146. /**
  8147. * Attached controls to the current camera.
  8148. * @param element Defines the element the controls should be listened from
  8149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8150. */
  8151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8152. /**
  8153. * Detach the current controls from the camera.
  8154. * The camera will stop reacting to inputs.
  8155. * @param element Defines the element to stop listening the inputs from
  8156. */
  8157. detachControl(element: HTMLElement): void;
  8158. private _collisionMask;
  8159. /**
  8160. * Define a collision mask to limit the list of object the camera can collide with
  8161. */
  8162. collisionMask: number;
  8163. /** @hidden */
  8164. _collideWithWorld(displacement: Vector3): void;
  8165. private _onCollisionPositionChange;
  8166. /** @hidden */
  8167. _checkInputs(): void;
  8168. /** @hidden */
  8169. _decideIfNeedsToMove(): boolean;
  8170. /** @hidden */
  8171. _updatePosition(): void;
  8172. /**
  8173. * Destroy the camera and release the current resources hold by it.
  8174. */
  8175. dispose(): void;
  8176. /**
  8177. * Gets the current object class name.
  8178. * @return the class name
  8179. */
  8180. getClassName(): string;
  8181. }
  8182. }
  8183. declare module BABYLON {
  8184. /**
  8185. * Default Inputs manager for the FreeCamera.
  8186. * It groups all the default supported inputs for ease of use.
  8187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8188. */
  8189. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8190. /**
  8191. * Instantiates a new FreeCameraInputsManager.
  8192. * @param camera Defines the camera the inputs belong to
  8193. */
  8194. constructor(camera: FreeCamera);
  8195. /**
  8196. * Add keyboard input support to the input manager.
  8197. * @returns the current input manager
  8198. */
  8199. addKeyboard(): FreeCameraInputsManager;
  8200. /**
  8201. * Add mouse input support to the input manager.
  8202. * @returns the current input manager
  8203. */
  8204. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8205. /**
  8206. * Add orientation input support to the input manager.
  8207. * @returns the current input manager
  8208. */
  8209. addDeviceOrientation(): FreeCameraInputsManager;
  8210. /**
  8211. * Add touch input support to the input manager.
  8212. * @returns the current input manager
  8213. */
  8214. addTouch(): FreeCameraInputsManager;
  8215. /**
  8216. * Add virtual joystick input support to the input manager.
  8217. * @returns the current input manager
  8218. */
  8219. addVirtualJoystick(): FreeCameraInputsManager;
  8220. }
  8221. }
  8222. declare module BABYLON {
  8223. /**
  8224. * This represents a FPS type of camera. This is only here for back compat purpose.
  8225. * Please use the UniversalCamera instead as both are identical.
  8226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8227. */
  8228. class GamepadCamera extends UniversalCamera {
  8229. /**
  8230. * Instantiates a new Gamepad Camera
  8231. * This represents a FPS type of camera. This is only here for back compat purpose.
  8232. * Please use the UniversalCamera instead as both are identical.
  8233. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8234. * @param name Define the name of the camera in the scene
  8235. * @param position Define the start position of the camera in the scene
  8236. * @param scene Define the scene the camera belongs to
  8237. */
  8238. constructor(name: string, position: Vector3, scene: Scene);
  8239. /**
  8240. * Gets the current object class name.
  8241. * @return the class name
  8242. */
  8243. getClassName(): string;
  8244. }
  8245. }
  8246. declare module BABYLON {
  8247. /**
  8248. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8249. * This is the base of the follow, arc rotate cameras and Free camera
  8250. * @see http://doc.babylonjs.com/features/cameras
  8251. */
  8252. class TargetCamera extends Camera {
  8253. /**
  8254. * Define the current direction the camera is moving to
  8255. */
  8256. cameraDirection: Vector3;
  8257. /**
  8258. * Define the current rotation the camera is rotating to
  8259. */
  8260. cameraRotation: Vector2;
  8261. /**
  8262. * Define the current rotation of the camera
  8263. */
  8264. rotation: Vector3;
  8265. /**
  8266. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8267. */
  8268. rotationQuaternion: Quaternion;
  8269. /**
  8270. * Define the current speed of the camera
  8271. */
  8272. speed: number;
  8273. /**
  8274. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8275. * around all axis.
  8276. */
  8277. noRotationConstraint: boolean;
  8278. /**
  8279. * Define the current target of the camera as an object or a position.
  8280. */
  8281. lockedTarget: any;
  8282. /** @hidden */
  8283. _currentTarget: Vector3;
  8284. /** @hidden */
  8285. _viewMatrix: Matrix;
  8286. /** @hidden */
  8287. _camMatrix: Matrix;
  8288. /** @hidden */
  8289. _cameraTransformMatrix: Matrix;
  8290. /** @hidden */
  8291. _cameraRotationMatrix: Matrix;
  8292. private _rigCamTransformMatrix;
  8293. /** @hidden */
  8294. _referencePoint: Vector3;
  8295. /** @hidden */
  8296. _transformedReferencePoint: Vector3;
  8297. protected _globalCurrentTarget: Vector3;
  8298. protected _globalCurrentUpVector: Vector3;
  8299. /** @hidden */
  8300. _reset: () => void;
  8301. private _defaultUp;
  8302. /**
  8303. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8304. * This is the base of the follow, arc rotate cameras and Free camera
  8305. * @see http://doc.babylonjs.com/features/cameras
  8306. * @param name Defines the name of the camera in the scene
  8307. * @param position Defines the start position of the camera in the scene
  8308. * @param scene Defines the scene the camera belongs to
  8309. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8310. */
  8311. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8312. /**
  8313. * Gets the position in front of the camera at a given distance.
  8314. * @param distance The distance from the camera we want the position to be
  8315. * @returns the position
  8316. */
  8317. getFrontPosition(distance: number): Vector3;
  8318. /** @hidden */
  8319. _getLockedTargetPosition(): Nullable<Vector3>;
  8320. private _storedPosition;
  8321. private _storedRotation;
  8322. private _storedRotationQuaternion;
  8323. /**
  8324. * Store current camera state of the camera (fov, position, rotation, etc..)
  8325. * @returns the camera
  8326. */
  8327. storeState(): Camera;
  8328. /**
  8329. * Restored camera state. You must call storeState() first
  8330. * @returns whether it was successful or not
  8331. * @hidden
  8332. */
  8333. _restoreStateValues(): boolean;
  8334. /** @hidden */
  8335. _initCache(): void;
  8336. /** @hidden */
  8337. _updateCache(ignoreParentClass?: boolean): void;
  8338. /** @hidden */
  8339. _isSynchronizedViewMatrix(): boolean;
  8340. /** @hidden */
  8341. _computeLocalCameraSpeed(): number;
  8342. /** @hidden */
  8343. setTarget(target: Vector3): void;
  8344. /**
  8345. * Return the current target position of the camera. This value is expressed in local space.
  8346. * @returns the target position
  8347. */
  8348. getTarget(): Vector3;
  8349. /** @hidden */
  8350. _decideIfNeedsToMove(): boolean;
  8351. /** @hidden */
  8352. _updatePosition(): void;
  8353. /** @hidden */
  8354. _checkInputs(): void;
  8355. protected _updateCameraRotationMatrix(): void;
  8356. /**
  8357. * 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)
  8358. * @returns the current camera
  8359. */
  8360. private _rotateUpVectorWithCameraRotationMatrix;
  8361. private _cachedRotationZ;
  8362. /** @hidden */
  8363. _getViewMatrix(): Matrix;
  8364. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8365. /**
  8366. * @hidden
  8367. */
  8368. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8369. /**
  8370. * @hidden
  8371. */
  8372. _updateRigCameras(): void;
  8373. private _getRigCamPosition;
  8374. /**
  8375. * Gets the current object class name.
  8376. * @return the class name
  8377. */
  8378. getClassName(): string;
  8379. }
  8380. }
  8381. declare module BABYLON {
  8382. /**
  8383. * This represents a FPS type of camera controlled by touch.
  8384. * This is like a universal camera minus the Gamepad controls.
  8385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8386. */
  8387. class TouchCamera extends FreeCamera {
  8388. /**
  8389. * Defines the touch sensibility for rotation.
  8390. * The higher the faster.
  8391. */
  8392. touchAngularSensibility: number;
  8393. /**
  8394. * Defines the touch sensibility for move.
  8395. * The higher the faster.
  8396. */
  8397. touchMoveSensibility: number;
  8398. /**
  8399. * Instantiates a new touch camera.
  8400. * This represents a FPS type of camera controlled by touch.
  8401. * This is like a universal camera minus the Gamepad controls.
  8402. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8403. * @param name Define the name of the camera in the scene
  8404. * @param position Define the start position of the camera in the scene
  8405. * @param scene Define the scene the camera belongs to
  8406. */
  8407. constructor(name: string, position: Vector3, scene: Scene);
  8408. /**
  8409. * Gets the current object class name.
  8410. * @return the class name
  8411. */
  8412. getClassName(): string;
  8413. /** @hidden */
  8414. _setupInputs(): void;
  8415. }
  8416. }
  8417. declare module BABYLON {
  8418. /**
  8419. * 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,
  8420. * which still works and will still be found in many Playgrounds.
  8421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8422. */
  8423. class UniversalCamera extends TouchCamera {
  8424. /**
  8425. * Defines the gamepad rotation sensiblity.
  8426. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8427. */
  8428. gamepadAngularSensibility: number;
  8429. /**
  8430. * Defines the gamepad move sensiblity.
  8431. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8432. */
  8433. gamepadMoveSensibility: number;
  8434. /**
  8435. * 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,
  8436. * which still works and will still be found in many Playgrounds.
  8437. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8438. * @param name Define the name of the camera in the scene
  8439. * @param position Define the start position of the camera in the scene
  8440. * @param scene Define the scene the camera belongs to
  8441. */
  8442. constructor(name: string, position: Vector3, scene: Scene);
  8443. /**
  8444. * Gets the current object class name.
  8445. * @return the class name
  8446. */
  8447. getClassName(): string;
  8448. }
  8449. }
  8450. declare module BABYLON {
  8451. /**
  8452. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8453. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8454. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8455. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8456. */
  8457. class VirtualJoysticksCamera extends FreeCamera {
  8458. /**
  8459. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8460. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8461. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8462. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8463. * @param name Define the name of the camera in the scene
  8464. * @param position Define the start position of the camera in the scene
  8465. * @param scene Define the scene the camera belongs to
  8466. */
  8467. constructor(name: string, position: Vector3, scene: Scene);
  8468. /**
  8469. * Gets the current object class name.
  8470. * @return the class name
  8471. */
  8472. getClassName(): string;
  8473. }
  8474. }
  8475. interface VRDisplay extends EventTarget {
  8476. /**
  8477. * Dictionary of capabilities describing the VRDisplay.
  8478. */
  8479. readonly capabilities: VRDisplayCapabilities;
  8480. /**
  8481. * z-depth defining the far plane of the eye view frustum
  8482. * enables mapping of values in the render target depth
  8483. * attachment to scene coordinates. Initially set to 10000.0.
  8484. */
  8485. depthFar: number;
  8486. /**
  8487. * z-depth defining the near plane of the eye view frustum
  8488. * enables mapping of values in the render target depth
  8489. * attachment to scene coordinates. Initially set to 0.01.
  8490. */
  8491. depthNear: number;
  8492. /**
  8493. * An identifier for this distinct VRDisplay. Used as an
  8494. * association point in the Gamepad API.
  8495. */
  8496. readonly displayId: number;
  8497. /**
  8498. * A display name, a user-readable name identifying it.
  8499. */
  8500. readonly displayName: string;
  8501. readonly isConnected: boolean;
  8502. readonly isPresenting: boolean;
  8503. /**
  8504. * If this VRDisplay supports room-scale experiences, the optional
  8505. * stage attribute contains details on the room-scale parameters.
  8506. */
  8507. readonly stageParameters: VRStageParameters | null;
  8508. /**
  8509. * Passing the value returned by `requestAnimationFrame` to
  8510. * `cancelAnimationFrame` will unregister the callback.
  8511. * @param handle Define the hanle of the request to cancel
  8512. */
  8513. cancelAnimationFrame(handle: number): void;
  8514. /**
  8515. * Stops presenting to the VRDisplay.
  8516. * @returns a promise to know when it stopped
  8517. */
  8518. exitPresent(): Promise<void>;
  8519. /**
  8520. * Return the current VREyeParameters for the given eye.
  8521. * @param whichEye Define the eye we want the parameter for
  8522. * @returns the eye parameters
  8523. */
  8524. getEyeParameters(whichEye: string): VREyeParameters;
  8525. /**
  8526. * Populates the passed VRFrameData with the information required to render
  8527. * the current frame.
  8528. * @param frameData Define the data structure to populate
  8529. * @returns true if ok otherwise false
  8530. */
  8531. getFrameData(frameData: VRFrameData): boolean;
  8532. /**
  8533. * Get the layers currently being presented.
  8534. * @returns the list of VR layers
  8535. */
  8536. getLayers(): VRLayer[];
  8537. /**
  8538. * Return a VRPose containing the future predicted pose of the VRDisplay
  8539. * when the current frame will be presented. The value returned will not
  8540. * change until JavaScript has returned control to the browser.
  8541. *
  8542. * The VRPose will contain the position, orientation, velocity,
  8543. * and acceleration of each of these properties.
  8544. * @returns the pose object
  8545. */
  8546. getPose(): VRPose;
  8547. /**
  8548. * Return the current instantaneous pose of the VRDisplay, with no
  8549. * prediction applied.
  8550. * @returns the current instantaneous pose
  8551. */
  8552. getImmediatePose(): VRPose;
  8553. /**
  8554. * The callback passed to `requestAnimationFrame` will be called
  8555. * any time a new frame should be rendered. When the VRDisplay is
  8556. * presenting the callback will be called at the native refresh
  8557. * rate of the HMD. When not presenting this function acts
  8558. * identically to how window.requestAnimationFrame acts. Content should
  8559. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8560. * asynchronously from other displays and at differing refresh rates.
  8561. * @param callback Define the eaction to run next frame
  8562. * @returns the request handle it
  8563. */
  8564. requestAnimationFrame(callback: FrameRequestCallback): number;
  8565. /**
  8566. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8567. * Repeat calls while already presenting will update the VRLayers being displayed.
  8568. * @param layers Define the list of layer to present
  8569. * @returns a promise to know when the request has been fulfilled
  8570. */
  8571. requestPresent(layers: VRLayer[]): Promise<void>;
  8572. /**
  8573. * Reset the pose for this display, treating its current position and
  8574. * orientation as the "origin/zero" values. VRPose.position,
  8575. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8576. * updated when calling resetPose(). This should be called in only
  8577. * sitting-space experiences.
  8578. */
  8579. resetPose(): void;
  8580. /**
  8581. * The VRLayer provided to the VRDisplay will be captured and presented
  8582. * in the HMD. Calling this function has the same effect on the source
  8583. * canvas as any other operation that uses its source image, and canvases
  8584. * created without preserveDrawingBuffer set to true will be cleared.
  8585. * @param pose Define the pose to submit
  8586. */
  8587. submitFrame(pose?: VRPose): void;
  8588. }
  8589. declare var VRDisplay: {
  8590. prototype: VRDisplay;
  8591. new (): VRDisplay;
  8592. };
  8593. interface VRLayer {
  8594. leftBounds?: number[] | Float32Array | null;
  8595. rightBounds?: number[] | Float32Array | null;
  8596. source?: HTMLCanvasElement | null;
  8597. }
  8598. interface VRDisplayCapabilities {
  8599. readonly canPresent: boolean;
  8600. readonly hasExternalDisplay: boolean;
  8601. readonly hasOrientation: boolean;
  8602. readonly hasPosition: boolean;
  8603. readonly maxLayers: number;
  8604. }
  8605. interface VREyeParameters {
  8606. /** @deprecated */
  8607. readonly fieldOfView: VRFieldOfView;
  8608. readonly offset: Float32Array;
  8609. readonly renderHeight: number;
  8610. readonly renderWidth: number;
  8611. }
  8612. interface VRFieldOfView {
  8613. readonly downDegrees: number;
  8614. readonly leftDegrees: number;
  8615. readonly rightDegrees: number;
  8616. readonly upDegrees: number;
  8617. }
  8618. interface VRFrameData {
  8619. readonly leftProjectionMatrix: Float32Array;
  8620. readonly leftViewMatrix: Float32Array;
  8621. readonly pose: VRPose;
  8622. readonly rightProjectionMatrix: Float32Array;
  8623. readonly rightViewMatrix: Float32Array;
  8624. readonly timestamp: number;
  8625. }
  8626. interface VRPose {
  8627. readonly angularAcceleration: Float32Array | null;
  8628. readonly angularVelocity: Float32Array | null;
  8629. readonly linearAcceleration: Float32Array | null;
  8630. readonly linearVelocity: Float32Array | null;
  8631. readonly orientation: Float32Array | null;
  8632. readonly position: Float32Array | null;
  8633. readonly timestamp: number;
  8634. }
  8635. interface VRStageParameters {
  8636. sittingToStandingTransform?: Float32Array;
  8637. sizeX?: number;
  8638. sizeY?: number;
  8639. }
  8640. interface Navigator {
  8641. getVRDisplays(): Promise<VRDisplay[]>;
  8642. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8643. }
  8644. interface Window {
  8645. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8646. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8647. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8648. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8649. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8650. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8651. }
  8652. interface Gamepad {
  8653. readonly displayId: number;
  8654. }
  8655. /**
  8656. * Module Debug contains the (visual) components to debug a scene correctly
  8657. */
  8658. declare module BABYLON.Debug {
  8659. /**
  8660. * The Axes viewer will show 3 axes in a specific point in space
  8661. */
  8662. class AxesViewer {
  8663. private _xline;
  8664. private _yline;
  8665. private _zline;
  8666. private _xmesh;
  8667. private _ymesh;
  8668. private _zmesh;
  8669. /**
  8670. * Gets the hosting scene
  8671. */
  8672. scene: Nullable<Scene>;
  8673. /**
  8674. * Gets or sets a number used to scale line length
  8675. */
  8676. scaleLines: number;
  8677. /**
  8678. * Creates a new AxesViewer
  8679. * @param scene defines the hosting scene
  8680. * @param scaleLines defines a number used to scale line length (1 by default)
  8681. */
  8682. constructor(scene: Scene, scaleLines?: number);
  8683. /**
  8684. * Force the viewer to update
  8685. * @param position defines the position of the viewer
  8686. * @param xaxis defines the x axis of the viewer
  8687. * @param yaxis defines the y axis of the viewer
  8688. * @param zaxis defines the z axis of the viewer
  8689. */
  8690. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  8691. /** Releases resources */
  8692. dispose(): void;
  8693. }
  8694. }
  8695. declare module BABYLON.Debug {
  8696. /**
  8697. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  8698. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  8699. */
  8700. class BoneAxesViewer extends AxesViewer {
  8701. /**
  8702. * Gets or sets the target mesh where to display the axes viewer
  8703. */
  8704. mesh: Nullable<Mesh>;
  8705. /**
  8706. * Gets or sets the target bone where to display the axes viewer
  8707. */
  8708. bone: Nullable<Bone>;
  8709. /** Gets current position */
  8710. pos: Vector3;
  8711. /** Gets direction of X axis */
  8712. xaxis: Vector3;
  8713. /** Gets direction of Y axis */
  8714. yaxis: Vector3;
  8715. /** Gets direction of Z axis */
  8716. zaxis: Vector3;
  8717. /**
  8718. * Creates a new BoneAxesViewer
  8719. * @param scene defines the hosting scene
  8720. * @param bone defines the target bone
  8721. * @param mesh defines the target mesh
  8722. * @param scaleLines defines a scaling factor for line length (1 by default)
  8723. */
  8724. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  8725. /**
  8726. * Force the viewer to update
  8727. */
  8728. update(): void;
  8729. /** Releases resources */
  8730. dispose(): void;
  8731. }
  8732. }
  8733. declare module BABYLON {
  8734. interface Scene {
  8735. /**
  8736. * @hidden
  8737. * Backing field
  8738. */
  8739. _debugLayer: DebugLayer;
  8740. /**
  8741. * Gets the debug layer (aka Inspector) associated with the scene
  8742. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8743. */
  8744. debugLayer: DebugLayer;
  8745. }
  8746. /**
  8747. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8748. * what is happening in your scene
  8749. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8750. */
  8751. class DebugLayer {
  8752. /**
  8753. * Define the url to get the inspector script from.
  8754. * By default it uses the babylonjs CDN.
  8755. * @ignoreNaming
  8756. */
  8757. static InspectorURL: string;
  8758. private _scene;
  8759. private _inspector;
  8760. private BJSINSPECTOR;
  8761. /**
  8762. * Observable triggered when a property is changed through the inspector.
  8763. */
  8764. onPropertyChangedObservable: Observable<{
  8765. object: any;
  8766. property: string;
  8767. value: any;
  8768. initialValue: any;
  8769. }>;
  8770. /**
  8771. * Instantiates a new debug layer.
  8772. * The debug layer (aka Inspector) is the go to tool in order to better understand
  8773. * what is happening in your scene
  8774. * @see http://doc.babylonjs.com/features/playground_debuglayer
  8775. * @param scene Defines the scene to inspect
  8776. */
  8777. constructor(scene: Scene);
  8778. /** Creates the inspector window. */
  8779. private _createInspector;
  8780. /**
  8781. * Get if the inspector is visible or not.
  8782. * @returns true if visible otherwise, false
  8783. */
  8784. isVisible(): boolean;
  8785. /**
  8786. * Hide the inspector and close its window.
  8787. */
  8788. hide(): void;
  8789. /**
  8790. *
  8791. * Launch the debugLayer.
  8792. *
  8793. * initialTab:
  8794. * | Value | Tab Name |
  8795. * | --- | --- |
  8796. * | 0 | Scene |
  8797. * | 1 | Console |
  8798. * | 2 | Stats |
  8799. * | 3 | Textures |
  8800. * | 4 | Mesh |
  8801. * | 5 | Light |
  8802. * | 6 | Material |
  8803. * | 7 | GLTF |
  8804. * | 8 | GUI |
  8805. * | 9 | Physics |
  8806. * | 10 | Camera |
  8807. * | 11 | Audio |
  8808. *
  8809. * @param config Define the configuration of the inspector
  8810. */
  8811. show(config?: {
  8812. popup?: boolean;
  8813. initialTab?: number | string;
  8814. parentElement?: HTMLElement;
  8815. newColors?: {
  8816. backgroundColor?: string;
  8817. backgroundColorLighter?: string;
  8818. backgroundColorLighter2?: string;
  8819. backgroundColorLighter3?: string;
  8820. color?: string;
  8821. colorTop?: string;
  8822. colorBot?: string;
  8823. };
  8824. }): void;
  8825. /**
  8826. * Gets the active tab
  8827. * @return the index of the active tab or -1 if the inspector is hidden
  8828. */
  8829. getActiveTab(): number;
  8830. }
  8831. }
  8832. declare module BABYLON.Debug {
  8833. /**
  8834. * Used to show the physics impostor around the specific mesh
  8835. */
  8836. class PhysicsViewer {
  8837. /** @hidden */
  8838. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  8839. /** @hidden */
  8840. protected _meshes: Array<Nullable<AbstractMesh>>;
  8841. /** @hidden */
  8842. protected _scene: Nullable<Scene>;
  8843. /** @hidden */
  8844. protected _numMeshes: number;
  8845. /** @hidden */
  8846. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  8847. private _renderFunction;
  8848. private _debugBoxMesh;
  8849. private _debugSphereMesh;
  8850. private _debugMaterial;
  8851. /**
  8852. * Creates a new PhysicsViewer
  8853. * @param scene defines the hosting scene
  8854. */
  8855. constructor(scene: Scene);
  8856. /** @hidden */
  8857. protected _updateDebugMeshes(): void;
  8858. /**
  8859. * Renders a specified physic impostor
  8860. * @param impostor defines the impostor to render
  8861. */
  8862. showImpostor(impostor: PhysicsImpostor): void;
  8863. /**
  8864. * Hides a specified physic impostor
  8865. * @param impostor defines the impostor to hide
  8866. */
  8867. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  8868. private _getDebugMaterial;
  8869. private _getDebugBoxMesh;
  8870. private _getDebugSphereMesh;
  8871. private _getDebugMesh;
  8872. /** Releases all resources */
  8873. dispose(): void;
  8874. }
  8875. }
  8876. declare module BABYLON {
  8877. /**
  8878. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8879. * in order to better appreciate the issue one might have.
  8880. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8881. */
  8882. class RayHelper {
  8883. /**
  8884. * Defines the ray we are currently tryin to visualize.
  8885. */
  8886. ray: Nullable<Ray>;
  8887. private _renderPoints;
  8888. private _renderLine;
  8889. private _renderFunction;
  8890. private _scene;
  8891. private _updateToMeshFunction;
  8892. private _attachedToMesh;
  8893. private _meshSpaceDirection;
  8894. private _meshSpaceOrigin;
  8895. /**
  8896. * Helper function to create a colored helper in a scene in one line.
  8897. * @param ray Defines the ray we are currently tryin to visualize
  8898. * @param scene Defines the scene the ray is used in
  8899. * @param color Defines the color we want to see the ray in
  8900. * @returns The newly created ray helper.
  8901. */
  8902. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  8903. /**
  8904. * Instantiate a new ray helper.
  8905. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  8906. * in order to better appreciate the issue one might have.
  8907. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  8908. * @param ray Defines the ray we are currently tryin to visualize
  8909. */
  8910. constructor(ray: Ray);
  8911. /**
  8912. * Shows the ray we are willing to debug.
  8913. * @param scene Defines the scene the ray needs to be rendered in
  8914. * @param color Defines the color the ray needs to be rendered in
  8915. */
  8916. show(scene: Scene, color?: Color3): void;
  8917. /**
  8918. * Hides the ray we are debugging.
  8919. */
  8920. hide(): void;
  8921. private _render;
  8922. /**
  8923. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  8924. * @param mesh Defines the mesh we want the helper attached to
  8925. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  8926. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  8927. * @param length Defines the length of the ray
  8928. */
  8929. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  8930. /**
  8931. * Detach the ray helper from the mesh it has previously been attached to.
  8932. */
  8933. detachFromMesh(): void;
  8934. private _updateToMesh;
  8935. /**
  8936. * Dispose the helper and release its associated resources.
  8937. */
  8938. dispose(): void;
  8939. }
  8940. }
  8941. declare module BABYLON.Debug {
  8942. /**
  8943. * Class used to render a debug view of a given skeleton
  8944. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  8945. */
  8946. class SkeletonViewer {
  8947. /** defines the skeleton to render */
  8948. skeleton: Skeleton;
  8949. /** defines the mesh attached to the skeleton */
  8950. mesh: AbstractMesh;
  8951. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8952. autoUpdateBonesMatrices: boolean;
  8953. /** defines the rendering group id to use with the viewer */
  8954. renderingGroupId: number;
  8955. /** Gets or sets the color used to render the skeleton */
  8956. color: Color3;
  8957. private _scene;
  8958. private _debugLines;
  8959. private _debugMesh;
  8960. private _isEnabled;
  8961. private _renderFunction;
  8962. /**
  8963. * Creates a new SkeletonViewer
  8964. * @param skeleton defines the skeleton to render
  8965. * @param mesh defines the mesh attached to the skeleton
  8966. * @param scene defines the hosting scene
  8967. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  8968. * @param renderingGroupId defines the rendering group id to use with the viewer
  8969. */
  8970. constructor(
  8971. /** defines the skeleton to render */
  8972. skeleton: Skeleton,
  8973. /** defines the mesh attached to the skeleton */
  8974. mesh: AbstractMesh, scene: Scene,
  8975. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  8976. autoUpdateBonesMatrices?: boolean,
  8977. /** defines the rendering group id to use with the viewer */
  8978. renderingGroupId?: number);
  8979. /** Gets or sets a boolean indicating if the viewer is enabled */
  8980. isEnabled: boolean;
  8981. private _getBonePosition;
  8982. private _getLinesForBonesWithLength;
  8983. private _getLinesForBonesNoLength;
  8984. /** Update the viewer to sync with current skeleton state */
  8985. update(): void;
  8986. /** Release associated resources */
  8987. dispose(): void;
  8988. }
  8989. }
  8990. declare module BABYLON {
  8991. /**
  8992. * Interface for attribute information associated with buffer instanciation
  8993. */
  8994. class InstancingAttributeInfo {
  8995. /**
  8996. * Index/offset of the attribute in the vertex shader
  8997. */
  8998. index: number;
  8999. /**
  9000. * size of the attribute, 1, 2, 3 or 4
  9001. */
  9002. attributeSize: number;
  9003. /**
  9004. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9005. * default is FLOAT
  9006. */
  9007. attribyteType: number;
  9008. /**
  9009. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9010. */
  9011. normalized: boolean;
  9012. /**
  9013. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9014. */
  9015. offset: number;
  9016. /**
  9017. * Name of the GLSL attribute, for debugging purpose only
  9018. */
  9019. attributeName: string;
  9020. }
  9021. /**
  9022. * Define options used to create a render target texture
  9023. */
  9024. class RenderTargetCreationOptions {
  9025. /**
  9026. * Specifies is mipmaps must be generated
  9027. */
  9028. generateMipMaps?: boolean;
  9029. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9030. generateDepthBuffer?: boolean;
  9031. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9032. generateStencilBuffer?: boolean;
  9033. /** Defines texture type (int by default) */
  9034. type?: number;
  9035. /** Defines sampling mode (trilinear by default) */
  9036. samplingMode?: number;
  9037. /** Defines format (RGBA by default) */
  9038. format?: number;
  9039. }
  9040. /**
  9041. * Define options used to create a depth texture
  9042. */
  9043. class DepthTextureCreationOptions {
  9044. /** Specifies whether or not a stencil should be allocated in the texture */
  9045. generateStencil?: boolean;
  9046. /** Specifies whether or not bilinear filtering is enable on the texture */
  9047. bilinearFiltering?: boolean;
  9048. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9049. comparisonFunction?: number;
  9050. /** Specifies if the created texture is a cube texture */
  9051. isCube?: boolean;
  9052. }
  9053. /**
  9054. * Class used to describe the capabilities of the engine relatively to the current browser
  9055. */
  9056. class EngineCapabilities {
  9057. /** Maximum textures units per fragment shader */
  9058. maxTexturesImageUnits: number;
  9059. /** Maximum texture units per vertex shader */
  9060. maxVertexTextureImageUnits: number;
  9061. /** Maximum textures units in the entire pipeline */
  9062. maxCombinedTexturesImageUnits: number;
  9063. /** Maximum texture size */
  9064. maxTextureSize: number;
  9065. /** Maximum cube texture size */
  9066. maxCubemapTextureSize: number;
  9067. /** Maximum render texture size */
  9068. maxRenderTextureSize: number;
  9069. /** Maximum number of vertex attributes */
  9070. maxVertexAttribs: number;
  9071. /** Maximum number of varyings */
  9072. maxVaryingVectors: number;
  9073. /** Maximum number of uniforms per vertex shader */
  9074. maxVertexUniformVectors: number;
  9075. /** Maximum number of uniforms per fragment shader */
  9076. maxFragmentUniformVectors: number;
  9077. /** Defines if standard derivates (dx/dy) are supported */
  9078. standardDerivatives: boolean;
  9079. /** Defines if s3tc texture compression is supported */
  9080. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9081. /** Defines if pvrtc texture compression is supported */
  9082. pvrtc: any;
  9083. /** Defines if etc1 texture compression is supported */
  9084. etc1: any;
  9085. /** Defines if etc2 texture compression is supported */
  9086. etc2: any;
  9087. /** Defines if astc texture compression is supported */
  9088. astc: any;
  9089. /** Defines if float textures are supported */
  9090. textureFloat: boolean;
  9091. /** Defines if vertex array objects are supported */
  9092. vertexArrayObject: boolean;
  9093. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9094. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9095. /** Gets the maximum level of anisotropy supported */
  9096. maxAnisotropy: number;
  9097. /** Defines if instancing is supported */
  9098. instancedArrays: boolean;
  9099. /** Defines if 32 bits indices are supported */
  9100. uintIndices: boolean;
  9101. /** Defines if high precision shaders are supported */
  9102. highPrecisionShaderSupported: boolean;
  9103. /** Defines if depth reading in the fragment shader is supported */
  9104. fragmentDepthSupported: boolean;
  9105. /** Defines if float texture linear filtering is supported*/
  9106. textureFloatLinearFiltering: boolean;
  9107. /** Defines if rendering to float textures is supported */
  9108. textureFloatRender: boolean;
  9109. /** Defines if half float textures are supported*/
  9110. textureHalfFloat: boolean;
  9111. /** Defines if half float texture linear filtering is supported*/
  9112. textureHalfFloatLinearFiltering: boolean;
  9113. /** Defines if rendering to half float textures is supported */
  9114. textureHalfFloatRender: boolean;
  9115. /** Defines if textureLOD shader command is supported */
  9116. textureLOD: boolean;
  9117. /** Defines if draw buffers extension is supported */
  9118. drawBuffersExtension: boolean;
  9119. /** Defines if depth textures are supported */
  9120. depthTextureExtension: boolean;
  9121. /** Defines if float color buffer are supported */
  9122. colorBufferFloat: boolean;
  9123. /** Gets disjoint timer query extension (null if not supported) */
  9124. timerQuery: EXT_disjoint_timer_query;
  9125. /** Defines if timestamp can be used with timer query */
  9126. canUseTimestampForTimerQuery: boolean;
  9127. }
  9128. /** Interface defining initialization parameters for Engine class */
  9129. interface EngineOptions extends WebGLContextAttributes {
  9130. /**
  9131. * Defines if the engine should no exceed a specified device ratio
  9132. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9133. */
  9134. limitDeviceRatio?: number;
  9135. /**
  9136. * Defines if webvr should be enabled automatically
  9137. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9138. */
  9139. autoEnableWebVR?: boolean;
  9140. /**
  9141. * Defines if webgl2 should be turned off even if supported
  9142. * @see http://doc.babylonjs.com/features/webgl2
  9143. */
  9144. disableWebGL2Support?: boolean;
  9145. /**
  9146. * Defines if webaudio should be initialized as well
  9147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9148. */
  9149. audioEngine?: boolean;
  9150. /**
  9151. * Defines if animations should run using a deterministic lock step
  9152. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9153. */
  9154. deterministicLockstep?: boolean;
  9155. /** Defines the maximum steps to use with deterministic lock step mode */
  9156. lockstepMaxSteps?: number;
  9157. /**
  9158. * Defines that engine should ignore context lost events
  9159. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9160. */
  9161. doNotHandleContextLost?: boolean;
  9162. }
  9163. /**
  9164. * Defines the interface used by display changed events
  9165. */
  9166. interface IDisplayChangedEventArgs {
  9167. /** Gets the vrDisplay object (if any) */
  9168. vrDisplay: Nullable<any>;
  9169. /** Gets a boolean indicating if webVR is supported */
  9170. vrSupported: boolean;
  9171. }
  9172. /**
  9173. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9174. */
  9175. class Engine {
  9176. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9177. static ExceptionList: ({
  9178. key: string;
  9179. capture: string;
  9180. captureConstraint: number;
  9181. targets: string[];
  9182. } | {
  9183. key: string;
  9184. capture: null;
  9185. captureConstraint: null;
  9186. targets: string[];
  9187. })[];
  9188. /** Gets the list of created engines */
  9189. static Instances: Engine[];
  9190. /**
  9191. * Gets the latest created engine
  9192. */
  9193. static readonly LastCreatedEngine: Nullable<Engine>;
  9194. /**
  9195. * Gets the latest created scene
  9196. */
  9197. static readonly LastCreatedScene: Nullable<Scene>;
  9198. /**
  9199. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9200. * @param flag defines which part of the materials must be marked as dirty
  9201. * @param predicate defines a predicate used to filter which materials should be affected
  9202. */
  9203. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9204. /**
  9205. * Hidden
  9206. */
  9207. static _TextureLoaders: IInternalTextureLoader[];
  9208. /** Defines that alpha blending is disabled */
  9209. static readonly ALPHA_DISABLE: number;
  9210. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9211. static readonly ALPHA_ADD: number;
  9212. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9213. static readonly ALPHA_COMBINE: number;
  9214. /** Defines that alpha blending to DEST - SRC * DEST */
  9215. static readonly ALPHA_SUBTRACT: number;
  9216. /** Defines that alpha blending to SRC * DEST */
  9217. static readonly ALPHA_MULTIPLY: number;
  9218. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9219. static readonly ALPHA_MAXIMIZED: number;
  9220. /** Defines that alpha blending to SRC + DEST */
  9221. static readonly ALPHA_ONEONE: number;
  9222. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9223. static readonly ALPHA_PREMULTIPLIED: number;
  9224. /**
  9225. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9226. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9227. */
  9228. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9229. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  9230. static readonly ALPHA_INTERPOLATE: number;
  9231. /**
  9232. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  9233. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  9234. */
  9235. static readonly ALPHA_SCREENMODE: number;
  9236. /** Defines that the ressource is not delayed*/
  9237. static readonly DELAYLOADSTATE_NONE: number;
  9238. /** Defines that the ressource was successfully delay loaded */
  9239. static readonly DELAYLOADSTATE_LOADED: number;
  9240. /** Defines that the ressource is currently delay loading */
  9241. static readonly DELAYLOADSTATE_LOADING: number;
  9242. /** Defines that the ressource is delayed and has not started loading */
  9243. static readonly DELAYLOADSTATE_NOTLOADED: number;
  9244. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  9245. static readonly NEVER: number;
  9246. /** 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 */
  9247. static readonly ALWAYS: number;
  9248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  9249. static readonly LESS: number;
  9250. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  9251. static readonly EQUAL: number;
  9252. /** 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 */
  9253. static readonly LEQUAL: number;
  9254. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  9255. static readonly GREATER: number;
  9256. /** 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 */
  9257. static readonly GEQUAL: number;
  9258. /** 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 */
  9259. static readonly NOTEQUAL: number;
  9260. /** Passed to stencilOperation to specify that stencil value must be kept */
  9261. static readonly KEEP: number;
  9262. /** Passed to stencilOperation to specify that stencil value must be replaced */
  9263. static readonly REPLACE: number;
  9264. /** Passed to stencilOperation to specify that stencil value must be incremented */
  9265. static readonly INCR: number;
  9266. /** Passed to stencilOperation to specify that stencil value must be decremented */
  9267. static readonly DECR: number;
  9268. /** Passed to stencilOperation to specify that stencil value must be inverted */
  9269. static readonly INVERT: number;
  9270. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  9271. static readonly INCR_WRAP: number;
  9272. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  9273. static readonly DECR_WRAP: number;
  9274. /** Texture is not repeating outside of 0..1 UVs */
  9275. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  9276. /** Texture is repeating outside of 0..1 UVs */
  9277. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  9278. /** Texture is repeating and mirrored */
  9279. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  9280. /** ALPHA */
  9281. static readonly TEXTUREFORMAT_ALPHA: number;
  9282. /** LUMINANCE */
  9283. static readonly TEXTUREFORMAT_LUMINANCE: number;
  9284. /** LUMINANCE_ALPHA */
  9285. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  9286. /** RGB */
  9287. static readonly TEXTUREFORMAT_RGB: number;
  9288. /** RGBA */
  9289. static readonly TEXTUREFORMAT_RGBA: number;
  9290. /** RED */
  9291. static readonly TEXTUREFORMAT_RED: number;
  9292. /** RED (2nd reference) */
  9293. static readonly TEXTUREFORMAT_R: number;
  9294. /** RG */
  9295. static readonly TEXTUREFORMAT_RG: number;
  9296. /** RED_INTEGER */
  9297. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  9298. /** RED_INTEGER (2nd reference) */
  9299. static readonly TEXTUREFORMAT_R_INTEGER: number;
  9300. /** RG_INTEGER */
  9301. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  9302. /** RGB_INTEGER */
  9303. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  9304. /** RGBA_INTEGER */
  9305. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  9306. /** UNSIGNED_BYTE */
  9307. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  9308. /** UNSIGNED_BYTE (2nd reference) */
  9309. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  9310. /** FLOAT */
  9311. static readonly TEXTURETYPE_FLOAT: number;
  9312. /** HALF_FLOAT */
  9313. static readonly TEXTURETYPE_HALF_FLOAT: number;
  9314. /** BYTE */
  9315. static readonly TEXTURETYPE_BYTE: number;
  9316. /** SHORT */
  9317. static readonly TEXTURETYPE_SHORT: number;
  9318. /** UNSIGNED_SHORT */
  9319. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  9320. /** INT */
  9321. static readonly TEXTURETYPE_INT: number;
  9322. /** UNSIGNED_INT */
  9323. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  9324. /** UNSIGNED_SHORT_4_4_4_4 */
  9325. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  9326. /** UNSIGNED_SHORT_5_5_5_1 */
  9327. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  9328. /** UNSIGNED_SHORT_5_6_5 */
  9329. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  9330. /** UNSIGNED_INT_2_10_10_10_REV */
  9331. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  9332. /** UNSIGNED_INT_24_8 */
  9333. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  9334. /** UNSIGNED_INT_10F_11F_11F_REV */
  9335. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  9336. /** UNSIGNED_INT_5_9_9_9_REV */
  9337. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  9338. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  9339. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9340. /** nearest is mag = nearest and min = nearest and mip = linear */
  9341. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  9342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9343. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  9344. /** Trilinear is mag = linear and min = linear and mip = linear */
  9345. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  9346. /** nearest is mag = nearest and min = nearest and mip = linear */
  9347. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  9348. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9349. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  9350. /** Trilinear is mag = linear and min = linear and mip = linear */
  9351. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  9352. /** mag = nearest and min = nearest and mip = nearest */
  9353. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  9354. /** mag = nearest and min = linear and mip = nearest */
  9355. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  9356. /** mag = nearest and min = linear and mip = linear */
  9357. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  9358. /** mag = nearest and min = linear and mip = none */
  9359. static readonly TEXTURE_NEAREST_LINEAR: number;
  9360. /** mag = nearest and min = nearest and mip = none */
  9361. static readonly TEXTURE_NEAREST_NEAREST: number;
  9362. /** mag = linear and min = nearest and mip = nearest */
  9363. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  9364. /** mag = linear and min = nearest and mip = linear */
  9365. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  9366. /** mag = linear and min = linear and mip = none */
  9367. static readonly TEXTURE_LINEAR_LINEAR: number;
  9368. /** mag = linear and min = nearest and mip = none */
  9369. static readonly TEXTURE_LINEAR_NEAREST: number;
  9370. /** Explicit coordinates mode */
  9371. static readonly TEXTURE_EXPLICIT_MODE: number;
  9372. /** Spherical coordinates mode */
  9373. static readonly TEXTURE_SPHERICAL_MODE: number;
  9374. /** Planar coordinates mode */
  9375. static readonly TEXTURE_PLANAR_MODE: number;
  9376. /** Cubic coordinates mode */
  9377. static readonly TEXTURE_CUBIC_MODE: number;
  9378. /** Projection coordinates mode */
  9379. static readonly TEXTURE_PROJECTION_MODE: number;
  9380. /** Skybox coordinates mode */
  9381. static readonly TEXTURE_SKYBOX_MODE: number;
  9382. /** Inverse Cubic coordinates mode */
  9383. static readonly TEXTURE_INVCUBIC_MODE: number;
  9384. /** Equirectangular coordinates mode */
  9385. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  9386. /** Equirectangular Fixed coordinates mode */
  9387. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  9388. /** Equirectangular Fixed Mirrored coordinates mode */
  9389. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  9390. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  9391. static readonly SCALEMODE_FLOOR: number;
  9392. /** Defines that texture rescaling will look for the nearest power of 2 size */
  9393. static readonly SCALEMODE_NEAREST: number;
  9394. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  9395. static readonly SCALEMODE_CEILING: number;
  9396. /**
  9397. * Returns the current version of the framework
  9398. */
  9399. static readonly Version: string;
  9400. /**
  9401. * Gets or sets the epsilon value used by collision engine
  9402. */
  9403. static CollisionsEpsilon: number;
  9404. /**
  9405. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  9406. */
  9407. static CodeRepository: string;
  9408. /**
  9409. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  9410. */
  9411. static ShadersRepository: string;
  9412. /**
  9413. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  9414. */
  9415. forcePOTTextures: boolean;
  9416. /**
  9417. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  9418. */
  9419. isFullscreen: boolean;
  9420. /**
  9421. * Gets a boolean indicating if the pointer is currently locked
  9422. */
  9423. isPointerLock: boolean;
  9424. /**
  9425. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  9426. */
  9427. cullBackFaces: boolean;
  9428. /**
  9429. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  9430. */
  9431. renderEvenInBackground: boolean;
  9432. /**
  9433. * Gets or sets a boolean indicating that cache can be kept between frames
  9434. */
  9435. preventCacheWipeBetweenFrames: boolean;
  9436. /**
  9437. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  9438. **/
  9439. enableOfflineSupport: boolean;
  9440. /**
  9441. * 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)
  9442. **/
  9443. disableManifestCheck: boolean;
  9444. /**
  9445. * Gets the list of created scenes
  9446. */
  9447. scenes: Scene[];
  9448. /**
  9449. * Gets the list of created postprocesses
  9450. */
  9451. postProcesses: PostProcess[];
  9452. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  9453. validateShaderPrograms: boolean;
  9454. /**
  9455. * Observable event triggered each time the rendering canvas is resized
  9456. */
  9457. onResizeObservable: Observable<Engine>;
  9458. /**
  9459. * Observable event triggered each time the canvas loses focus
  9460. */
  9461. onCanvasBlurObservable: Observable<Engine>;
  9462. /**
  9463. * Observable event triggered each time the canvas gains focus
  9464. */
  9465. onCanvasFocusObservable: Observable<Engine>;
  9466. /**
  9467. * Observable event triggered each time the canvas receives pointerout event
  9468. */
  9469. onCanvasPointerOutObservable: Observable<PointerEvent>;
  9470. /**
  9471. * Observable event triggered before each texture is initialized
  9472. */
  9473. onBeforeTextureInitObservable: Observable<Texture>;
  9474. private _vrDisplay;
  9475. private _vrSupported;
  9476. private _oldSize;
  9477. private _oldHardwareScaleFactor;
  9478. private _vrExclusivePointerMode;
  9479. private _webVRInitPromise;
  9480. /**
  9481. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  9482. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  9483. */
  9484. readonly isInVRExclusivePointerMode: boolean;
  9485. /**
  9486. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  9487. */
  9488. disableUniformBuffers: boolean;
  9489. /** @hidden */
  9490. _uniformBuffers: UniformBuffer[];
  9491. /**
  9492. * Gets a boolean indicating that the engine supports uniform buffers
  9493. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  9494. */
  9495. readonly supportsUniformBuffers: boolean;
  9496. /**
  9497. * Observable raised when the engine begins a new frame
  9498. */
  9499. onBeginFrameObservable: Observable<Engine>;
  9500. /**
  9501. * Observable raised when the engine ends the current frame
  9502. */
  9503. onEndFrameObservable: Observable<Engine>;
  9504. /**
  9505. * Observable raised when the engine is about to compile a shader
  9506. */
  9507. onBeforeShaderCompilationObservable: Observable<Engine>;
  9508. /**
  9509. * Observable raised when the engine has jsut compiled a shader
  9510. */
  9511. onAfterShaderCompilationObservable: Observable<Engine>;
  9512. /** @hidden */
  9513. _gl: WebGLRenderingContext;
  9514. private _renderingCanvas;
  9515. private _windowIsBackground;
  9516. private _webGLVersion;
  9517. /**
  9518. * Gets a boolean indicating that only power of 2 textures are supported
  9519. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  9520. */
  9521. readonly needPOTTextures: boolean;
  9522. /** @hidden */
  9523. _badOS: boolean;
  9524. /** @hidden */
  9525. _badDesktopOS: boolean;
  9526. /**
  9527. * Gets or sets a value indicating if we want to disable texture binding optmization.
  9528. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  9529. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  9530. */
  9531. disableTextureBindingOptimization: boolean;
  9532. /**
  9533. * Gets the audio engine
  9534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9535. * @ignorenaming
  9536. */
  9537. static audioEngine: IAudioEngine;
  9538. /**
  9539. * Default AudioEngine Factory responsible of creating the Audio Engine.
  9540. * By default, this will create a BabylonJS Audio Engine if the workload
  9541. * has been embedded.
  9542. */
  9543. static AudioEngineFactory: (engine: Engine) => IAudioEngine;
  9544. private _onFocus;
  9545. private _onBlur;
  9546. private _onCanvasPointerOut;
  9547. private _onCanvasBlur;
  9548. private _onCanvasFocus;
  9549. private _onFullscreenChange;
  9550. private _onPointerLockChange;
  9551. private _onVRDisplayPointerRestricted;
  9552. private _onVRDisplayPointerUnrestricted;
  9553. private _onVrDisplayConnect;
  9554. private _onVrDisplayDisconnect;
  9555. private _onVrDisplayPresentChange;
  9556. /**
  9557. * Observable signaled when VR display mode changes
  9558. */
  9559. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  9560. /**
  9561. * Observable signaled when VR request present is complete
  9562. */
  9563. onVRRequestPresentComplete: Observable<boolean>;
  9564. /**
  9565. * Observable signaled when VR request present starts
  9566. */
  9567. onVRRequestPresentStart: Observable<Engine>;
  9568. private _hardwareScalingLevel;
  9569. /** @hidden */
  9570. protected _caps: EngineCapabilities;
  9571. private _pointerLockRequested;
  9572. private _isStencilEnable;
  9573. private _colorWrite;
  9574. private _loadingScreen;
  9575. /** @hidden */
  9576. _drawCalls: PerfCounter;
  9577. /** @hidden */
  9578. _textureCollisions: PerfCounter;
  9579. private _glVersion;
  9580. private _glRenderer;
  9581. private _glVendor;
  9582. private _videoTextureSupported;
  9583. private _renderingQueueLaunched;
  9584. private _activeRenderLoops;
  9585. private _deterministicLockstep;
  9586. private _lockstepMaxSteps;
  9587. /**
  9588. * Observable signaled when a context lost event is raised
  9589. */
  9590. onContextLostObservable: Observable<Engine>;
  9591. /**
  9592. * Observable signaled when a context restored event is raised
  9593. */
  9594. onContextRestoredObservable: Observable<Engine>;
  9595. private _onContextLost;
  9596. private _onContextRestored;
  9597. private _contextWasLost;
  9598. private _doNotHandleContextLost;
  9599. /**
  9600. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  9601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  9602. */
  9603. doNotHandleContextLost: boolean;
  9604. private _performanceMonitor;
  9605. private _fps;
  9606. private _deltaTime;
  9607. /**
  9608. * Turn this value on if you want to pause FPS computation when in background
  9609. */
  9610. disablePerformanceMonitorInBackground: boolean;
  9611. /**
  9612. * Gets the performance monitor attached to this engine
  9613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  9614. */
  9615. readonly performanceMonitor: PerformanceMonitor;
  9616. /** @hidden */
  9617. protected _depthCullingState: _DepthCullingState;
  9618. /** @hidden */
  9619. protected _stencilState: _StencilState;
  9620. /** @hidden */
  9621. protected _alphaState: _AlphaState;
  9622. /** @hidden */
  9623. protected _alphaMode: number;
  9624. protected _internalTexturesCache: InternalTexture[];
  9625. /** @hidden */
  9626. protected _activeChannel: number;
  9627. private _currentTextureChannel;
  9628. /** @hidden */
  9629. protected _boundTexturesCache: {
  9630. [key: string]: Nullable<InternalTexture>;
  9631. };
  9632. /** @hidden */
  9633. protected _currentEffect: Nullable<Effect>;
  9634. /** @hidden */
  9635. protected _currentProgram: Nullable<WebGLProgram>;
  9636. private _compiledEffects;
  9637. private _vertexAttribArraysEnabled;
  9638. /** @hidden */
  9639. protected _cachedViewport: Nullable<Viewport>;
  9640. private _cachedVertexArrayObject;
  9641. /** @hidden */
  9642. protected _cachedVertexBuffers: any;
  9643. /** @hidden */
  9644. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  9645. /** @hidden */
  9646. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  9647. /** @hidden */
  9648. protected _currentRenderTarget: Nullable<InternalTexture>;
  9649. private _uintIndicesCurrentlySet;
  9650. private _currentBoundBuffer;
  9651. /** @hidden */
  9652. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  9653. private _currentBufferPointers;
  9654. private _currentInstanceLocations;
  9655. private _currentInstanceBuffers;
  9656. private _textureUnits;
  9657. private _firstBoundInternalTextureTracker;
  9658. private _lastBoundInternalTextureTracker;
  9659. private _workingCanvas;
  9660. private _workingContext;
  9661. private _rescalePostProcess;
  9662. private _dummyFramebuffer;
  9663. private _externalData;
  9664. private _bindedRenderFunction;
  9665. private _vaoRecordInProgress;
  9666. private _mustWipeVertexAttributes;
  9667. private _emptyTexture;
  9668. private _emptyCubeTexture;
  9669. private _emptyTexture3D;
  9670. private _frameHandler;
  9671. private _nextFreeTextureSlots;
  9672. private _maxSimultaneousTextures;
  9673. private _activeRequests;
  9674. private _texturesSupported;
  9675. private _textureFormatInUse;
  9676. /**
  9677. * Gets the list of texture formats supported
  9678. */
  9679. readonly texturesSupported: Array<string>;
  9680. /**
  9681. * Gets the list of texture formats in use
  9682. */
  9683. readonly textureFormatInUse: Nullable<string>;
  9684. /**
  9685. * Gets the current viewport
  9686. */
  9687. readonly currentViewport: Nullable<Viewport>;
  9688. /**
  9689. * Gets the default empty texture
  9690. */
  9691. readonly emptyTexture: InternalTexture;
  9692. /**
  9693. * Gets the default empty 3D texture
  9694. */
  9695. readonly emptyTexture3D: InternalTexture;
  9696. /**
  9697. * Gets the default empty cube texture
  9698. */
  9699. readonly emptyCubeTexture: InternalTexture;
  9700. /**
  9701. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  9702. */
  9703. readonly premultipliedAlpha: boolean;
  9704. /**
  9705. * Creates a new engine
  9706. * @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
  9707. * @param antialias defines enable antialiasing (default: false)
  9708. * @param options defines further options to be sent to the getContext() function
  9709. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  9710. */
  9711. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  9712. private _rebuildInternalTextures;
  9713. private _rebuildEffects;
  9714. private _rebuildBuffers;
  9715. private _initGLContext;
  9716. /**
  9717. * Gets version of the current webGL context
  9718. */
  9719. readonly webGLVersion: number;
  9720. /**
  9721. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  9722. */
  9723. readonly isStencilEnable: boolean;
  9724. private _prepareWorkingCanvas;
  9725. /**
  9726. * Reset the texture cache to empty state
  9727. */
  9728. resetTextureCache(): void;
  9729. /**
  9730. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  9731. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9732. * @returns true if engine is in deterministic lock step mode
  9733. */
  9734. isDeterministicLockStep(): boolean;
  9735. /**
  9736. * Gets the max steps when engine is running in deterministic lock step
  9737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9738. * @returns the max steps
  9739. */
  9740. getLockstepMaxSteps(): number;
  9741. /**
  9742. * Gets an object containing information about the current webGL context
  9743. * @returns an object containing the vender, the renderer and the version of the current webGL context
  9744. */
  9745. getGlInfo(): {
  9746. vendor: string;
  9747. renderer: string;
  9748. version: string;
  9749. };
  9750. /**
  9751. * Gets current aspect ratio
  9752. * @param camera defines the camera to use to get the aspect ratio
  9753. * @param useScreen defines if screen size must be used (or the current render target if any)
  9754. * @returns a number defining the aspect ratio
  9755. */
  9756. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  9757. /**
  9758. * Gets current screen aspect ratio
  9759. * @returns a number defining the aspect ratio
  9760. */
  9761. getScreenAspectRatio(): number;
  9762. /**
  9763. * Gets the current render width
  9764. * @param useScreen defines if screen size must be used (or the current render target if any)
  9765. * @returns a number defining the current render width
  9766. */
  9767. getRenderWidth(useScreen?: boolean): number;
  9768. /**
  9769. * Gets the current render height
  9770. * @param useScreen defines if screen size must be used (or the current render target if any)
  9771. * @returns a number defining the current render height
  9772. */
  9773. getRenderHeight(useScreen?: boolean): number;
  9774. /**
  9775. * Gets the HTML canvas attached with the current webGL context
  9776. * @returns a HTML canvas
  9777. */
  9778. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  9779. /**
  9780. * Gets the client rect of the HTML canvas attached with the current webGL context
  9781. * @returns a client rectanglee
  9782. */
  9783. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  9784. /**
  9785. * Defines the hardware scaling level.
  9786. * By default the hardware scaling level is computed from the window device ratio.
  9787. * 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.
  9788. * @param level defines the level to use
  9789. */
  9790. setHardwareScalingLevel(level: number): void;
  9791. /**
  9792. * Gets the current hardware scaling level.
  9793. * By default the hardware scaling level is computed from the window device ratio.
  9794. * 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.
  9795. * @returns a number indicating the current hardware scaling level
  9796. */
  9797. getHardwareScalingLevel(): number;
  9798. /**
  9799. * Gets the list of loaded textures
  9800. * @returns an array containing all loaded textures
  9801. */
  9802. getLoadedTexturesCache(): InternalTexture[];
  9803. /**
  9804. * Gets the object containing all engine capabilities
  9805. * @returns the EngineCapabilities object
  9806. */
  9807. getCaps(): EngineCapabilities;
  9808. /** @hidden */
  9809. readonly drawCalls: number;
  9810. /** @hidden */
  9811. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  9812. /**
  9813. * Gets the current depth function
  9814. * @returns a number defining the depth function
  9815. */
  9816. getDepthFunction(): Nullable<number>;
  9817. /**
  9818. * Sets the current depth function
  9819. * @param depthFunc defines the function to use
  9820. */
  9821. setDepthFunction(depthFunc: number): void;
  9822. /**
  9823. * Sets the current depth function to GREATER
  9824. */
  9825. setDepthFunctionToGreater(): void;
  9826. /**
  9827. * Sets the current depth function to GEQUAL
  9828. */
  9829. setDepthFunctionToGreaterOrEqual(): void;
  9830. /**
  9831. * Sets the current depth function to LESS
  9832. */
  9833. setDepthFunctionToLess(): void;
  9834. /**
  9835. * Sets the current depth function to LEQUAL
  9836. */
  9837. setDepthFunctionToLessOrEqual(): void;
  9838. /**
  9839. * Gets a boolean indicating if stencil buffer is enabled
  9840. * @returns the current stencil buffer state
  9841. */
  9842. getStencilBuffer(): boolean;
  9843. /**
  9844. * Enable or disable the stencil buffer
  9845. * @param enable defines if the stencil buffer must be enabled or disabled
  9846. */
  9847. setStencilBuffer(enable: boolean): void;
  9848. /**
  9849. * Gets the current stencil mask
  9850. * @returns a number defining the new stencil mask to use
  9851. */
  9852. getStencilMask(): number;
  9853. /**
  9854. * Sets the current stencil mask
  9855. * @param mask defines the new stencil mask to use
  9856. */
  9857. setStencilMask(mask: number): void;
  9858. /**
  9859. * Gets the current stencil function
  9860. * @returns a number defining the stencil function to use
  9861. */
  9862. getStencilFunction(): number;
  9863. /**
  9864. * Gets the current stencil reference value
  9865. * @returns a number defining the stencil reference value to use
  9866. */
  9867. getStencilFunctionReference(): number;
  9868. /**
  9869. * Gets the current stencil mask
  9870. * @returns a number defining the stencil mask to use
  9871. */
  9872. getStencilFunctionMask(): number;
  9873. /**
  9874. * Sets the current stencil function
  9875. * @param stencilFunc defines the new stencil function to use
  9876. */
  9877. setStencilFunction(stencilFunc: number): void;
  9878. /**
  9879. * Sets the current stencil reference
  9880. * @param reference defines the new stencil reference to use
  9881. */
  9882. setStencilFunctionReference(reference: number): void;
  9883. /**
  9884. * Sets the current stencil mask
  9885. * @param mask defines the new stencil mask to use
  9886. */
  9887. setStencilFunctionMask(mask: number): void;
  9888. /**
  9889. * Gets the current stencil operation when stencil fails
  9890. * @returns a number defining stencil operation to use when stencil fails
  9891. */
  9892. getStencilOperationFail(): number;
  9893. /**
  9894. * Gets the current stencil operation when depth fails
  9895. * @returns a number defining stencil operation to use when depth fails
  9896. */
  9897. getStencilOperationDepthFail(): number;
  9898. /**
  9899. * Gets the current stencil operation when stencil passes
  9900. * @returns a number defining stencil operation to use when stencil passes
  9901. */
  9902. getStencilOperationPass(): number;
  9903. /**
  9904. * Sets the stencil operation to use when stencil fails
  9905. * @param operation defines the stencil operation to use when stencil fails
  9906. */
  9907. setStencilOperationFail(operation: number): void;
  9908. /**
  9909. * Sets the stencil operation to use when depth fails
  9910. * @param operation defines the stencil operation to use when depth fails
  9911. */
  9912. setStencilOperationDepthFail(operation: number): void;
  9913. /**
  9914. * Sets the stencil operation to use when stencil passes
  9915. * @param operation defines the stencil operation to use when stencil passes
  9916. */
  9917. setStencilOperationPass(operation: number): void;
  9918. /**
  9919. * Sets a boolean indicating if the dithering state is enabled or disabled
  9920. * @param value defines the dithering state
  9921. */
  9922. setDitheringState(value: boolean): void;
  9923. /**
  9924. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  9925. * @param value defines the rasterizer state
  9926. */
  9927. setRasterizerState(value: boolean): void;
  9928. /**
  9929. * stop executing a render loop function and remove it from the execution array
  9930. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  9931. */
  9932. stopRenderLoop(renderFunction?: () => void): void;
  9933. /** @hidden */
  9934. _renderLoop(): void;
  9935. /**
  9936. * Register and execute a render loop. The engine can have more than one render function
  9937. * @param renderFunction defines the function to continuously execute
  9938. */
  9939. runRenderLoop(renderFunction: () => void): void;
  9940. /**
  9941. * Toggle full screen mode
  9942. * @param requestPointerLock defines if a pointer lock should be requested from the user
  9943. */
  9944. switchFullscreen(requestPointerLock: boolean): void;
  9945. /**
  9946. * Clear the current render buffer or the current render target (if any is set up)
  9947. * @param color defines the color to use
  9948. * @param backBuffer defines if the back buffer must be cleared
  9949. * @param depth defines if the depth buffer must be cleared
  9950. * @param stencil defines if the stencil buffer must be cleared
  9951. */
  9952. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9953. /**
  9954. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  9955. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  9956. * @param y defines the y-coordinate of the corner of the clear rectangle
  9957. * @param width defines the width of the clear rectangle
  9958. * @param height defines the height of the clear rectangle
  9959. * @param clearColor defines the clear color
  9960. */
  9961. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  9962. private _viewportCached;
  9963. /** @hidden */
  9964. _viewport(x: number, y: number, width: number, height: number): void;
  9965. /**
  9966. * Set the WebGL's viewport
  9967. * @param viewport defines the viewport element to be used
  9968. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  9969. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  9970. */
  9971. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9972. /**
  9973. * Directly set the WebGL Viewport
  9974. * @param x defines the x coordinate of the viewport (in screen space)
  9975. * @param y defines the y coordinate of the viewport (in screen space)
  9976. * @param width defines the width of the viewport (in screen space)
  9977. * @param height defines the height of the viewport (in screen space)
  9978. * @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
  9979. */
  9980. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  9981. /**
  9982. * Begin a new frame
  9983. */
  9984. beginFrame(): void;
  9985. /**
  9986. * Enf the current frame
  9987. */
  9988. endFrame(): void;
  9989. /**
  9990. * Resize the view according to the canvas' size
  9991. */
  9992. resize(): void;
  9993. /**
  9994. * Force a specific size of the canvas
  9995. * @param width defines the new canvas' width
  9996. * @param height defines the new canvas' height
  9997. */
  9998. setSize(width: number, height: number): void;
  9999. /**
  10000. * Gets a boolean indicating if a webVR device was detected
  10001. * @returns true if a webVR device was detected
  10002. */
  10003. isVRDevicePresent(): boolean;
  10004. /**
  10005. * Gets the current webVR device
  10006. * @returns the current webVR device (or null)
  10007. */
  10008. getVRDevice(): any;
  10009. /**
  10010. * Initializes a webVR display and starts listening to display change events
  10011. * The onVRDisplayChangedObservable will be notified upon these changes
  10012. * @returns The onVRDisplayChangedObservable
  10013. */
  10014. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10015. /**
  10016. * Initializes a webVR display and starts listening to display change events
  10017. * The onVRDisplayChangedObservable will be notified upon these changes
  10018. * @returns A promise containing a VRDisplay and if vr is supported
  10019. */
  10020. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10021. /**
  10022. * Call this function to switch to webVR mode
  10023. * Will do nothing if webVR is not supported or if there is no webVR device
  10024. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10025. */
  10026. enableVR(): void;
  10027. /**
  10028. * Call this function to leave webVR mode
  10029. * Will do nothing if webVR is not supported or if there is no webVR device
  10030. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10031. */
  10032. disableVR(): void;
  10033. private _onVRFullScreenTriggered;
  10034. private _getVRDisplaysAsync;
  10035. /**
  10036. * Binds the frame buffer to the specified texture.
  10037. * @param texture The texture to render to or null for the default canvas
  10038. * @param faceIndex The face of the texture to render to in case of cube texture
  10039. * @param requiredWidth The width of the target to render to
  10040. * @param requiredHeight The height of the target to render to
  10041. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10042. * @param depthStencilTexture The depth stencil texture to use to render
  10043. * @param lodLevel defines le lod level to bind to the frame buffer
  10044. */
  10045. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10046. private bindUnboundFramebuffer;
  10047. /**
  10048. * Unbind the current render target texture from the webGL context
  10049. * @param texture defines the render target texture to unbind
  10050. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10051. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10052. */
  10053. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10054. /**
  10055. * Unbind a list of render target textures from the webGL context
  10056. * This is used only when drawBuffer extension or webGL2 are active
  10057. * @param textures defines the render target textures to unbind
  10058. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10059. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10060. */
  10061. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10062. /**
  10063. * Force the mipmap generation for the given render target texture
  10064. * @param texture defines the render target texture to use
  10065. */
  10066. generateMipMapsForCubemap(texture: InternalTexture): void;
  10067. /**
  10068. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10069. */
  10070. flushFramebuffer(): void;
  10071. /**
  10072. * Unbind the current render target and bind the default framebuffer
  10073. */
  10074. restoreDefaultFramebuffer(): void;
  10075. /**
  10076. * Create an uniform buffer
  10077. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10078. * @param elements defines the content of the uniform buffer
  10079. * @returns the webGL uniform buffer
  10080. */
  10081. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10082. /**
  10083. * Create a dynamic uniform buffer
  10084. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10085. * @param elements defines the content of the uniform buffer
  10086. * @returns the webGL uniform buffer
  10087. */
  10088. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10089. /**
  10090. * Update an existing uniform buffer
  10091. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10092. * @param uniformBuffer defines the target uniform buffer
  10093. * @param elements defines the content to update
  10094. * @param offset defines the offset in the uniform buffer where update should start
  10095. * @param count defines the size of the data to update
  10096. */
  10097. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10098. private _resetVertexBufferBinding;
  10099. /**
  10100. * Creates a vertex buffer
  10101. * @param data the data for the vertex buffer
  10102. * @returns the new WebGL static buffer
  10103. */
  10104. createVertexBuffer(data: DataArray): WebGLBuffer;
  10105. /**
  10106. * Creates a dynamic vertex buffer
  10107. * @param data the data for the dynamic vertex buffer
  10108. * @returns the new WebGL dynamic buffer
  10109. */
  10110. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10111. /**
  10112. * Update a dynamic index buffer
  10113. * @param indexBuffer defines the target index buffer
  10114. * @param indices defines the data to update
  10115. * @param offset defines the offset in the target index buffer where update should start
  10116. */
  10117. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10118. /**
  10119. * Updates a dynamic vertex buffer.
  10120. * @param vertexBuffer the vertex buffer to update
  10121. * @param data the data used to update the vertex buffer
  10122. * @param byteOffset the byte offset of the data
  10123. * @param byteLength the byte length of the data
  10124. */
  10125. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10126. private _resetIndexBufferBinding;
  10127. /**
  10128. * Creates a new index buffer
  10129. * @param indices defines the content of the index buffer
  10130. * @param updatable defines if the index buffer must be updatable
  10131. * @returns a new webGL buffer
  10132. */
  10133. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10134. /**
  10135. * Bind a webGL buffer to the webGL context
  10136. * @param buffer defines the buffer to bind
  10137. */
  10138. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10139. /**
  10140. * Bind an uniform buffer to the current webGL context
  10141. * @param buffer defines the buffer to bind
  10142. */
  10143. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10144. /**
  10145. * Bind a buffer to the current webGL context at a given location
  10146. * @param buffer defines the buffer to bind
  10147. * @param location defines the index where to bind the buffer
  10148. */
  10149. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10150. /**
  10151. * Bind a specific block at a given index in a specific shader program
  10152. * @param shaderProgram defines the shader program
  10153. * @param blockName defines the block name
  10154. * @param index defines the index where to bind the block
  10155. */
  10156. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10157. private bindIndexBuffer;
  10158. private bindBuffer;
  10159. /**
  10160. * update the bound buffer with the given data
  10161. * @param data defines the data to update
  10162. */
  10163. updateArrayBuffer(data: Float32Array): void;
  10164. private _vertexAttribPointer;
  10165. private _bindIndexBufferWithCache;
  10166. private _bindVertexBuffersAttributes;
  10167. /**
  10168. * Records a vertex array object
  10169. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10170. * @param vertexBuffers defines the list of vertex buffers to store
  10171. * @param indexBuffer defines the index buffer to store
  10172. * @param effect defines the effect to store
  10173. * @returns the new vertex array object
  10174. */
  10175. recordVertexArrayObject(vertexBuffers: {
  10176. [key: string]: VertexBuffer;
  10177. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10178. /**
  10179. * Bind a specific vertex array object
  10180. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10181. * @param vertexArrayObject defines the vertex array object to bind
  10182. * @param indexBuffer defines the index buffer to bind
  10183. */
  10184. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10185. /**
  10186. * Bind webGl buffers directly to the webGL context
  10187. * @param vertexBuffer defines the vertex buffer to bind
  10188. * @param indexBuffer defines the index buffer to bind
  10189. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10190. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10191. * @param effect defines the effect associated with the vertex buffer
  10192. */
  10193. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10194. private _unbindVertexArrayObject;
  10195. /**
  10196. * Bind a list of vertex buffers to the webGL context
  10197. * @param vertexBuffers defines the list of vertex buffers to bind
  10198. * @param indexBuffer defines the index buffer to bind
  10199. * @param effect defines the effect associated with the vertex buffers
  10200. */
  10201. bindBuffers(vertexBuffers: {
  10202. [key: string]: Nullable<VertexBuffer>;
  10203. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10204. /**
  10205. * Unbind all instance attributes
  10206. */
  10207. unbindInstanceAttributes(): void;
  10208. /**
  10209. * Release and free the memory of a vertex array object
  10210. * @param vao defines the vertex array object to delete
  10211. */
  10212. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10213. /** @hidden */
  10214. _releaseBuffer(buffer: WebGLBuffer): boolean;
  10215. /**
  10216. * Creates a webGL buffer to use with instanciation
  10217. * @param capacity defines the size of the buffer
  10218. * @returns the webGL buffer
  10219. */
  10220. createInstancesBuffer(capacity: number): WebGLBuffer;
  10221. /**
  10222. * Delete a webGL buffer used with instanciation
  10223. * @param buffer defines the webGL buffer to delete
  10224. */
  10225. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  10226. /**
  10227. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  10228. * @param instancesBuffer defines the webGL buffer to update and bind
  10229. * @param data defines the data to store in the buffer
  10230. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  10231. */
  10232. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  10233. /**
  10234. * Apply all cached states (depth, culling, stencil and alpha)
  10235. */
  10236. applyStates(): void;
  10237. /**
  10238. * Send a draw order
  10239. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10240. * @param indexStart defines the starting index
  10241. * @param indexCount defines the number of index to draw
  10242. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10243. */
  10244. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  10245. /**
  10246. * Draw a list of points
  10247. * @param verticesStart defines the index of first vertex to draw
  10248. * @param verticesCount defines the count of vertices to draw
  10249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10250. */
  10251. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10252. /**
  10253. * Draw a list of unindexed primitives
  10254. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10255. * @param verticesStart defines the index of first vertex to draw
  10256. * @param verticesCount defines the count of vertices to draw
  10257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10258. */
  10259. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10260. /**
  10261. * Draw a list of indexed primitives
  10262. * @param fillMode defines the primitive to use
  10263. * @param indexStart defines the starting index
  10264. * @param indexCount defines the number of index to draw
  10265. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10266. */
  10267. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  10268. /**
  10269. * Draw a list of unindexed primitives
  10270. * @param fillMode defines the primitive to use
  10271. * @param verticesStart defines the index of first vertex to draw
  10272. * @param verticesCount defines the count of vertices to draw
  10273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10274. */
  10275. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10276. private _drawMode;
  10277. /** @hidden */
  10278. _releaseEffect(effect: Effect): void;
  10279. /** @hidden */
  10280. _deleteProgram(program: WebGLProgram): void;
  10281. /**
  10282. * Create a new effect (used to store vertex/fragment shaders)
  10283. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  10284. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  10285. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  10286. * @param samplers defines an array of string used to represent textures
  10287. * @param defines defines the string containing the defines to use to compile the shaders
  10288. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  10289. * @param onCompiled defines a function to call when the effect creation is successful
  10290. * @param onError defines a function to call when the effect creation has failed
  10291. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  10292. * @returns the new Effect
  10293. */
  10294. 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;
  10295. private _compileShader;
  10296. private _compileRawShader;
  10297. /**
  10298. * Directly creates a webGL program
  10299. * @param vertexCode defines the vertex shader code to use
  10300. * @param fragmentCode defines the fragment shader code to use
  10301. * @param context defines the webGL context to use (if not set, the current one will be used)
  10302. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10303. * @returns the new webGL program
  10304. */
  10305. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10306. /**
  10307. * Creates a webGL program
  10308. * @param vertexCode defines the vertex shader code to use
  10309. * @param fragmentCode defines the fragment shader code to use
  10310. * @param defines defines the string containing the defines to use to compile the shaders
  10311. * @param context defines the webGL context to use (if not set, the current one will be used)
  10312. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10313. * @returns the new webGL program
  10314. */
  10315. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10316. private _createShaderProgram;
  10317. /**
  10318. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  10319. * @param shaderProgram defines the webGL program to use
  10320. * @param uniformsNames defines the list of uniform names
  10321. * @returns an array of webGL uniform locations
  10322. */
  10323. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  10324. /**
  10325. * Gets the lsit of active attributes for a given webGL program
  10326. * @param shaderProgram defines the webGL program to use
  10327. * @param attributesNames defines the list of attribute names to get
  10328. * @returns an array of indices indicating the offset of each attribute
  10329. */
  10330. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  10331. /**
  10332. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  10333. * @param effect defines the effect to activate
  10334. */
  10335. enableEffect(effect: Nullable<Effect>): void;
  10336. /**
  10337. * Set the value of an uniform to an array of int32
  10338. * @param uniform defines the webGL uniform location where to store the value
  10339. * @param array defines the array of int32 to store
  10340. */
  10341. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10342. /**
  10343. * Set the value of an uniform to an array of int32 (stored as vec2)
  10344. * @param uniform defines the webGL uniform location where to store the value
  10345. * @param array defines the array of int32 to store
  10346. */
  10347. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10348. /**
  10349. * Set the value of an uniform to an array of int32 (stored as vec3)
  10350. * @param uniform defines the webGL uniform location where to store the value
  10351. * @param array defines the array of int32 to store
  10352. */
  10353. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10354. /**
  10355. * Set the value of an uniform to an array of int32 (stored as vec4)
  10356. * @param uniform defines the webGL uniform location where to store the value
  10357. * @param array defines the array of int32 to store
  10358. */
  10359. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10360. /**
  10361. * Set the value of an uniform to an array of float32
  10362. * @param uniform defines the webGL uniform location where to store the value
  10363. * @param array defines the array of float32 to store
  10364. */
  10365. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10366. /**
  10367. * Set the value of an uniform to an array of float32 (stored as vec2)
  10368. * @param uniform defines the webGL uniform location where to store the value
  10369. * @param array defines the array of float32 to store
  10370. */
  10371. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10372. /**
  10373. * Set the value of an uniform to an array of float32 (stored as vec3)
  10374. * @param uniform defines the webGL uniform location where to store the value
  10375. * @param array defines the array of float32 to store
  10376. */
  10377. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10378. /**
  10379. * Set the value of an uniform to an array of float32 (stored as vec4)
  10380. * @param uniform defines the webGL uniform location where to store the value
  10381. * @param array defines the array of float32 to store
  10382. */
  10383. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10384. /**
  10385. * Set the value of an uniform to an array of number
  10386. * @param uniform defines the webGL uniform location where to store the value
  10387. * @param array defines the array of number to store
  10388. */
  10389. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10390. /**
  10391. * Set the value of an uniform to an array of number (stored as vec2)
  10392. * @param uniform defines the webGL uniform location where to store the value
  10393. * @param array defines the array of number to store
  10394. */
  10395. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10396. /**
  10397. * Set the value of an uniform to an array of number (stored as vec3)
  10398. * @param uniform defines the webGL uniform location where to store the value
  10399. * @param array defines the array of number to store
  10400. */
  10401. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10402. /**
  10403. * Set the value of an uniform to an array of number (stored as vec4)
  10404. * @param uniform defines the webGL uniform location where to store the value
  10405. * @param array defines the array of number to store
  10406. */
  10407. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10408. /**
  10409. * Set the value of an uniform to an array of float32 (stored as matrices)
  10410. * @param uniform defines the webGL uniform location where to store the value
  10411. * @param matrices defines the array of float32 to store
  10412. */
  10413. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  10414. /**
  10415. * Set the value of an uniform to a matrix
  10416. * @param uniform defines the webGL uniform location where to store the value
  10417. * @param matrix defines the matrix to store
  10418. */
  10419. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  10420. /**
  10421. * Set the value of an uniform to a matrix (3x3)
  10422. * @param uniform defines the webGL uniform location where to store the value
  10423. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  10424. */
  10425. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10426. /**
  10427. * Set the value of an uniform to a matrix (2x2)
  10428. * @param uniform defines the webGL uniform location where to store the value
  10429. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  10430. */
  10431. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10432. /**
  10433. * Set the value of an uniform to a number (int)
  10434. * @param uniform defines the webGL uniform location where to store the value
  10435. * @param value defines the int number to store
  10436. */
  10437. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10438. /**
  10439. * Set the value of an uniform to a number (float)
  10440. * @param uniform defines the webGL uniform location where to store the value
  10441. * @param value defines the float number to store
  10442. */
  10443. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10444. /**
  10445. * Set the value of an uniform to a vec2
  10446. * @param uniform defines the webGL uniform location where to store the value
  10447. * @param x defines the 1st component of the value
  10448. * @param y defines the 2nd component of the value
  10449. */
  10450. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  10451. /**
  10452. * Set the value of an uniform to a vec3
  10453. * @param uniform defines the webGL uniform location where to store the value
  10454. * @param x defines the 1st component of the value
  10455. * @param y defines the 2nd component of the value
  10456. * @param z defines the 3rd component of the value
  10457. */
  10458. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  10459. /**
  10460. * Set the value of an uniform to a boolean
  10461. * @param uniform defines the webGL uniform location where to store the value
  10462. * @param bool defines the boolean to store
  10463. */
  10464. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  10465. /**
  10466. * Set the value of an uniform to a vec4
  10467. * @param uniform defines the webGL uniform location where to store the value
  10468. * @param x defines the 1st component of the value
  10469. * @param y defines the 2nd component of the value
  10470. * @param z defines the 3rd component of the value
  10471. * @param w defines the 4th component of the value
  10472. */
  10473. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  10474. /**
  10475. * Set the value of an uniform to a Color3
  10476. * @param uniform defines the webGL uniform location where to store the value
  10477. * @param color3 defines the color to store
  10478. */
  10479. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  10480. /**
  10481. * Set the value of an uniform to a Color3 and an alpha value
  10482. * @param uniform defines the webGL uniform location where to store the value
  10483. * @param color3 defines the color to store
  10484. * @param alpha defines the alpha component to store
  10485. */
  10486. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  10487. /**
  10488. * Sets a Color4 on a uniform variable
  10489. * @param uniform defines the uniform location
  10490. * @param color4 defines the value to be set
  10491. */
  10492. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  10493. /**
  10494. * Set various states to the webGL context
  10495. * @param culling defines backface culling state
  10496. * @param zOffset defines the value to apply to zOffset (0 by default)
  10497. * @param force defines if states must be applied even if cache is up to date
  10498. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  10499. */
  10500. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  10501. /**
  10502. * Set the z offset to apply to current rendering
  10503. * @param value defines the offset to apply
  10504. */
  10505. setZOffset(value: number): void;
  10506. /**
  10507. * Gets the current value of the zOffset
  10508. * @returns the current zOffset state
  10509. */
  10510. getZOffset(): number;
  10511. /**
  10512. * Enable or disable depth buffering
  10513. * @param enable defines the state to set
  10514. */
  10515. setDepthBuffer(enable: boolean): void;
  10516. /**
  10517. * Gets a boolean indicating if depth writing is enabled
  10518. * @returns the current depth writing state
  10519. */
  10520. getDepthWrite(): boolean;
  10521. /**
  10522. * Enable or disable depth writing
  10523. * @param enable defines the state to set
  10524. */
  10525. setDepthWrite(enable: boolean): void;
  10526. /**
  10527. * Enable or disable color writing
  10528. * @param enable defines the state to set
  10529. */
  10530. setColorWrite(enable: boolean): void;
  10531. /**
  10532. * Gets a boolean indicating if color writing is enabled
  10533. * @returns the current color writing state
  10534. */
  10535. getColorWrite(): boolean;
  10536. /**
  10537. * Sets alpha constants used by some alpha blending modes
  10538. * @param r defines the red component
  10539. * @param g defines the green component
  10540. * @param b defines the blue component
  10541. * @param a defines the alpha component
  10542. */
  10543. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  10544. /**
  10545. * Sets the current alpha mode
  10546. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  10547. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  10548. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10549. */
  10550. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  10551. /**
  10552. * Gets the current alpha mode
  10553. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10554. * @returns the current alpha mode
  10555. */
  10556. getAlphaMode(): number;
  10557. /**
  10558. * Clears the list of texture accessible through engine.
  10559. * This can help preventing texture load conflict due to name collision.
  10560. */
  10561. clearInternalTexturesCache(): void;
  10562. /**
  10563. * Force the entire cache to be cleared
  10564. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  10565. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  10566. */
  10567. wipeCaches(bruteForce?: boolean): void;
  10568. /**
  10569. * Set the compressed texture format to use, based on the formats you have, and the formats
  10570. * supported by the hardware / browser.
  10571. *
  10572. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  10573. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  10574. * to API arguments needed to compressed textures. This puts the burden on the container
  10575. * generator to house the arcane code for determining these for current & future formats.
  10576. *
  10577. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  10578. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  10579. *
  10580. * Note: The result of this call is not taken into account when a texture is base64.
  10581. *
  10582. * @param formatsAvailable defines the list of those format families you have created
  10583. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  10584. *
  10585. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  10586. * @returns The extension selected.
  10587. */
  10588. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  10589. private _getSamplingParameters;
  10590. private _partialLoadImg;
  10591. private _cascadeLoadImgs;
  10592. /** @hidden */
  10593. _createTexture(): WebGLTexture;
  10594. /**
  10595. * Usually called from BABYLON.Texture.ts.
  10596. * Passed information to create a WebGLTexture
  10597. * @param urlArg defines a value which contains one of the following:
  10598. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  10599. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  10600. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  10601. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  10602. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  10603. * @param scene needed for loading to the correct scene
  10604. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  10605. * @param onLoad optional callback to be called upon successful completion
  10606. * @param onError optional callback to be called upon failure
  10607. * @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
  10608. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  10609. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  10610. * @param forcedExtension defines the extension to use to pick the right loader
  10611. * @returns a InternalTexture for assignment back into BABYLON.Texture
  10612. */
  10613. 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;
  10614. private _rescaleTexture;
  10615. /**
  10616. * Update a raw texture
  10617. * @param texture defines the texture to update
  10618. * @param data defines the data to store in the texture
  10619. * @param format defines the format of the data
  10620. * @param invertY defines if data must be stored with Y axis inverted
  10621. * @param compression defines the compression used (null by default)
  10622. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10623. */
  10624. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  10625. /**
  10626. * Creates a raw texture
  10627. * @param data defines the data to store in the texture
  10628. * @param width defines the width of the texture
  10629. * @param height defines the height of the texture
  10630. * @param format defines the format of the data
  10631. * @param generateMipMaps defines if the engine should generate the mip levels
  10632. * @param invertY defines if data must be stored with Y axis inverted
  10633. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10634. * @param compression defines the compression used (null by default)
  10635. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10636. * @returns the raw texture inside an InternalTexture
  10637. */
  10638. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  10639. private _unpackFlipYCached;
  10640. /**
  10641. * In case you are sharing the context with other applications, it might
  10642. * be interested to not cache the unpack flip y state to ensure a consistent
  10643. * value would be set.
  10644. */
  10645. enableUnpackFlipYCached: boolean;
  10646. /** @hidden */
  10647. _unpackFlipY(value: boolean): void;
  10648. /** @hidden */
  10649. _getUnpackAlignement(): number;
  10650. /**
  10651. * Creates a dynamic texture
  10652. * @param width defines the width of the texture
  10653. * @param height defines the height of the texture
  10654. * @param generateMipMaps defines if the engine should generate the mip levels
  10655. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  10656. * @returns the dynamic texture inside an InternalTexture
  10657. */
  10658. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10659. /**
  10660. * Update the sampling mode of a given texture
  10661. * @param samplingMode defines the required sampling mode
  10662. * @param texture defines the texture to update
  10663. */
  10664. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  10665. /**
  10666. * Update the content of a dynamic texture
  10667. * @param texture defines the texture to update
  10668. * @param canvas defines the canvas containing the source
  10669. * @param invertY defines if data must be stored with Y axis inverted
  10670. * @param premulAlpha defines if alpha is stored as premultiplied
  10671. * @param format defines the format of the data
  10672. */
  10673. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  10674. /**
  10675. * Update a video texture
  10676. * @param texture defines the texture to update
  10677. * @param video defines the video element to use
  10678. * @param invertY defines if data must be stored with Y axis inverted
  10679. */
  10680. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  10681. /**
  10682. * Updates a depth texture Comparison Mode and Function.
  10683. * If the comparison Function is equal to 0, the mode will be set to none.
  10684. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  10685. * @param texture The texture to set the comparison function for
  10686. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  10687. */
  10688. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  10689. private _setupDepthStencilTexture;
  10690. /**
  10691. * Creates a depth stencil texture.
  10692. * This is only available in WebGL 2 or with the depth texture extension available.
  10693. * @param size The size of face edge in the texture.
  10694. * @param options The options defining the texture.
  10695. * @returns The texture
  10696. */
  10697. createDepthStencilTexture(size: number | {
  10698. width: number;
  10699. height: number;
  10700. }, options: DepthTextureCreationOptions): InternalTexture;
  10701. /**
  10702. * Creates a depth stencil texture.
  10703. * This is only available in WebGL 2 or with the depth texture extension available.
  10704. * @param size The size of face edge in the texture.
  10705. * @param options The options defining the texture.
  10706. * @returns The texture
  10707. */
  10708. private _createDepthStencilTexture;
  10709. /**
  10710. * Creates a depth stencil cube texture.
  10711. * This is only available in WebGL 2.
  10712. * @param size The size of face edge in the cube texture.
  10713. * @param options The options defining the cube texture.
  10714. * @returns The cube texture
  10715. */
  10716. private _createDepthStencilCubeTexture;
  10717. /**
  10718. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  10719. * @param renderTarget The render target to set the frame buffer for
  10720. */
  10721. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  10722. /**
  10723. * Creates a new render target texture
  10724. * @param size defines the size of the texture
  10725. * @param options defines the options used to create the texture
  10726. * @returns a new render target texture stored in an InternalTexture
  10727. */
  10728. createRenderTargetTexture(size: number | {
  10729. width: number;
  10730. height: number;
  10731. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  10732. /**
  10733. * Create a multi render target texture
  10734. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  10735. * @param size defines the size of the texture
  10736. * @param options defines the creation options
  10737. * @returns the cube texture as an InternalTexture
  10738. */
  10739. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  10740. private _setupFramebufferDepthAttachments;
  10741. /**
  10742. * Updates the sample count of a render target texture
  10743. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  10744. * @param texture defines the texture to update
  10745. * @param samples defines the sample count to set
  10746. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  10747. */
  10748. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  10749. /**
  10750. * Update the sample count for a given multiple render target texture
  10751. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  10752. * @param textures defines the textures to update
  10753. * @param samples defines the sample count to set
  10754. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  10755. */
  10756. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  10757. /** @hidden */
  10758. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10759. /** @hidden */
  10760. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10761. /** @hidden */
  10762. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  10763. /** @hidden */
  10764. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  10765. /**
  10766. * Creates a new render target cube texture
  10767. * @param size defines the size of the texture
  10768. * @param options defines the options used to create the texture
  10769. * @returns a new render target cube texture stored in an InternalTexture
  10770. */
  10771. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10772. /**
  10773. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  10774. * @param rootUrl defines the url where the file to load is located
  10775. * @param scene defines the current scene
  10776. * @param lodScale defines scale to apply to the mip map selection
  10777. * @param lodOffset defines offset to apply to the mip map selection
  10778. * @param onLoad defines an optional callback raised when the texture is loaded
  10779. * @param onError defines an optional callback raised if there is an issue to load the texture
  10780. * @param format defines the format of the data
  10781. * @param forcedExtension defines the extension to use to pick the right loader
  10782. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  10783. * @returns the cube texture as an InternalTexture
  10784. */
  10785. 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;
  10786. /**
  10787. * Creates a cube texture
  10788. * @param rootUrl defines the url where the files to load is located
  10789. * @param scene defines the current scene
  10790. * @param files defines the list of files to load (1 per face)
  10791. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10792. * @param onLoad defines an optional callback raised when the texture is loaded
  10793. * @param onError defines an optional callback raised if there is an issue to load the texture
  10794. * @param format defines the format of the data
  10795. * @param forcedExtension defines the extension to use to pick the right loader
  10796. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10797. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10798. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10799. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10800. * @returns the cube texture as an InternalTexture
  10801. */
  10802. 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;
  10803. /**
  10804. * @hidden
  10805. */
  10806. _setCubeMapTextureParams(loadMipmap: boolean): void;
  10807. /**
  10808. * Update a raw cube texture
  10809. * @param texture defines the texture to udpdate
  10810. * @param data defines the data to store
  10811. * @param format defines the data format
  10812. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10813. * @param invertY defines if data must be stored with Y axis inverted
  10814. * @param compression defines the compression used (null by default)
  10815. * @param level defines which level of the texture to update
  10816. */
  10817. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  10818. /**
  10819. * Creates a new raw cube texture
  10820. * @param data defines the array of data to use to create each face
  10821. * @param size defines the size of the textures
  10822. * @param format defines the format of the data
  10823. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  10824. * @param generateMipMaps defines if the engine should generate the mip levels
  10825. * @param invertY defines if data must be stored with Y axis inverted
  10826. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10827. * @param compression defines the compression used (null by default)
  10828. * @returns the cube texture as an InternalTexture
  10829. */
  10830. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  10831. /**
  10832. * Creates a new raw cube texture from a specified url
  10833. * @param url defines the url where the data is located
  10834. * @param scene defines the current scene
  10835. * @param size defines the size of the textures
  10836. * @param format defines the format of the data
  10837. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  10838. * @param noMipmap defines if the engine should avoid generating the mip levels
  10839. * @param callback defines a callback used to extract texture data from loaded data
  10840. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10841. * @param onLoad defines a callback called when texture is loaded
  10842. * @param onError defines a callback called if there is an error
  10843. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10844. * @param invertY defines if data must be stored with Y axis inverted
  10845. * @returns the cube texture as an InternalTexture
  10846. */
  10847. 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;
  10848. /**
  10849. * Update a raw 3D texture
  10850. * @param texture defines the texture to update
  10851. * @param data defines the data to store
  10852. * @param format defines the data format
  10853. * @param invertY defines if data must be stored with Y axis inverted
  10854. * @param compression defines the used compression (can be null)
  10855. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10856. */
  10857. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  10858. /**
  10859. * Creates a new raw 3D texture
  10860. * @param data defines the data used to create the texture
  10861. * @param width defines the width of the texture
  10862. * @param height defines the height of the texture
  10863. * @param depth defines the depth of the texture
  10864. * @param format defines the format of the texture
  10865. * @param generateMipMaps defines if the engine must generate mip levels
  10866. * @param invertY defines if data must be stored with Y axis inverted
  10867. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  10868. * @param compression defines the compressed used (can be null)
  10869. * @param textureType defines the compressed used (can be null)
  10870. * @returns a new raw 3D texture (stored in an InternalTexture)
  10871. */
  10872. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  10873. private _prepareWebGLTextureContinuation;
  10874. private _prepareWebGLTexture;
  10875. private _convertRGBtoRGBATextureData;
  10876. /** @hidden */
  10877. _releaseFramebufferObjects(texture: InternalTexture): void;
  10878. /** @hidden */
  10879. _releaseTexture(texture: InternalTexture): void;
  10880. private setProgram;
  10881. private _boundUniforms;
  10882. /**
  10883. * Binds an effect to the webGL context
  10884. * @param effect defines the effect to bind
  10885. */
  10886. bindSamplers(effect: Effect): void;
  10887. private _moveBoundTextureOnTop;
  10888. private _getCorrectTextureChannel;
  10889. private _linkTrackers;
  10890. private _removeDesignatedSlot;
  10891. private _activateCurrentTexture;
  10892. /** @hidden */
  10893. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  10894. /** @hidden */
  10895. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  10896. /**
  10897. * Sets a texture to the webGL context from a postprocess
  10898. * @param channel defines the channel to use
  10899. * @param postProcess defines the source postprocess
  10900. */
  10901. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  10902. /**
  10903. * Binds the output of the passed in post process to the texture channel specified
  10904. * @param channel The channel the texture should be bound to
  10905. * @param postProcess The post process which's output should be bound
  10906. */
  10907. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  10908. /**
  10909. * Unbind all textures from the webGL context
  10910. */
  10911. unbindAllTextures(): void;
  10912. /**
  10913. * Sets a texture to the according uniform.
  10914. * @param channel The texture channel
  10915. * @param uniform The uniform to set
  10916. * @param texture The texture to apply
  10917. */
  10918. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  10919. /**
  10920. * Sets a depth stencil texture from a render target to the according uniform.
  10921. * @param channel The texture channel
  10922. * @param uniform The uniform to set
  10923. * @param texture The render target texture containing the depth stencil texture to apply
  10924. */
  10925. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  10926. private _bindSamplerUniformToChannel;
  10927. private _getTextureWrapMode;
  10928. private _setTexture;
  10929. /**
  10930. * Sets an array of texture to the webGL context
  10931. * @param channel defines the channel where the texture array must be set
  10932. * @param uniform defines the associated uniform location
  10933. * @param textures defines the array of textures to bind
  10934. */
  10935. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  10936. /** @hidden */
  10937. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  10938. private _setTextureParameterFloat;
  10939. private _setTextureParameterInteger;
  10940. /**
  10941. * Reads pixels from the current frame buffer. Please note that this function can be slow
  10942. * @param x defines the x coordinate of the rectangle where pixels must be read
  10943. * @param y defines the y coordinate of the rectangle where pixels must be read
  10944. * @param width defines the width of the rectangle where pixels must be read
  10945. * @param height defines the height of the rectangle where pixels must be read
  10946. * @returns a Uint8Array containing RGBA colors
  10947. */
  10948. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  10949. /**
  10950. * Add an externaly attached data from its key.
  10951. * This method call will fail and return false, if such key already exists.
  10952. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  10953. * @param key the unique key that identifies the data
  10954. * @param data the data object to associate to the key for this Engine instance
  10955. * @return true if no such key were already present and the data was added successfully, false otherwise
  10956. */
  10957. addExternalData<T>(key: string, data: T): boolean;
  10958. /**
  10959. * Get an externaly attached data from its key
  10960. * @param key the unique key that identifies the data
  10961. * @return the associated data, if present (can be null), or undefined if not present
  10962. */
  10963. getExternalData<T>(key: string): T;
  10964. /**
  10965. * Get an externaly attached data from its key, create it using a factory if it's not already present
  10966. * @param key the unique key that identifies the data
  10967. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  10968. * @return the associated data, can be null if the factory returned null.
  10969. */
  10970. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  10971. /**
  10972. * Remove an externaly attached data from the Engine instance
  10973. * @param key the unique key that identifies the data
  10974. * @return true if the data was successfully removed, false if it doesn't exist
  10975. */
  10976. removeExternalData(key: string): boolean;
  10977. /**
  10978. * Unbind all vertex attributes from the webGL context
  10979. */
  10980. unbindAllAttributes(): void;
  10981. /**
  10982. * 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
  10983. */
  10984. releaseEffects(): void;
  10985. /**
  10986. * Dispose and release all associated resources
  10987. */
  10988. dispose(): void;
  10989. /**
  10990. * Display the loading screen
  10991. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  10992. */
  10993. displayLoadingUI(): void;
  10994. /**
  10995. * Hide the loading screen
  10996. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  10997. */
  10998. hideLoadingUI(): void;
  10999. /**
  11000. * Gets the current loading screen object
  11001. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11002. */
  11003. /**
  11004. * Sets the current loading screen object
  11005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11006. */
  11007. loadingScreen: ILoadingScreen;
  11008. /**
  11009. * Sets the current loading screen text
  11010. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11011. */
  11012. loadingUIText: string;
  11013. /**
  11014. * Sets the current loading screen background color
  11015. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11016. */
  11017. loadingUIBackgroundColor: string;
  11018. /**
  11019. * Attach a new callback raised when context lost event is fired
  11020. * @param callback defines the callback to call
  11021. */
  11022. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11023. /**
  11024. * Attach a new callback raised when context restored event is fired
  11025. * @param callback defines the callback to call
  11026. */
  11027. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11028. /**
  11029. * Gets the source code of the vertex shader associated with a specific webGL program
  11030. * @param program defines the program to use
  11031. * @returns a string containing the source code of the vertex shader associated with the program
  11032. */
  11033. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11034. /**
  11035. * Gets the source code of the fragment shader associated with a specific webGL program
  11036. * @param program defines the program to use
  11037. * @returns a string containing the source code of the fragment shader associated with the program
  11038. */
  11039. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11040. /**
  11041. * Get the current error code of the webGL context
  11042. * @returns the error code
  11043. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11044. */
  11045. getError(): number;
  11046. /**
  11047. * Gets the current framerate
  11048. * @returns a number representing the framerate
  11049. */
  11050. getFps(): number;
  11051. /**
  11052. * Gets the time spent between current and previous frame
  11053. * @returns a number representing the delta time in ms
  11054. */
  11055. getDeltaTime(): number;
  11056. private _measureFps;
  11057. /** @hidden */
  11058. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11059. private _canRenderToFloatFramebuffer;
  11060. private _canRenderToHalfFloatFramebuffer;
  11061. private _canRenderToFramebuffer;
  11062. /** @hidden */
  11063. _getWebGLTextureType(type: number): number;
  11064. private _getInternalFormat;
  11065. /** @hidden */
  11066. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11067. /** @hidden */
  11068. _getRGBAMultiSampleBufferFormat(type: number): number;
  11069. /** @hidden */
  11070. _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;
  11071. /** @hidden */
  11072. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11073. private _partialLoadFile;
  11074. private _cascadeLoadFiles;
  11075. /**
  11076. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11077. * @returns true if the engine can be created
  11078. * @ignorenaming
  11079. */
  11080. static isSupported(): boolean;
  11081. }
  11082. }
  11083. declare module BABYLON {
  11084. class NullEngineOptions {
  11085. renderWidth: number;
  11086. renderHeight: number;
  11087. textureSize: number;
  11088. deterministicLockstep: boolean;
  11089. lockstepMaxSteps: number;
  11090. }
  11091. /**
  11092. * The null engine class provides support for headless version of babylon.js.
  11093. * This can be used in server side scenario or for testing purposes
  11094. */
  11095. class NullEngine extends Engine {
  11096. private _options;
  11097. isDeterministicLockStep(): boolean;
  11098. getLockstepMaxSteps(): number;
  11099. getHardwareScalingLevel(): number;
  11100. constructor(options?: NullEngineOptions);
  11101. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11102. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11103. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11104. getRenderWidth(useScreen?: boolean): number;
  11105. getRenderHeight(useScreen?: boolean): number;
  11106. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11107. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11108. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11109. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11110. bindSamplers(effect: Effect): void;
  11111. enableEffect(effect: Effect): void;
  11112. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11113. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11114. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11115. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11116. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11117. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11118. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11119. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11120. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11121. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11122. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11123. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11124. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11125. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11126. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11127. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11128. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11129. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11130. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11131. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11132. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11133. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11134. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11135. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11136. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11137. bindBuffers(vertexBuffers: {
  11138. [key: string]: VertexBuffer;
  11139. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11140. wipeCaches(bruteForce?: boolean): void;
  11141. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11142. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11143. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11144. /** @hidden */
  11145. _createTexture(): WebGLTexture;
  11146. /** @hidden */
  11147. _releaseTexture(texture: InternalTexture): void;
  11148. 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;
  11149. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11150. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11151. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11152. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11153. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11154. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11155. /**
  11156. * @hidden
  11157. * Get the current error code of the webGL context
  11158. * @returns the error code
  11159. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11160. */
  11161. getError(): number;
  11162. /** @hidden */
  11163. _getUnpackAlignement(): number;
  11164. /** @hidden */
  11165. _unpackFlipY(value: boolean): void;
  11166. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11167. /**
  11168. * Updates a dynamic vertex buffer.
  11169. * @param vertexBuffer the vertex buffer to update
  11170. * @param data the data used to update the vertex buffer
  11171. * @param byteOffset the byte offset of the data (optional)
  11172. * @param byteLength the byte length of the data (optional)
  11173. */
  11174. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11175. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11176. /** @hidden */
  11177. _bindTexture(channel: number, texture: InternalTexture): void;
  11178. /** @hidden */
  11179. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11180. releaseEffects(): void;
  11181. displayLoadingUI(): void;
  11182. hideLoadingUI(): void;
  11183. /** @hidden */
  11184. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11185. /** @hidden */
  11186. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11187. /** @hidden */
  11188. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11189. /** @hidden */
  11190. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11191. }
  11192. }
  11193. interface WebGLRenderingContext {
  11194. readonly RASTERIZER_DISCARD: number;
  11195. readonly DEPTH_COMPONENT24: number;
  11196. readonly TEXTURE_3D: number;
  11197. readonly TEXTURE_2D_ARRAY: number;
  11198. readonly TEXTURE_COMPARE_FUNC: number;
  11199. readonly TEXTURE_COMPARE_MODE: number;
  11200. readonly COMPARE_REF_TO_TEXTURE: number;
  11201. readonly TEXTURE_WRAP_R: number;
  11202. readonly HALF_FLOAT: number;
  11203. readonly RGB8: number;
  11204. readonly RED_INTEGER: number;
  11205. readonly RG_INTEGER: number;
  11206. readonly RGB_INTEGER: number;
  11207. readonly RGBA_INTEGER: number;
  11208. readonly R8_SNORM: number;
  11209. readonly RG8_SNORM: number;
  11210. readonly RGB8_SNORM: number;
  11211. readonly RGBA8_SNORM: number;
  11212. readonly R8I: number;
  11213. readonly RG8I: number;
  11214. readonly RGB8I: number;
  11215. readonly RGBA8I: number;
  11216. readonly R8UI: number;
  11217. readonly RG8UI: number;
  11218. readonly RGB8UI: number;
  11219. readonly RGBA8UI: number;
  11220. readonly R16I: number;
  11221. readonly RG16I: number;
  11222. readonly RGB16I: number;
  11223. readonly RGBA16I: number;
  11224. readonly R16UI: number;
  11225. readonly RG16UI: number;
  11226. readonly RGB16UI: number;
  11227. readonly RGBA16UI: number;
  11228. readonly R32I: number;
  11229. readonly RG32I: number;
  11230. readonly RGB32I: number;
  11231. readonly RGBA32I: number;
  11232. readonly R32UI: number;
  11233. readonly RG32UI: number;
  11234. readonly RGB32UI: number;
  11235. readonly RGBA32UI: number;
  11236. readonly RGB10_A2UI: number;
  11237. readonly R11F_G11F_B10F: number;
  11238. readonly RGB9_E5: number;
  11239. readonly RGB10_A2: number;
  11240. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  11241. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  11242. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  11243. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  11244. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  11245. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  11246. 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;
  11247. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  11248. readonly TRANSFORM_FEEDBACK: number;
  11249. readonly INTERLEAVED_ATTRIBS: number;
  11250. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  11251. createTransformFeedback(): WebGLTransformFeedback;
  11252. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  11253. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  11254. beginTransformFeedback(primitiveMode: number): void;
  11255. endTransformFeedback(): void;
  11256. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  11257. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11258. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11259. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11260. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  11261. }
  11262. interface ImageBitmap {
  11263. readonly width: number;
  11264. readonly height: number;
  11265. close(): void;
  11266. }
  11267. interface WebGLQuery extends WebGLObject {
  11268. }
  11269. declare var WebGLQuery: {
  11270. prototype: WebGLQuery;
  11271. new (): WebGLQuery;
  11272. };
  11273. interface WebGLSampler extends WebGLObject {
  11274. }
  11275. declare var WebGLSampler: {
  11276. prototype: WebGLSampler;
  11277. new (): WebGLSampler;
  11278. };
  11279. interface WebGLSync extends WebGLObject {
  11280. }
  11281. declare var WebGLSync: {
  11282. prototype: WebGLSync;
  11283. new (): WebGLSync;
  11284. };
  11285. interface WebGLTransformFeedback extends WebGLObject {
  11286. }
  11287. declare var WebGLTransformFeedback: {
  11288. prototype: WebGLTransformFeedback;
  11289. new (): WebGLTransformFeedback;
  11290. };
  11291. interface WebGLVertexArrayObject extends WebGLObject {
  11292. }
  11293. declare var WebGLVertexArrayObject: {
  11294. prototype: WebGLVertexArrayObject;
  11295. new (): WebGLVertexArrayObject;
  11296. };
  11297. declare module BABYLON {
  11298. /**
  11299. * Class used to store bounding box information
  11300. */
  11301. class BoundingBox implements ICullable {
  11302. /**
  11303. * Gets the 8 vectors representing the bounding box in local space
  11304. */
  11305. vectors: Vector3[];
  11306. /**
  11307. * Gets the center of the bounding box in local space
  11308. */
  11309. center: Vector3;
  11310. /**
  11311. * Gets the center of the bounding box in world space
  11312. */
  11313. centerWorld: Vector3;
  11314. /**
  11315. * Gets the extend size in local space
  11316. */
  11317. extendSize: Vector3;
  11318. /**
  11319. * Gets the extend size in world space
  11320. */
  11321. extendSizeWorld: Vector3;
  11322. /**
  11323. * Gets the OBB (object bounding box) directions
  11324. */
  11325. directions: Vector3[];
  11326. /**
  11327. * Gets the 8 vectors representing the bounding box in world space
  11328. */
  11329. vectorsWorld: Vector3[];
  11330. /**
  11331. * Gets the minimum vector in world space
  11332. */
  11333. minimumWorld: Vector3;
  11334. /**
  11335. * Gets the maximum vector in world space
  11336. */
  11337. maximumWorld: Vector3;
  11338. /**
  11339. * Gets the minimum vector in local space
  11340. */
  11341. minimum: Vector3;
  11342. /**
  11343. * Gets the maximum vector in local space
  11344. */
  11345. maximum: Vector3;
  11346. private _worldMatrix;
  11347. /**
  11348. * @hidden
  11349. */
  11350. _tag: number;
  11351. /**
  11352. * Creates a new bounding box
  11353. * @param min defines the minimum vector (in local space)
  11354. * @param max defines the maximum vector (in local space)
  11355. */
  11356. constructor(min: Vector3, max: Vector3);
  11357. /**
  11358. * Recreates the entire bounding box from scratch
  11359. * @param min defines the new minimum vector (in local space)
  11360. * @param max defines the new maximum vector (in local space)
  11361. */
  11362. reConstruct(min: Vector3, max: Vector3): void;
  11363. /**
  11364. * Scale the current bounding box by applying a scale factor
  11365. * @param factor defines the scale factor to apply
  11366. * @returns the current bounding box
  11367. */
  11368. scale(factor: number): BoundingBox;
  11369. /**
  11370. * Gets the world matrix of the bounding box
  11371. * @returns a matrix
  11372. */
  11373. getWorldMatrix(): Matrix;
  11374. /**
  11375. * Sets the world matrix stored in the bounding box
  11376. * @param matrix defines the matrix to store
  11377. * @returns current bounding box
  11378. */
  11379. setWorldMatrix(matrix: Matrix): BoundingBox;
  11380. /** @hidden */
  11381. _update(world: Matrix): void;
  11382. /**
  11383. * Tests if the bounding box is intersecting the frustum planes
  11384. * @param frustumPlanes defines the frustum planes to test
  11385. * @returns true if there is an intersection
  11386. */
  11387. isInFrustum(frustumPlanes: Plane[]): boolean;
  11388. /**
  11389. * Tests if the bounding box is entirely inside the frustum planes
  11390. * @param frustumPlanes defines the frustum planes to test
  11391. * @returns true if there is an inclusion
  11392. */
  11393. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11394. /**
  11395. * Tests if a point is inside the bounding box
  11396. * @param point defines the point to test
  11397. * @returns true if the point is inside the bounding box
  11398. */
  11399. intersectsPoint(point: Vector3): boolean;
  11400. /**
  11401. * Tests if the bounding box intersects with a bounding sphere
  11402. * @param sphere defines the sphere to test
  11403. * @returns true if there is an intersection
  11404. */
  11405. intersectsSphere(sphere: BoundingSphere): boolean;
  11406. /**
  11407. * Tests if the bounding box intersects with a box defined by a min and max vectors
  11408. * @param min defines the min vector to use
  11409. * @param max defines the max vector to use
  11410. * @returns true if there is an intersection
  11411. */
  11412. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  11413. /**
  11414. * Tests if two bounding boxes are intersections
  11415. * @param box0 defines the first box to test
  11416. * @param box1 defines the second box to test
  11417. * @returns true if there is an intersection
  11418. */
  11419. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  11420. /**
  11421. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  11422. * @param minPoint defines the minimum vector of the bounding box
  11423. * @param maxPoint defines the maximum vector of the bounding box
  11424. * @param sphereCenter defines the sphere center
  11425. * @param sphereRadius defines the sphere radius
  11426. * @returns true if there is an intersection
  11427. */
  11428. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  11429. /**
  11430. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  11431. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  11432. * @param frustumPlanes defines the frustum planes to test
  11433. * @return true if there is an inclusion
  11434. */
  11435. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  11436. /**
  11437. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  11438. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  11439. * @param frustumPlanes defines the frustum planes to test
  11440. * @return true if there is an intersection
  11441. */
  11442. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  11443. }
  11444. }
  11445. declare module BABYLON {
  11446. /**
  11447. * Interface for cullable objects
  11448. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  11449. */
  11450. interface ICullable {
  11451. /**
  11452. * Checks if the object or part of the object is in the frustum
  11453. * @param frustumPlanes Camera near/planes
  11454. * @returns true if the object is in frustum otherwise false
  11455. */
  11456. isInFrustum(frustumPlanes: Plane[]): boolean;
  11457. /**
  11458. * Checks if a cullable object (mesh...) is in the camera frustum
  11459. * Unlike isInFrustum this cheks the full bounding box
  11460. * @param frustumPlanes Camera near/planes
  11461. * @returns true if the object is in frustum otherwise false
  11462. */
  11463. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11464. }
  11465. /**
  11466. * Info for a bounding data of a mesh
  11467. */
  11468. class BoundingInfo implements ICullable {
  11469. /**
  11470. * Bounding box for the mesh
  11471. */
  11472. boundingBox: BoundingBox;
  11473. /**
  11474. * Bounding sphere for the mesh
  11475. */
  11476. boundingSphere: BoundingSphere;
  11477. private _isLocked;
  11478. /**
  11479. * Constructs bounding info
  11480. * @param minimum min vector of the bounding box/sphere
  11481. * @param maximum max vector of the bounding box/sphere
  11482. */
  11483. constructor(minimum: Vector3, maximum: Vector3);
  11484. /**
  11485. * min vector of the bounding box/sphere
  11486. */
  11487. readonly minimum: Vector3;
  11488. /**
  11489. * max vector of the bounding box/sphere
  11490. */
  11491. readonly maximum: Vector3;
  11492. /**
  11493. * If the info is locked and won't be updated to avoid perf overhead
  11494. */
  11495. isLocked: boolean;
  11496. /**
  11497. * Updates the boudning sphere and box
  11498. * @param world world matrix to be used to update
  11499. */
  11500. update(world: Matrix): void;
  11501. /**
  11502. * Recreate the bounding info to be centered around a specific point given a specific extend.
  11503. * @param center New center of the bounding info
  11504. * @param extend New extend of the bounding info
  11505. * @returns the current bounding info
  11506. */
  11507. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  11508. /**
  11509. * Scale the current bounding info by applying a scale factor
  11510. * @param factor defines the scale factor to apply
  11511. * @returns the current bounding info
  11512. */
  11513. scale(factor: number): BoundingInfo;
  11514. /**
  11515. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  11516. * @param frustumPlanes defines the frustum to test
  11517. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  11518. * @returns true if the bounding info is in the frustum planes
  11519. */
  11520. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  11521. /**
  11522. * Gets the world distance between the min and max points of the bounding box
  11523. */
  11524. readonly diagonalLength: number;
  11525. /**
  11526. * Checks if a cullable object (mesh...) is in the camera frustum
  11527. * Unlike isInFrustum this cheks the full bounding box
  11528. * @param frustumPlanes Camera near/planes
  11529. * @returns true if the object is in frustum otherwise false
  11530. */
  11531. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  11532. /** @hidden */
  11533. _checkCollision(collider: Collider): boolean;
  11534. /**
  11535. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  11536. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  11537. * @param point the point to check intersection with
  11538. * @returns if the point intersects
  11539. */
  11540. intersectsPoint(point: Vector3): boolean;
  11541. /**
  11542. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  11543. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  11544. * @param boundingInfo the bounding info to check intersection with
  11545. * @param precise if the intersection should be done using OBB
  11546. * @returns if the bounding info intersects
  11547. */
  11548. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  11549. }
  11550. }
  11551. declare module BABYLON {
  11552. /**
  11553. * Class used to store bounding sphere information
  11554. */
  11555. class BoundingSphere {
  11556. /**
  11557. * Gets the center of the bounding sphere in local space
  11558. */
  11559. center: Vector3;
  11560. /**
  11561. * Radius of the bounding sphere in local space
  11562. */
  11563. radius: number;
  11564. /**
  11565. * Gets the center of the bounding sphere in world space
  11566. */
  11567. centerWorld: Vector3;
  11568. /**
  11569. * Radius of the bounding sphere in world space
  11570. */
  11571. radiusWorld: number;
  11572. /**
  11573. * Gets the minimum vector in local space
  11574. */
  11575. minimum: Vector3;
  11576. /**
  11577. * Gets the maximum vector in local space
  11578. */
  11579. maximum: Vector3;
  11580. /**
  11581. * Creates a new bounding sphere
  11582. * @param min defines the minimum vector (in local space)
  11583. * @param max defines the maximum vector (in local space)
  11584. */
  11585. constructor(min: Vector3, max: Vector3);
  11586. /**
  11587. * Recreates the entire bounding sphere from scratch
  11588. * @param min defines the new minimum vector (in local space)
  11589. * @param max defines the new maximum vector (in local space)
  11590. */
  11591. reConstruct(min: Vector3, max: Vector3): void;
  11592. /**
  11593. * Scale the current bounding sphere by applying a scale factor
  11594. * @param factor defines the scale factor to apply
  11595. * @returns the current bounding box
  11596. */
  11597. scale(factor: number): BoundingSphere;
  11598. /** @hidden */
  11599. _update(world: Matrix): void;
  11600. /**
  11601. * Tests if the bounding sphere is intersecting the frustum planes
  11602. * @param frustumPlanes defines the frustum planes to test
  11603. * @returns true if there is an intersection
  11604. */
  11605. isInFrustum(frustumPlanes: Plane[]): boolean;
  11606. /**
  11607. * Tests if a point is inside the bounding sphere
  11608. * @param point defines the point to test
  11609. * @returns true if the point is inside the bounding sphere
  11610. */
  11611. intersectsPoint(point: Vector3): boolean;
  11612. /**
  11613. * Checks if two sphere intersct
  11614. * @param sphere0 sphere 0
  11615. * @param sphere1 sphere 1
  11616. * @returns true if the speres intersect
  11617. */
  11618. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  11619. }
  11620. }
  11621. declare module BABYLON {
  11622. class Ray {
  11623. origin: Vector3;
  11624. direction: Vector3;
  11625. length: number;
  11626. private _edge1;
  11627. private _edge2;
  11628. private _pvec;
  11629. private _tvec;
  11630. private _qvec;
  11631. private _tmpRay;
  11632. constructor(origin: Vector3, direction: Vector3, length?: number);
  11633. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  11634. intersectsBox(box: BoundingBox): boolean;
  11635. intersectsSphere(sphere: BoundingSphere): boolean;
  11636. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  11637. intersectsPlane(plane: Plane): Nullable<number>;
  11638. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  11639. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11640. private _comparePickingInfo;
  11641. private static smallnum;
  11642. private static rayl;
  11643. /**
  11644. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11645. * @param sega the first point of the segment to test the intersection against
  11646. * @param segb the second point of the segment to test the intersection against
  11647. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11648. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11649. */
  11650. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  11651. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  11652. static Zero(): Ray;
  11653. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  11654. /**
  11655. * 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
  11656. * transformed to the given world matrix.
  11657. * @param origin The origin point
  11658. * @param end The end point
  11659. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11660. */
  11661. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  11662. static Transform(ray: Ray, matrix: Matrix): Ray;
  11663. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  11664. }
  11665. }
  11666. declare module BABYLON {
  11667. /**
  11668. * Gather the list of keyboard event types as constants.
  11669. */
  11670. class KeyboardEventTypes {
  11671. /**
  11672. * The keydown event is fired when a key becomes active (pressed).
  11673. */
  11674. static readonly KEYDOWN: number;
  11675. /**
  11676. * The keyup event is fired when a key has been released.
  11677. */
  11678. static readonly KEYUP: number;
  11679. }
  11680. /**
  11681. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11682. */
  11683. class KeyboardInfo {
  11684. /**
  11685. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11686. */
  11687. type: number;
  11688. /**
  11689. * Defines the related dom event
  11690. */
  11691. event: KeyboardEvent;
  11692. /**
  11693. * Instantiates a new keyboard info.
  11694. * This class is used to store keyboard related info for the onKeyboardObservable event.
  11695. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11696. * @param event Defines the related dom event
  11697. */
  11698. constructor(
  11699. /**
  11700. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11701. */
  11702. type: number,
  11703. /**
  11704. * Defines the related dom event
  11705. */
  11706. event: KeyboardEvent);
  11707. }
  11708. /**
  11709. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11710. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  11711. */
  11712. class KeyboardInfoPre extends KeyboardInfo {
  11713. /**
  11714. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11715. */
  11716. type: number;
  11717. /**
  11718. * Defines the related dom event
  11719. */
  11720. event: KeyboardEvent;
  11721. /**
  11722. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  11723. */
  11724. skipOnPointerObservable: boolean;
  11725. /**
  11726. * Instantiates a new keyboard pre info.
  11727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  11728. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  11729. * @param event Defines the related dom event
  11730. */
  11731. constructor(
  11732. /**
  11733. * Defines the type of event (BABYLON.KeyboardEventTypes)
  11734. */
  11735. type: number,
  11736. /**
  11737. * Defines the related dom event
  11738. */
  11739. event: KeyboardEvent);
  11740. }
  11741. }
  11742. declare module BABYLON {
  11743. /**
  11744. * Gather the list of pointer event types as constants.
  11745. */
  11746. class PointerEventTypes {
  11747. /**
  11748. * 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.
  11749. */
  11750. static readonly POINTERDOWN: number;
  11751. /**
  11752. * The pointerup event is fired when a pointer is no longer active.
  11753. */
  11754. static readonly POINTERUP: number;
  11755. /**
  11756. * The pointermove event is fired when a pointer changes coordinates.
  11757. */
  11758. static readonly POINTERMOVE: number;
  11759. /**
  11760. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11761. */
  11762. static readonly POINTERWHEEL: number;
  11763. /**
  11764. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11765. */
  11766. static readonly POINTERPICK: number;
  11767. /**
  11768. * The pointertap event is fired when a the object has been touched and released without drag.
  11769. */
  11770. static readonly POINTERTAP: number;
  11771. /**
  11772. * The pointertap event is fired when a the object has been touched and released twice without drag.
  11773. */
  11774. static readonly POINTERDOUBLETAP: number;
  11775. }
  11776. /**
  11777. * Base class of pointer info types.
  11778. */
  11779. class PointerInfoBase {
  11780. /**
  11781. * Defines the type of event (BABYLON.PointerEventTypes)
  11782. */
  11783. type: number;
  11784. /**
  11785. * Defines the related dom event
  11786. */
  11787. event: PointerEvent | MouseWheelEvent;
  11788. /**
  11789. * Instantiates the base class of pointers info.
  11790. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11791. * @param event Defines the related dom event
  11792. */
  11793. constructor(
  11794. /**
  11795. * Defines the type of event (BABYLON.PointerEventTypes)
  11796. */
  11797. type: number,
  11798. /**
  11799. * Defines the related dom event
  11800. */
  11801. event: PointerEvent | MouseWheelEvent);
  11802. }
  11803. /**
  11804. * This class is used to store pointer related info for the onPrePointerObservable event.
  11805. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11806. */
  11807. class PointerInfoPre extends PointerInfoBase {
  11808. /**
  11809. * Ray from a pointer if availible (eg. 6dof controller)
  11810. */
  11811. ray: Nullable<Ray>;
  11812. /**
  11813. * Defines the local position of the pointer on the canvas.
  11814. */
  11815. localPosition: Vector2;
  11816. /**
  11817. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11818. */
  11819. skipOnPointerObservable: boolean;
  11820. /**
  11821. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11822. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11823. * @param event Defines the related dom event
  11824. * @param localX Defines the local x coordinates of the pointer when the event occured
  11825. * @param localY Defines the local y coordinates of the pointer when the event occured
  11826. */
  11827. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11828. }
  11829. /**
  11830. * This type contains all the data related to a pointer event in Babylon.js.
  11831. * 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.
  11832. */
  11833. class PointerInfo extends PointerInfoBase {
  11834. /**
  11835. * Defines the picking info associated to the info (if any)\
  11836. */
  11837. pickInfo: Nullable<PickingInfo>;
  11838. /**
  11839. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11840. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param pickInfo Defines the picking info associated to the info (if any)\
  11843. */
  11844. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11845. /**
  11846. * Defines the picking info associated to the info (if any)\
  11847. */
  11848. pickInfo: Nullable<PickingInfo>);
  11849. }
  11850. }
  11851. declare module BABYLON {
  11852. /**
  11853. * Represents a gamepad control stick position
  11854. */
  11855. class StickValues {
  11856. /**
  11857. * The x component of the control stick
  11858. */
  11859. x: number;
  11860. /**
  11861. * The y component of the control stick
  11862. */
  11863. y: number;
  11864. /**
  11865. * Initializes the gamepad x and y control stick values
  11866. * @param x The x component of the gamepad control stick value
  11867. * @param y The y component of the gamepad control stick value
  11868. */
  11869. constructor(
  11870. /**
  11871. * The x component of the control stick
  11872. */
  11873. x: number,
  11874. /**
  11875. * The y component of the control stick
  11876. */
  11877. y: number);
  11878. }
  11879. /**
  11880. * An interface which manages callbacks for gamepad button changes
  11881. */
  11882. interface GamepadButtonChanges {
  11883. /**
  11884. * Called when a gamepad has been changed
  11885. */
  11886. changed: boolean;
  11887. /**
  11888. * Called when a gamepad press event has been triggered
  11889. */
  11890. pressChanged: boolean;
  11891. /**
  11892. * Called when a touch event has been triggered
  11893. */
  11894. touchChanged: boolean;
  11895. /**
  11896. * Called when a value has changed
  11897. */
  11898. valueChanged: boolean;
  11899. }
  11900. /**
  11901. * Represents a gamepad
  11902. */
  11903. class Gamepad {
  11904. /**
  11905. * The id of the gamepad
  11906. */
  11907. id: string;
  11908. /**
  11909. * The index of the gamepad
  11910. */
  11911. index: number;
  11912. /**
  11913. * The browser gamepad
  11914. */
  11915. browserGamepad: any;
  11916. /**
  11917. * Specifies what type of gamepad this represents
  11918. */
  11919. type: number;
  11920. private _leftStick;
  11921. private _rightStick;
  11922. /** @hidden */
  11923. _isConnected: boolean;
  11924. private _leftStickAxisX;
  11925. private _leftStickAxisY;
  11926. private _rightStickAxisX;
  11927. private _rightStickAxisY;
  11928. /**
  11929. * Triggered when the left control stick has been changed
  11930. */
  11931. private _onleftstickchanged;
  11932. /**
  11933. * Triggered when the right control stick has been changed
  11934. */
  11935. private _onrightstickchanged;
  11936. /**
  11937. * Represents a gamepad controller
  11938. */
  11939. static GAMEPAD: number;
  11940. /**
  11941. * Represents a generic controller
  11942. */
  11943. static GENERIC: number;
  11944. /**
  11945. * Represents an XBox controller
  11946. */
  11947. static XBOX: number;
  11948. /**
  11949. * Represents a pose-enabled controller
  11950. */
  11951. static POSE_ENABLED: number;
  11952. /**
  11953. * Specifies whether the left control stick should be Y-inverted
  11954. */
  11955. protected _invertLeftStickY: boolean;
  11956. /**
  11957. * Specifies if the gamepad has been connected
  11958. */
  11959. readonly isConnected: boolean;
  11960. /**
  11961. * Initializes the gamepad
  11962. * @param id The id of the gamepad
  11963. * @param index The index of the gamepad
  11964. * @param browserGamepad The browser gamepad
  11965. * @param leftStickX The x component of the left joystick
  11966. * @param leftStickY The y component of the left joystick
  11967. * @param rightStickX The x component of the right joystick
  11968. * @param rightStickY The y component of the right joystick
  11969. */
  11970. constructor(
  11971. /**
  11972. * The id of the gamepad
  11973. */
  11974. id: string,
  11975. /**
  11976. * The index of the gamepad
  11977. */
  11978. index: number,
  11979. /**
  11980. * The browser gamepad
  11981. */
  11982. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  11983. /**
  11984. * Callback triggered when the left joystick has changed
  11985. * @param callback
  11986. */
  11987. onleftstickchanged(callback: (values: StickValues) => void): void;
  11988. /**
  11989. * Callback triggered when the right joystick has changed
  11990. * @param callback
  11991. */
  11992. onrightstickchanged(callback: (values: StickValues) => void): void;
  11993. /**
  11994. * Gets the left joystick
  11995. */
  11996. /**
  11997. * Sets the left joystick values
  11998. */
  11999. leftStick: StickValues;
  12000. /**
  12001. * Gets the right joystick
  12002. */
  12003. /**
  12004. * Sets the right joystick value
  12005. */
  12006. rightStick: StickValues;
  12007. /**
  12008. * Updates the gamepad joystick positions
  12009. */
  12010. update(): void;
  12011. /**
  12012. * Disposes the gamepad
  12013. */
  12014. dispose(): void;
  12015. }
  12016. /**
  12017. * Represents a generic gamepad
  12018. */
  12019. class GenericPad extends Gamepad {
  12020. private _buttons;
  12021. private _onbuttondown;
  12022. private _onbuttonup;
  12023. /**
  12024. * Observable triggered when a button has been pressed
  12025. */
  12026. onButtonDownObservable: Observable<number>;
  12027. /**
  12028. * Observable triggered when a button has been released
  12029. */
  12030. onButtonUpObservable: Observable<number>;
  12031. /**
  12032. * Callback triggered when a button has been pressed
  12033. * @param callback Called when a button has been pressed
  12034. */
  12035. onbuttondown(callback: (buttonPressed: number) => void): void;
  12036. /**
  12037. * Callback triggered when a button has been released
  12038. * @param callback Called when a button has been released
  12039. */
  12040. onbuttonup(callback: (buttonReleased: number) => void): void;
  12041. /**
  12042. * Initializes the generic gamepad
  12043. * @param id The id of the generic gamepad
  12044. * @param index The index of the generic gamepad
  12045. * @param browserGamepad The browser gamepad
  12046. */
  12047. constructor(id: string, index: number, browserGamepad: any);
  12048. private _setButtonValue;
  12049. /**
  12050. * Updates the generic gamepad
  12051. */
  12052. update(): void;
  12053. /**
  12054. * Disposes the generic gamepad
  12055. */
  12056. dispose(): void;
  12057. }
  12058. }
  12059. declare module BABYLON {
  12060. /**
  12061. * Manager for handling gamepads
  12062. */
  12063. class GamepadManager {
  12064. private _scene?;
  12065. private _babylonGamepads;
  12066. private _oneGamepadConnected;
  12067. /** @hidden */
  12068. _isMonitoring: boolean;
  12069. private _gamepadEventSupported;
  12070. private _gamepadSupport;
  12071. /**
  12072. * observable to be triggered when the gamepad controller has been connected
  12073. */
  12074. onGamepadConnectedObservable: Observable<Gamepad>;
  12075. /**
  12076. * observable to be triggered when the gamepad controller has been disconnected
  12077. */
  12078. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12079. private _onGamepadConnectedEvent;
  12080. private _onGamepadDisconnectedEvent;
  12081. /**
  12082. * Initializes the gamepad manager
  12083. * @param _scene BabylonJS scene
  12084. */
  12085. constructor(_scene?: Scene | undefined);
  12086. /**
  12087. * The gamepads in the game pad manager
  12088. */
  12089. readonly gamepads: Gamepad[];
  12090. /**
  12091. * Get the gamepad controllers based on type
  12092. * @param type The type of gamepad controller
  12093. * @returns Nullable gamepad
  12094. */
  12095. getGamepadByType(type?: number): Nullable<Gamepad>;
  12096. /**
  12097. * Disposes the gamepad manager
  12098. */
  12099. dispose(): void;
  12100. private _addNewGamepad;
  12101. private _startMonitoringGamepads;
  12102. private _stopMonitoringGamepads;
  12103. /** @hidden */
  12104. _checkGamepadsStatus(): void;
  12105. private _updateGamepadObjects;
  12106. }
  12107. }
  12108. declare module BABYLON {
  12109. interface Scene {
  12110. /** @hidden */
  12111. _gamepadManager: Nullable<GamepadManager>;
  12112. /**
  12113. * Gets the gamepad manager associated with the scene
  12114. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12115. */
  12116. gamepadManager: GamepadManager;
  12117. }
  12118. /**
  12119. * Interface representing a free camera inputs manager
  12120. */
  12121. interface FreeCameraInputsManager {
  12122. addGamepad(): FreeCameraInputsManager;
  12123. }
  12124. /**
  12125. * Interface representing an arc rotate camera inputs manager
  12126. */
  12127. interface ArcRotateCameraInputsManager {
  12128. /**
  12129. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12130. * @returns the camera inputs manager
  12131. */
  12132. addGamepad(): ArcRotateCameraInputsManager;
  12133. }
  12134. /**
  12135. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12136. */
  12137. class GamepadSystemSceneComponent implements ISceneComponent {
  12138. /**
  12139. * The component name helpfull to identify the component in the list of scene components.
  12140. */
  12141. readonly name: string;
  12142. /**
  12143. * The scene the component belongs to.
  12144. */
  12145. scene: Scene;
  12146. /**
  12147. * Creates a new instance of the component for the given scene
  12148. * @param scene Defines the scene to register the component in
  12149. */
  12150. constructor(scene: Scene);
  12151. /**
  12152. * Registers the component in a given scene
  12153. */
  12154. register(): void;
  12155. /**
  12156. * Rebuilds the elements related to this component in case of
  12157. * context lost for instance.
  12158. */
  12159. rebuild(): void;
  12160. /**
  12161. * Disposes the component and the associated ressources
  12162. */
  12163. dispose(): void;
  12164. private _beforeCameraUpdate;
  12165. }
  12166. }
  12167. declare module BABYLON {
  12168. /**
  12169. * Defines supported buttons for XBox360 compatible gamepads
  12170. */
  12171. enum Xbox360Button {
  12172. /** A */
  12173. A = 0,
  12174. /** B */
  12175. B = 1,
  12176. /** X */
  12177. X = 2,
  12178. /** Y */
  12179. Y = 3,
  12180. /** Start */
  12181. Start = 4,
  12182. /** Back */
  12183. Back = 5,
  12184. /** Left button */
  12185. LB = 6,
  12186. /** Right button */
  12187. RB = 7,
  12188. /** Left stick */
  12189. LeftStick = 8,
  12190. /** Right stick */
  12191. RightStick = 9
  12192. }
  12193. /** Defines values for XBox360 DPad */
  12194. enum Xbox360Dpad {
  12195. /** Up */
  12196. Up = 0,
  12197. /** Down */
  12198. Down = 1,
  12199. /** Left */
  12200. Left = 2,
  12201. /** Right */
  12202. Right = 3
  12203. }
  12204. /**
  12205. * Defines a XBox360 gamepad
  12206. */
  12207. class Xbox360Pad extends Gamepad {
  12208. private _leftTrigger;
  12209. private _rightTrigger;
  12210. private _onlefttriggerchanged;
  12211. private _onrighttriggerchanged;
  12212. private _onbuttondown;
  12213. private _onbuttonup;
  12214. private _ondpaddown;
  12215. private _ondpadup;
  12216. /** Observable raised when a button is pressed */
  12217. onButtonDownObservable: Observable<Xbox360Button>;
  12218. /** Observable raised when a button is released */
  12219. onButtonUpObservable: Observable<Xbox360Button>;
  12220. /** Observable raised when a pad is pressed */
  12221. onPadDownObservable: Observable<Xbox360Dpad>;
  12222. /** Observable raised when a pad is released */
  12223. onPadUpObservable: Observable<Xbox360Dpad>;
  12224. private _buttonA;
  12225. private _buttonB;
  12226. private _buttonX;
  12227. private _buttonY;
  12228. private _buttonBack;
  12229. private _buttonStart;
  12230. private _buttonLB;
  12231. private _buttonRB;
  12232. private _buttonLeftStick;
  12233. private _buttonRightStick;
  12234. private _dPadUp;
  12235. private _dPadDown;
  12236. private _dPadLeft;
  12237. private _dPadRight;
  12238. private _isXboxOnePad;
  12239. /**
  12240. * Creates a new XBox360 gamepad object
  12241. * @param id defines the id of this gamepad
  12242. * @param index defines its index
  12243. * @param gamepad defines the internal HTML gamepad object
  12244. * @param xboxOne defines if it is a XBox One gamepad
  12245. */
  12246. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12247. /**
  12248. * Defines the callback to call when left trigger is pressed
  12249. * @param callback defines the callback to use
  12250. */
  12251. onlefttriggerchanged(callback: (value: number) => void): void;
  12252. /**
  12253. * Defines the callback to call when right trigger is pressed
  12254. * @param callback defines the callback to use
  12255. */
  12256. onrighttriggerchanged(callback: (value: number) => void): void;
  12257. /**
  12258. * Gets the left trigger value
  12259. */
  12260. /**
  12261. * Sets the left trigger value
  12262. */
  12263. leftTrigger: number;
  12264. /**
  12265. * Gets the right trigger value
  12266. */
  12267. /**
  12268. * Sets the right trigger value
  12269. */
  12270. rightTrigger: number;
  12271. /**
  12272. * Defines the callback to call when a button is pressed
  12273. * @param callback defines the callback to use
  12274. */
  12275. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12276. /**
  12277. * Defines the callback to call when a button is released
  12278. * @param callback defines the callback to use
  12279. */
  12280. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12281. /**
  12282. * Defines the callback to call when a pad is pressed
  12283. * @param callback defines the callback to use
  12284. */
  12285. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12286. /**
  12287. * Defines the callback to call when a pad is released
  12288. * @param callback defines the callback to use
  12289. */
  12290. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12291. private _setButtonValue;
  12292. private _setDPadValue;
  12293. /**
  12294. * Gets the value of the `A` button
  12295. */
  12296. /**
  12297. * Sets the value of the `A` button
  12298. */
  12299. buttonA: number;
  12300. /**
  12301. * Gets the value of the `B` button
  12302. */
  12303. /**
  12304. * Sets the value of the `B` button
  12305. */
  12306. buttonB: number;
  12307. /**
  12308. * Gets the value of the `X` button
  12309. */
  12310. /**
  12311. * Sets the value of the `X` button
  12312. */
  12313. buttonX: number;
  12314. /**
  12315. * Gets the value of the `Y` button
  12316. */
  12317. /**
  12318. * Sets the value of the `Y` button
  12319. */
  12320. buttonY: number;
  12321. /**
  12322. * Gets the value of the `Start` button
  12323. */
  12324. /**
  12325. * Sets the value of the `Start` button
  12326. */
  12327. buttonStart: number;
  12328. /**
  12329. * Gets the value of the `Back` button
  12330. */
  12331. /**
  12332. * Sets the value of the `Back` button
  12333. */
  12334. buttonBack: number;
  12335. /**
  12336. * Gets the value of the `Left` button
  12337. */
  12338. /**
  12339. * Sets the value of the `Left` button
  12340. */
  12341. buttonLB: number;
  12342. /**
  12343. * Gets the value of the `Right` button
  12344. */
  12345. /**
  12346. * Sets the value of the `Right` button
  12347. */
  12348. buttonRB: number;
  12349. /**
  12350. * Gets the value of the Left joystick
  12351. */
  12352. /**
  12353. * Sets the value of the Left joystick
  12354. */
  12355. buttonLeftStick: number;
  12356. /**
  12357. * Gets the value of the Right joystick
  12358. */
  12359. /**
  12360. * Sets the value of the Right joystick
  12361. */
  12362. buttonRightStick: number;
  12363. /**
  12364. * Gets the value of D-pad up
  12365. */
  12366. /**
  12367. * Sets the value of D-pad up
  12368. */
  12369. dPadUp: number;
  12370. /**
  12371. * Gets the value of D-pad down
  12372. */
  12373. /**
  12374. * Sets the value of D-pad down
  12375. */
  12376. dPadDown: number;
  12377. /**
  12378. * Gets the value of D-pad left
  12379. */
  12380. /**
  12381. * Sets the value of D-pad left
  12382. */
  12383. dPadLeft: number;
  12384. /**
  12385. * Gets the value of D-pad right
  12386. */
  12387. /**
  12388. * Sets the value of D-pad right
  12389. */
  12390. dPadRight: number;
  12391. /**
  12392. * Force the gamepad to synchronize with device values
  12393. */
  12394. update(): void;
  12395. /**
  12396. * Disposes the gamepad
  12397. */
  12398. dispose(): void;
  12399. }
  12400. }
  12401. declare module BABYLON {
  12402. /**
  12403. * Single axis drag gizmo
  12404. */
  12405. class AxisDragGizmo extends Gizmo {
  12406. /**
  12407. * Drag behavior responsible for the gizmos dragging interactions
  12408. */
  12409. dragBehavior: PointerDragBehavior;
  12410. private _pointerObserver;
  12411. /**
  12412. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12413. */
  12414. snapDistance: number;
  12415. /**
  12416. * Event that fires each time the gizmo snaps to a new location.
  12417. * * snapDistance is the the change in distance
  12418. */
  12419. onSnapObservable: Observable<{
  12420. snapDistance: number;
  12421. }>;
  12422. /**
  12423. * Creates an AxisDragGizmo
  12424. * @param gizmoLayer The utility layer the gizmo will be added to
  12425. * @param dragAxis The axis which the gizmo will be able to drag on
  12426. * @param color The color of the gizmo
  12427. */
  12428. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12429. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12430. /**
  12431. * Disposes of the gizmo
  12432. */
  12433. dispose(): void;
  12434. }
  12435. }
  12436. declare module BABYLON {
  12437. /**
  12438. * Single axis scale gizmo
  12439. */
  12440. class AxisScaleGizmo extends Gizmo {
  12441. private _coloredMaterial;
  12442. /**
  12443. * Drag behavior responsible for the gizmos dragging interactions
  12444. */
  12445. dragBehavior: PointerDragBehavior;
  12446. private _pointerObserver;
  12447. /**
  12448. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12449. */
  12450. snapDistance: number;
  12451. /**
  12452. * Event that fires each time the gizmo snaps to a new location.
  12453. * * snapDistance is the the change in distance
  12454. */
  12455. onSnapObservable: Observable<{
  12456. snapDistance: number;
  12457. }>;
  12458. /**
  12459. * If the scaling operation should be done on all axis (default: false)
  12460. */
  12461. uniformScaling: boolean;
  12462. /**
  12463. * Creates an AxisScaleGizmo
  12464. * @param gizmoLayer The utility layer the gizmo will be added to
  12465. * @param dragAxis The axis which the gizmo will be able to scale on
  12466. * @param color The color of the gizmo
  12467. */
  12468. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12469. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12470. /**
  12471. * Disposes of the gizmo
  12472. */
  12473. dispose(): void;
  12474. /**
  12475. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12476. * @param mesh The mesh to replace the default mesh of the gizmo
  12477. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12478. */
  12479. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12480. }
  12481. }
  12482. declare module BABYLON {
  12483. /**
  12484. * Bounding box gizmo
  12485. */
  12486. class BoundingBoxGizmo extends Gizmo {
  12487. private _lineBoundingBox;
  12488. private _rotateSpheresParent;
  12489. private _scaleBoxesParent;
  12490. private _boundingDimensions;
  12491. private _renderObserver;
  12492. private _pointerObserver;
  12493. private _scaleDragSpeed;
  12494. private _tmpQuaternion;
  12495. private _tmpVector;
  12496. private _tmpRotationMatrix;
  12497. /**
  12498. * 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)
  12499. */
  12500. ignoreChildren: boolean;
  12501. /**
  12502. * 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)
  12503. */
  12504. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12505. /**
  12506. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12507. */
  12508. rotationSphereSize: number;
  12509. /**
  12510. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12511. */
  12512. scaleBoxSize: number;
  12513. /**
  12514. * 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)
  12515. */
  12516. fixedDragMeshScreenSize: boolean;
  12517. /**
  12518. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12519. */
  12520. fixedDragMeshScreenSizeDistanceFactor: number;
  12521. /**
  12522. * Fired when a rotation sphere or scale box is dragged
  12523. */
  12524. onDragStartObservable: Observable<{}>;
  12525. /**
  12526. * Fired when a scale box is dragged
  12527. */
  12528. onScaleBoxDragObservable: Observable<{}>;
  12529. /**
  12530. * Fired when a scale box drag is ended
  12531. */
  12532. onScaleBoxDragEndObservable: Observable<{}>;
  12533. /**
  12534. * Fired when a rotation sphere is dragged
  12535. */
  12536. onRotationSphereDragObservable: Observable<{}>;
  12537. /**
  12538. * Fired when a rotation sphere drag is ended
  12539. */
  12540. onRotationSphereDragEndObservable: Observable<{}>;
  12541. /**
  12542. * 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)
  12543. */
  12544. scalePivot: Nullable<Vector3>;
  12545. private _anchorMesh;
  12546. private _existingMeshScale;
  12547. private static _PivotCached;
  12548. private static _OldPivotPoint;
  12549. private static _PivotTranslation;
  12550. private static _PivotTmpVector;
  12551. /** @hidden */
  12552. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  12553. /** @hidden */
  12554. static _RestorePivotPoint(mesh: AbstractMesh): void;
  12555. /**
  12556. * Creates an BoundingBoxGizmo
  12557. * @param gizmoLayer The utility layer the gizmo will be added to
  12558. * @param color The color of the gizmo
  12559. */
  12560. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12561. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12562. private _selectNode;
  12563. /**
  12564. * Updates the bounding box information for the Gizmo
  12565. */
  12566. updateBoundingBox(): void;
  12567. /**
  12568. * Enables rotation on the specified axis and disables rotation on the others
  12569. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  12570. */
  12571. setEnabledRotationAxis(axis: string): void;
  12572. /**
  12573. * Disposes of the gizmo
  12574. */
  12575. dispose(): void;
  12576. /**
  12577. * 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)
  12578. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  12579. * @returns the bounding box mesh with the passed in mesh as a child
  12580. */
  12581. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  12582. /**
  12583. * CustomMeshes are not supported by this gizmo
  12584. * @param mesh The mesh to replace the default mesh of the gizmo
  12585. */
  12586. setCustomMesh(mesh: Mesh): void;
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. /**
  12591. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  12592. */
  12593. class Gizmo implements IDisposable {
  12594. /** The utility layer the gizmo will be added to */
  12595. gizmoLayer: UtilityLayerRenderer;
  12596. /**
  12597. * The root mesh of the gizmo
  12598. */
  12599. protected _rootMesh: Mesh;
  12600. private _attachedMesh;
  12601. /**
  12602. * Ratio for the scale of the gizmo (Default: 1)
  12603. */
  12604. scaleRatio: number;
  12605. private _tmpMatrix;
  12606. /**
  12607. * If a custom mesh has been set (Default: false)
  12608. */
  12609. protected _customMeshSet: boolean;
  12610. /**
  12611. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  12612. * * When set, interactions will be enabled
  12613. */
  12614. attachedMesh: Nullable<AbstractMesh>;
  12615. /**
  12616. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12617. * @param mesh The mesh to replace the default mesh of the gizmo
  12618. */
  12619. setCustomMesh(mesh: Mesh): void;
  12620. /**
  12621. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  12622. */
  12623. updateGizmoRotationToMatchAttachedMesh: boolean;
  12624. /**
  12625. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  12626. */
  12627. updateGizmoPositionToMatchAttachedMesh: boolean;
  12628. /**
  12629. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  12630. */
  12631. protected _updateScale: boolean;
  12632. protected _interactionsEnabled: boolean;
  12633. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12634. private _beforeRenderObserver;
  12635. /**
  12636. * Creates a gizmo
  12637. * @param gizmoLayer The utility layer the gizmo will be added to
  12638. */
  12639. constructor(
  12640. /** The utility layer the gizmo will be added to */
  12641. gizmoLayer?: UtilityLayerRenderer);
  12642. private _tempVector;
  12643. /**
  12644. * @hidden
  12645. * Updates the gizmo to match the attached mesh's position/rotation
  12646. */
  12647. protected _update(): void;
  12648. /**
  12649. * Disposes of the gizmo
  12650. */
  12651. dispose(): void;
  12652. }
  12653. }
  12654. declare module BABYLON {
  12655. /**
  12656. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  12657. */
  12658. class GizmoManager implements IDisposable {
  12659. private scene;
  12660. /**
  12661. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  12662. */
  12663. gizmos: {
  12664. positionGizmo: Nullable<PositionGizmo>;
  12665. rotationGizmo: Nullable<RotationGizmo>;
  12666. scaleGizmo: Nullable<ScaleGizmo>;
  12667. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  12668. };
  12669. private _gizmosEnabled;
  12670. private _pointerObserver;
  12671. private _attachedMesh;
  12672. private _boundingBoxColor;
  12673. /**
  12674. * When bounding box gizmo is enabled, this can be used to track drag/end events
  12675. */
  12676. boundingBoxDragBehavior: SixDofDragBehavior;
  12677. /**
  12678. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  12679. */
  12680. attachableMeshes: Nullable<Array<AbstractMesh>>;
  12681. /**
  12682. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  12683. */
  12684. usePointerToAttachGizmos: boolean;
  12685. /**
  12686. * Instatiates a gizmo manager
  12687. * @param scene the scene to overlay the gizmos on top of
  12688. */
  12689. constructor(scene: Scene);
  12690. /**
  12691. * Attaches a set of gizmos to the specified mesh
  12692. * @param mesh The mesh the gizmo's should be attached to
  12693. */
  12694. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  12695. /**
  12696. * If the position gizmo is enabled
  12697. */
  12698. positionGizmoEnabled: boolean;
  12699. /**
  12700. * If the rotation gizmo is enabled
  12701. */
  12702. rotationGizmoEnabled: boolean;
  12703. /**
  12704. * If the scale gizmo is enabled
  12705. */
  12706. scaleGizmoEnabled: boolean;
  12707. /**
  12708. * If the boundingBox gizmo is enabled
  12709. */
  12710. boundingBoxGizmoEnabled: boolean;
  12711. /**
  12712. * Disposes of the gizmo manager
  12713. */
  12714. dispose(): void;
  12715. }
  12716. }
  12717. declare module BABYLON {
  12718. /**
  12719. * Single plane rotation gizmo
  12720. */
  12721. class PlaneRotationGizmo extends Gizmo {
  12722. /**
  12723. * Drag behavior responsible for the gizmos dragging interactions
  12724. */
  12725. dragBehavior: PointerDragBehavior;
  12726. private _pointerObserver;
  12727. /**
  12728. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  12729. */
  12730. snapDistance: number;
  12731. /**
  12732. * Event that fires each time the gizmo snaps to a new location.
  12733. * * snapDistance is the the change in distance
  12734. */
  12735. onSnapObservable: Observable<{
  12736. snapDistance: number;
  12737. }>;
  12738. /**
  12739. * Creates a PlaneRotationGizmo
  12740. * @param gizmoLayer The utility layer the gizmo will be added to
  12741. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  12742. * @param color The color of the gizmo
  12743. */
  12744. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12745. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12746. /**
  12747. * Disposes of the gizmo
  12748. */
  12749. dispose(): void;
  12750. }
  12751. }
  12752. declare module BABYLON {
  12753. /**
  12754. * Gizmo that enables dragging a mesh along 3 axis
  12755. */
  12756. class PositionGizmo extends Gizmo {
  12757. /**
  12758. * Internal gizmo used for interactions on the x axis
  12759. */
  12760. xGizmo: AxisDragGizmo;
  12761. /**
  12762. * Internal gizmo used for interactions on the y axis
  12763. */
  12764. yGizmo: AxisDragGizmo;
  12765. /**
  12766. * Internal gizmo used for interactions on the z axis
  12767. */
  12768. zGizmo: AxisDragGizmo;
  12769. attachedMesh: Nullable<AbstractMesh>;
  12770. /**
  12771. * Creates a PositionGizmo
  12772. * @param gizmoLayer The utility layer the gizmo will be added to
  12773. */
  12774. constructor(gizmoLayer?: UtilityLayerRenderer);
  12775. updateGizmoRotationToMatchAttachedMesh: boolean;
  12776. /**
  12777. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12778. */
  12779. snapDistance: number;
  12780. /**
  12781. * Ratio for the scale of the gizmo (Default: 1)
  12782. */
  12783. scaleRatio: number;
  12784. /**
  12785. * Disposes of the gizmo
  12786. */
  12787. dispose(): void;
  12788. /**
  12789. * CustomMeshes are not supported by this gizmo
  12790. * @param mesh The mesh to replace the default mesh of the gizmo
  12791. */
  12792. setCustomMesh(mesh: Mesh): void;
  12793. }
  12794. }
  12795. declare module BABYLON {
  12796. /**
  12797. * Gizmo that enables rotating a mesh along 3 axis
  12798. */
  12799. class RotationGizmo extends Gizmo {
  12800. /**
  12801. * Internal gizmo used for interactions on the x axis
  12802. */
  12803. xGizmo: PlaneRotationGizmo;
  12804. /**
  12805. * Internal gizmo used for interactions on the y axis
  12806. */
  12807. yGizmo: PlaneRotationGizmo;
  12808. /**
  12809. * Internal gizmo used for interactions on the z axis
  12810. */
  12811. zGizmo: PlaneRotationGizmo;
  12812. attachedMesh: Nullable<AbstractMesh>;
  12813. /**
  12814. * Creates a RotationGizmo
  12815. * @param gizmoLayer The utility layer the gizmo will be added to
  12816. */
  12817. constructor(gizmoLayer?: UtilityLayerRenderer);
  12818. updateGizmoRotationToMatchAttachedMesh: boolean;
  12819. /**
  12820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12821. */
  12822. snapDistance: number;
  12823. /**
  12824. * Ratio for the scale of the gizmo (Default: 1)
  12825. */
  12826. scaleRatio: number;
  12827. /**
  12828. * Disposes of the gizmo
  12829. */
  12830. dispose(): void;
  12831. /**
  12832. * CustomMeshes are not supported by this gizmo
  12833. * @param mesh The mesh to replace the default mesh of the gizmo
  12834. */
  12835. setCustomMesh(mesh: Mesh): void;
  12836. }
  12837. }
  12838. declare module BABYLON {
  12839. /**
  12840. * Gizmo that enables scaling a mesh along 3 axis
  12841. */
  12842. class ScaleGizmo extends Gizmo {
  12843. /**
  12844. * Internal gizmo used for interactions on the x axis
  12845. */
  12846. xGizmo: AxisScaleGizmo;
  12847. /**
  12848. * Internal gizmo used for interactions on the y axis
  12849. */
  12850. yGizmo: AxisScaleGizmo;
  12851. /**
  12852. * Internal gizmo used for interactions on the z axis
  12853. */
  12854. zGizmo: AxisScaleGizmo;
  12855. /**
  12856. * Internal gizmo used to scale all axis equally
  12857. */
  12858. uniformScaleGizmo: AxisScaleGizmo;
  12859. attachedMesh: Nullable<AbstractMesh>;
  12860. /**
  12861. * Creates a ScaleGizmo
  12862. * @param gizmoLayer The utility layer the gizmo will be added to
  12863. */
  12864. constructor(gizmoLayer?: UtilityLayerRenderer);
  12865. updateGizmoRotationToMatchAttachedMesh: boolean;
  12866. /**
  12867. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12868. */
  12869. snapDistance: number;
  12870. /**
  12871. * Ratio for the scale of the gizmo (Default: 1)
  12872. */
  12873. scaleRatio: number;
  12874. /**
  12875. * Disposes of the gizmo
  12876. */
  12877. dispose(): void;
  12878. }
  12879. }
  12880. declare module BABYLON {
  12881. /**
  12882. * Represents the different options available during the creation of
  12883. * a Environment helper.
  12884. *
  12885. * This can control the default ground, skybox and image processing setup of your scene.
  12886. */
  12887. interface IEnvironmentHelperOptions {
  12888. /**
  12889. * Specifies wether or not to create a ground.
  12890. * True by default.
  12891. */
  12892. createGround: boolean;
  12893. /**
  12894. * Specifies the ground size.
  12895. * 15 by default.
  12896. */
  12897. groundSize: number;
  12898. /**
  12899. * The texture used on the ground for the main color.
  12900. * Comes from the BabylonJS CDN by default.
  12901. *
  12902. * Remarks: Can be either a texture or a url.
  12903. */
  12904. groundTexture: string | BaseTexture;
  12905. /**
  12906. * The color mixed in the ground texture by default.
  12907. * BabylonJS clearColor by default.
  12908. */
  12909. groundColor: Color3;
  12910. /**
  12911. * Specifies the ground opacity.
  12912. * 1 by default.
  12913. */
  12914. groundOpacity: number;
  12915. /**
  12916. * Enables the ground to receive shadows.
  12917. * True by default.
  12918. */
  12919. enableGroundShadow: boolean;
  12920. /**
  12921. * Helps preventing the shadow to be fully black on the ground.
  12922. * 0.5 by default.
  12923. */
  12924. groundShadowLevel: number;
  12925. /**
  12926. * Creates a mirror texture attach to the ground.
  12927. * false by default.
  12928. */
  12929. enableGroundMirror: boolean;
  12930. /**
  12931. * Specifies the ground mirror size ratio.
  12932. * 0.3 by default as the default kernel is 64.
  12933. */
  12934. groundMirrorSizeRatio: number;
  12935. /**
  12936. * Specifies the ground mirror blur kernel size.
  12937. * 64 by default.
  12938. */
  12939. groundMirrorBlurKernel: number;
  12940. /**
  12941. * Specifies the ground mirror visibility amount.
  12942. * 1 by default
  12943. */
  12944. groundMirrorAmount: number;
  12945. /**
  12946. * Specifies the ground mirror reflectance weight.
  12947. * This uses the standard weight of the background material to setup the fresnel effect
  12948. * of the mirror.
  12949. * 1 by default.
  12950. */
  12951. groundMirrorFresnelWeight: number;
  12952. /**
  12953. * Specifies the ground mirror Falloff distance.
  12954. * This can helps reducing the size of the reflection.
  12955. * 0 by Default.
  12956. */
  12957. groundMirrorFallOffDistance: number;
  12958. /**
  12959. * Specifies the ground mirror texture type.
  12960. * Unsigned Int by Default.
  12961. */
  12962. groundMirrorTextureType: number;
  12963. /**
  12964. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  12965. * the shown objects.
  12966. */
  12967. groundYBias: number;
  12968. /**
  12969. * Specifies wether or not to create a skybox.
  12970. * True by default.
  12971. */
  12972. createSkybox: boolean;
  12973. /**
  12974. * Specifies the skybox size.
  12975. * 20 by default.
  12976. */
  12977. skyboxSize: number;
  12978. /**
  12979. * The texture used on the skybox for the main color.
  12980. * Comes from the BabylonJS CDN by default.
  12981. *
  12982. * Remarks: Can be either a texture or a url.
  12983. */
  12984. skyboxTexture: string | BaseTexture;
  12985. /**
  12986. * The color mixed in the skybox texture by default.
  12987. * BabylonJS clearColor by default.
  12988. */
  12989. skyboxColor: Color3;
  12990. /**
  12991. * The background rotation around the Y axis of the scene.
  12992. * This helps aligning the key lights of your scene with the background.
  12993. * 0 by default.
  12994. */
  12995. backgroundYRotation: number;
  12996. /**
  12997. * Compute automatically the size of the elements to best fit with the scene.
  12998. */
  12999. sizeAuto: boolean;
  13000. /**
  13001. * Default position of the rootMesh if autoSize is not true.
  13002. */
  13003. rootPosition: Vector3;
  13004. /**
  13005. * Sets up the image processing in the scene.
  13006. * true by default.
  13007. */
  13008. setupImageProcessing: boolean;
  13009. /**
  13010. * The texture used as your environment texture in the scene.
  13011. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13012. *
  13013. * Remarks: Can be either a texture or a url.
  13014. */
  13015. environmentTexture: string | BaseTexture;
  13016. /**
  13017. * The value of the exposure to apply to the scene.
  13018. * 0.6 by default if setupImageProcessing is true.
  13019. */
  13020. cameraExposure: number;
  13021. /**
  13022. * The value of the contrast to apply to the scene.
  13023. * 1.6 by default if setupImageProcessing is true.
  13024. */
  13025. cameraContrast: number;
  13026. /**
  13027. * Specifies wether or not tonemapping should be enabled in the scene.
  13028. * true by default if setupImageProcessing is true.
  13029. */
  13030. toneMappingEnabled: boolean;
  13031. }
  13032. /**
  13033. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13034. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13035. * It also helps with the default setup of your imageProcessing configuration.
  13036. */
  13037. class EnvironmentHelper {
  13038. /**
  13039. * Default ground texture URL.
  13040. */
  13041. private static _groundTextureCDNUrl;
  13042. /**
  13043. * Default skybox texture URL.
  13044. */
  13045. private static _skyboxTextureCDNUrl;
  13046. /**
  13047. * Default environment texture URL.
  13048. */
  13049. private static _environmentTextureCDNUrl;
  13050. /**
  13051. * Creates the default options for the helper.
  13052. */
  13053. private static _getDefaultOptions;
  13054. private _rootMesh;
  13055. /**
  13056. * Gets the root mesh created by the helper.
  13057. */
  13058. readonly rootMesh: Mesh;
  13059. private _skybox;
  13060. /**
  13061. * Gets the skybox created by the helper.
  13062. */
  13063. readonly skybox: Nullable<Mesh>;
  13064. private _skyboxTexture;
  13065. /**
  13066. * Gets the skybox texture created by the helper.
  13067. */
  13068. readonly skyboxTexture: Nullable<BaseTexture>;
  13069. private _skyboxMaterial;
  13070. /**
  13071. * Gets the skybox material created by the helper.
  13072. */
  13073. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13074. private _ground;
  13075. /**
  13076. * Gets the ground mesh created by the helper.
  13077. */
  13078. readonly ground: Nullable<Mesh>;
  13079. private _groundTexture;
  13080. /**
  13081. * Gets the ground texture created by the helper.
  13082. */
  13083. readonly groundTexture: Nullable<BaseTexture>;
  13084. private _groundMirror;
  13085. /**
  13086. * Gets the ground mirror created by the helper.
  13087. */
  13088. readonly groundMirror: Nullable<MirrorTexture>;
  13089. /**
  13090. * Gets the ground mirror render list to helps pushing the meshes
  13091. * you wish in the ground reflection.
  13092. */
  13093. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13094. private _groundMaterial;
  13095. /**
  13096. * Gets the ground material created by the helper.
  13097. */
  13098. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13099. /**
  13100. * Stores the creation options.
  13101. */
  13102. private readonly _scene;
  13103. private _options;
  13104. /**
  13105. * This observable will be notified with any error during the creation of the environment,
  13106. * mainly texture creation errors.
  13107. */
  13108. onErrorObservable: Observable<{
  13109. message?: string;
  13110. exception?: any;
  13111. }>;
  13112. /**
  13113. * constructor
  13114. * @param options
  13115. * @param scene The scene to add the material to
  13116. */
  13117. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13118. /**
  13119. * Updates the background according to the new options
  13120. * @param options
  13121. */
  13122. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13123. /**
  13124. * Sets the primary color of all the available elements.
  13125. * @param color the main color to affect to the ground and the background
  13126. */
  13127. setMainColor(color: Color3): void;
  13128. /**
  13129. * Setup the image processing according to the specified options.
  13130. */
  13131. private _setupImageProcessing;
  13132. /**
  13133. * Setup the environment texture according to the specified options.
  13134. */
  13135. private _setupEnvironmentTexture;
  13136. /**
  13137. * Setup the background according to the specified options.
  13138. */
  13139. private _setupBackground;
  13140. /**
  13141. * Get the scene sizes according to the setup.
  13142. */
  13143. private _getSceneSize;
  13144. /**
  13145. * Setup the ground according to the specified options.
  13146. */
  13147. private _setupGround;
  13148. /**
  13149. * Setup the ground material according to the specified options.
  13150. */
  13151. private _setupGroundMaterial;
  13152. /**
  13153. * Setup the ground diffuse texture according to the specified options.
  13154. */
  13155. private _setupGroundDiffuseTexture;
  13156. /**
  13157. * Setup the ground mirror texture according to the specified options.
  13158. */
  13159. private _setupGroundMirrorTexture;
  13160. /**
  13161. * Setup the ground to receive the mirror texture.
  13162. */
  13163. private _setupMirrorInGroundMaterial;
  13164. /**
  13165. * Setup the skybox according to the specified options.
  13166. */
  13167. private _setupSkybox;
  13168. /**
  13169. * Setup the skybox material according to the specified options.
  13170. */
  13171. private _setupSkyboxMaterial;
  13172. /**
  13173. * Setup the skybox reflection texture according to the specified options.
  13174. */
  13175. private _setupSkyboxReflectionTexture;
  13176. private _errorHandler;
  13177. /**
  13178. * Dispose all the elements created by the Helper.
  13179. */
  13180. dispose(): void;
  13181. }
  13182. }
  13183. declare module BABYLON {
  13184. /**
  13185. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13186. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13187. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13188. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13189. */
  13190. class PhotoDome extends TransformNode {
  13191. private _useDirectMapping;
  13192. /**
  13193. * The texture being displayed on the sphere
  13194. */
  13195. protected _photoTexture: Texture;
  13196. /**
  13197. * Gets or sets the texture being displayed on the sphere
  13198. */
  13199. photoTexture: Texture;
  13200. /**
  13201. * Observable raised when an error occured while loading the 360 image
  13202. */
  13203. onLoadErrorObservable: Observable<string>;
  13204. /**
  13205. * The skybox material
  13206. */
  13207. protected _material: BackgroundMaterial;
  13208. /**
  13209. * The surface used for the skybox
  13210. */
  13211. protected _mesh: Mesh;
  13212. /**
  13213. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13214. * Also see the options.resolution property.
  13215. */
  13216. fovMultiplier: number;
  13217. /**
  13218. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13219. * @param name Element's name, child elements will append suffixes for their own names.
  13220. * @param urlsOfPhoto defines the url of the photo to display
  13221. * @param options defines an object containing optional or exposed sub element properties
  13222. * @param onError defines a callback called when an error occured while loading the texture
  13223. */
  13224. constructor(name: string, urlOfPhoto: string, options: {
  13225. resolution?: number;
  13226. size?: number;
  13227. useDirectMapping?: boolean;
  13228. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13229. /**
  13230. * Releases resources associated with this node.
  13231. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13232. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13233. */
  13234. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13235. }
  13236. }
  13237. declare module BABYLON {
  13238. interface Scene {
  13239. /**
  13240. * Creates a default light for the scene.
  13241. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13242. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13243. */
  13244. createDefaultLight(replace?: boolean): void;
  13245. /**
  13246. * Creates a default camera for the scene.
  13247. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13248. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13249. * @param replace has default false, when true replaces the active camera in the scene
  13250. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13251. */
  13252. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13253. /**
  13254. * Creates a default camera and a default light.
  13255. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13256. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13257. * @param replace has the default false, when true replaces the active camera/light in the scene
  13258. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13259. */
  13260. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13261. /**
  13262. * Creates a new sky box
  13263. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13264. * @param environmentTexture defines the texture to use as environment texture
  13265. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13266. * @param scale defines the overall scale of the skybox
  13267. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13268. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13269. * @returns a new mesh holding the sky box
  13270. */
  13271. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13272. /**
  13273. * Creates a new environment
  13274. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13275. * @param options defines the options you can use to configure the environment
  13276. * @returns the new EnvironmentHelper
  13277. */
  13278. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13279. /**
  13280. * Creates a new VREXperienceHelper
  13281. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13282. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13283. * @returns a new VREXperienceHelper
  13284. */
  13285. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13286. }
  13287. }
  13288. declare module BABYLON {
  13289. /**
  13290. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13291. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13292. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13293. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13294. */
  13295. class VideoDome extends TransformNode {
  13296. private _useDirectMapping;
  13297. /**
  13298. * The video texture being displayed on the sphere
  13299. */
  13300. protected _videoTexture: VideoTexture;
  13301. /**
  13302. * Gets the video texture being displayed on the sphere
  13303. */
  13304. readonly videoTexture: VideoTexture;
  13305. /**
  13306. * The skybox material
  13307. */
  13308. protected _material: BackgroundMaterial;
  13309. /**
  13310. * The surface used for the skybox
  13311. */
  13312. protected _mesh: Mesh;
  13313. /**
  13314. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13315. * Also see the options.resolution property.
  13316. */
  13317. fovMultiplier: number;
  13318. /**
  13319. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13320. * @param name Element's name, child elements will append suffixes for their own names.
  13321. * @param urlsOrVideo defines the url(s) or the video element to use
  13322. * @param options An object containing optional or exposed sub element properties
  13323. */
  13324. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13325. resolution?: number;
  13326. clickToPlay?: boolean;
  13327. autoPlay?: boolean;
  13328. loop?: boolean;
  13329. size?: number;
  13330. poster?: string;
  13331. useDirectMapping?: boolean;
  13332. }, scene: Scene);
  13333. /**
  13334. * Releases resources associated with this node.
  13335. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13336. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13337. */
  13338. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13339. }
  13340. }
  13341. declare module BABYLON {
  13342. /**
  13343. * This class can be used to get instrumentation data from a Babylon engine
  13344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13345. */
  13346. class EngineInstrumentation implements IDisposable {
  13347. /**
  13348. * Define the instrumented engine.
  13349. */
  13350. engine: Engine;
  13351. private _captureGPUFrameTime;
  13352. private _gpuFrameTimeToken;
  13353. private _gpuFrameTime;
  13354. private _captureShaderCompilationTime;
  13355. private _shaderCompilationTime;
  13356. private _onBeginFrameObserver;
  13357. private _onEndFrameObserver;
  13358. private _onBeforeShaderCompilationObserver;
  13359. private _onAfterShaderCompilationObserver;
  13360. /**
  13361. * Gets the perf counter used for GPU frame time
  13362. */
  13363. readonly gpuFrameTimeCounter: PerfCounter;
  13364. /**
  13365. * Gets the GPU frame time capture status
  13366. */
  13367. /**
  13368. * Enable or disable the GPU frame time capture
  13369. */
  13370. captureGPUFrameTime: boolean;
  13371. /**
  13372. * Gets the perf counter used for shader compilation time
  13373. */
  13374. readonly shaderCompilationTimeCounter: PerfCounter;
  13375. /**
  13376. * Gets the shader compilation time capture status
  13377. */
  13378. /**
  13379. * Enable or disable the shader compilation time capture
  13380. */
  13381. captureShaderCompilationTime: boolean;
  13382. /**
  13383. * Instantiates a new engine instrumentation.
  13384. * This class can be used to get instrumentation data from a Babylon engine
  13385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13386. * @param engine Defines the engine to instrument
  13387. */
  13388. constructor(
  13389. /**
  13390. * Define the instrumented engine.
  13391. */
  13392. engine: Engine);
  13393. /**
  13394. * Dispose and release associated resources.
  13395. */
  13396. dispose(): void;
  13397. }
  13398. }
  13399. declare module BABYLON {
  13400. /**
  13401. * This class can be used to get instrumentation data from a Babylon engine
  13402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13403. */
  13404. class SceneInstrumentation implements IDisposable {
  13405. /**
  13406. * Defines the scene to instrument
  13407. */
  13408. scene: Scene;
  13409. private _captureActiveMeshesEvaluationTime;
  13410. private _activeMeshesEvaluationTime;
  13411. private _captureRenderTargetsRenderTime;
  13412. private _renderTargetsRenderTime;
  13413. private _captureFrameTime;
  13414. private _frameTime;
  13415. private _captureRenderTime;
  13416. private _renderTime;
  13417. private _captureInterFrameTime;
  13418. private _interFrameTime;
  13419. private _captureParticlesRenderTime;
  13420. private _particlesRenderTime;
  13421. private _captureSpritesRenderTime;
  13422. private _spritesRenderTime;
  13423. private _capturePhysicsTime;
  13424. private _physicsTime;
  13425. private _captureAnimationsTime;
  13426. private _animationsTime;
  13427. private _captureCameraRenderTime;
  13428. private _cameraRenderTime;
  13429. private _onBeforeActiveMeshesEvaluationObserver;
  13430. private _onAfterActiveMeshesEvaluationObserver;
  13431. private _onBeforeRenderTargetsRenderObserver;
  13432. private _onAfterRenderTargetsRenderObserver;
  13433. private _onAfterRenderObserver;
  13434. private _onBeforeDrawPhaseObserver;
  13435. private _onAfterDrawPhaseObserver;
  13436. private _onBeforeAnimationsObserver;
  13437. private _onBeforeParticlesRenderingObserver;
  13438. private _onAfterParticlesRenderingObserver;
  13439. private _onBeforeSpritesRenderingObserver;
  13440. private _onAfterSpritesRenderingObserver;
  13441. private _onBeforePhysicsObserver;
  13442. private _onAfterPhysicsObserver;
  13443. private _onAfterAnimationsObserver;
  13444. private _onBeforeCameraRenderObserver;
  13445. private _onAfterCameraRenderObserver;
  13446. /**
  13447. * Gets the perf counter used for active meshes evaluation time
  13448. */
  13449. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13450. /**
  13451. * Gets the active meshes evaluation time capture status
  13452. */
  13453. /**
  13454. * Enable or disable the active meshes evaluation time capture
  13455. */
  13456. captureActiveMeshesEvaluationTime: boolean;
  13457. /**
  13458. * Gets the perf counter used for render targets render time
  13459. */
  13460. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13461. /**
  13462. * Gets the render targets render time capture status
  13463. */
  13464. /**
  13465. * Enable or disable the render targets render time capture
  13466. */
  13467. captureRenderTargetsRenderTime: boolean;
  13468. /**
  13469. * Gets the perf counter used for particles render time
  13470. */
  13471. readonly particlesRenderTimeCounter: PerfCounter;
  13472. /**
  13473. * Gets the particles render time capture status
  13474. */
  13475. /**
  13476. * Enable or disable the particles render time capture
  13477. */
  13478. captureParticlesRenderTime: boolean;
  13479. /**
  13480. * Gets the perf counter used for sprites render time
  13481. */
  13482. readonly spritesRenderTimeCounter: PerfCounter;
  13483. /**
  13484. * Gets the sprites render time capture status
  13485. */
  13486. /**
  13487. * Enable or disable the sprites render time capture
  13488. */
  13489. captureSpritesRenderTime: boolean;
  13490. /**
  13491. * Gets the perf counter used for physics time
  13492. */
  13493. readonly physicsTimeCounter: PerfCounter;
  13494. /**
  13495. * Gets the physics time capture status
  13496. */
  13497. /**
  13498. * Enable or disable the physics time capture
  13499. */
  13500. capturePhysicsTime: boolean;
  13501. /**
  13502. * Gets the perf counter used for animations time
  13503. */
  13504. readonly animationsTimeCounter: PerfCounter;
  13505. /**
  13506. * Gets the animations time capture status
  13507. */
  13508. /**
  13509. * Enable or disable the animations time capture
  13510. */
  13511. captureAnimationsTime: boolean;
  13512. /**
  13513. * Gets the perf counter used for frame time capture
  13514. */
  13515. readonly frameTimeCounter: PerfCounter;
  13516. /**
  13517. * Gets the frame time capture status
  13518. */
  13519. /**
  13520. * Enable or disable the frame time capture
  13521. */
  13522. captureFrameTime: boolean;
  13523. /**
  13524. * Gets the perf counter used for inter-frames time capture
  13525. */
  13526. readonly interFrameTimeCounter: PerfCounter;
  13527. /**
  13528. * Gets the inter-frames time capture status
  13529. */
  13530. /**
  13531. * Enable or disable the inter-frames time capture
  13532. */
  13533. captureInterFrameTime: boolean;
  13534. /**
  13535. * Gets the perf counter used for render time capture
  13536. */
  13537. readonly renderTimeCounter: PerfCounter;
  13538. /**
  13539. * Gets the render time capture status
  13540. */
  13541. /**
  13542. * Enable or disable the render time capture
  13543. */
  13544. captureRenderTime: boolean;
  13545. /**
  13546. * Gets the perf counter used for camera render time capture
  13547. */
  13548. readonly cameraRenderTimeCounter: PerfCounter;
  13549. /**
  13550. * Gets the camera render time capture status
  13551. */
  13552. /**
  13553. * Enable or disable the camera render time capture
  13554. */
  13555. captureCameraRenderTime: boolean;
  13556. /**
  13557. * Gets the perf counter used for draw calls
  13558. */
  13559. readonly drawCallsCounter: PerfCounter;
  13560. /**
  13561. * Gets the perf counter used for texture collisions
  13562. */
  13563. readonly textureCollisionsCounter: PerfCounter;
  13564. /**
  13565. * Instantiates a new scene instrumentation.
  13566. * This class can be used to get instrumentation data from a Babylon engine
  13567. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13568. * @param scene Defines the scene to instrument
  13569. */
  13570. constructor(
  13571. /**
  13572. * Defines the scene to instrument
  13573. */
  13574. scene: Scene);
  13575. /**
  13576. * Dispose and release associated resources.
  13577. */
  13578. dispose(): void;
  13579. }
  13580. }
  13581. declare module BABYLON {
  13582. /**
  13583. * @hidden
  13584. **/
  13585. class _TimeToken {
  13586. _startTimeQuery: Nullable<WebGLQuery>;
  13587. _endTimeQuery: Nullable<WebGLQuery>;
  13588. _timeElapsedQuery: Nullable<WebGLQuery>;
  13589. _timeElapsedQueryEnded: boolean;
  13590. }
  13591. }
  13592. declare module BABYLON {
  13593. /**
  13594. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  13595. * It controls one of the indiviual texture used in the effect.
  13596. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  13597. */
  13598. class LensFlare {
  13599. /**
  13600. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  13601. */
  13602. size: number;
  13603. /**
  13604. * 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.
  13605. */
  13606. position: number;
  13607. /**
  13608. * Define the lens color.
  13609. */
  13610. color: Color3;
  13611. /**
  13612. * Define the lens texture.
  13613. */
  13614. texture: Nullable<Texture>;
  13615. /**
  13616. * Define the alpha mode to render this particular lens.
  13617. */
  13618. alphaMode: number;
  13619. private _system;
  13620. /**
  13621. * Creates a new Lens Flare.
  13622. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  13623. * It controls one of the indiviual texture used in the effect.
  13624. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  13625. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  13626. * @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.
  13627. * @param color Define the lens color
  13628. * @param imgUrl Define the lens texture url
  13629. * @param system Define the `lensFlareSystem` this flare is part of
  13630. * @returns The newly created Lens Flare
  13631. */
  13632. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  13633. /**
  13634. * Instantiates a new Lens Flare.
  13635. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  13636. * It controls one of the indiviual texture used in the effect.
  13637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  13638. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  13639. * @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.
  13640. * @param color Define the lens color
  13641. * @param imgUrl Define the lens texture url
  13642. * @param system Define the `lensFlareSystem` this flare is part of
  13643. */
  13644. constructor(
  13645. /**
  13646. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  13647. */
  13648. size: number,
  13649. /**
  13650. * 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.
  13651. */
  13652. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  13653. /**
  13654. * Dispose and release the lens flare with its associated resources.
  13655. */
  13656. dispose(): void;
  13657. }
  13658. }
  13659. declare module BABYLON {
  13660. /**
  13661. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  13662. * It is usually composed of several `BABYLON.lensFlare`.
  13663. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  13664. */
  13665. class LensFlareSystem {
  13666. /**
  13667. * Define the name of the lens flare system
  13668. */
  13669. name: string;
  13670. /**
  13671. * List of lens flares used in this system.
  13672. */
  13673. lensFlares: LensFlare[];
  13674. /**
  13675. * Define a limit from the border the lens flare can be visible.
  13676. */
  13677. borderLimit: number;
  13678. /**
  13679. * Define a viewport border we do not want to see the lens flare in.
  13680. */
  13681. viewportBorder: number;
  13682. /**
  13683. * Define a predicate which could limit the list of meshes able to occlude the effect.
  13684. */
  13685. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  13686. /**
  13687. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  13688. */
  13689. layerMask: number;
  13690. /**
  13691. * Define the id of the lens flare system in the scene.
  13692. * (equal to name by default)
  13693. */
  13694. id: string;
  13695. private _scene;
  13696. private _emitter;
  13697. private _vertexBuffers;
  13698. private _indexBuffer;
  13699. private _effect;
  13700. private _positionX;
  13701. private _positionY;
  13702. private _isEnabled;
  13703. /**
  13704. * Instantiates a lens flare system.
  13705. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  13706. * It is usually composed of several `BABYLON.lensFlare`.
  13707. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  13708. * @param name Define the name of the lens flare system in the scene
  13709. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  13710. * @param scene Define the scene the lens flare system belongs to
  13711. */
  13712. constructor(
  13713. /**
  13714. * Define the name of the lens flare system
  13715. */
  13716. name: string, emitter: any, scene: Scene);
  13717. /**
  13718. * Define if the lens flare system is enabled.
  13719. */
  13720. isEnabled: boolean;
  13721. /**
  13722. * Get the scene the effects belongs to.
  13723. * @returns the scene holding the lens flare system
  13724. */
  13725. getScene(): Scene;
  13726. /**
  13727. * Get the emitter of the lens flare system.
  13728. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  13729. * @returns the emitter of the lens flare system
  13730. */
  13731. getEmitter(): any;
  13732. /**
  13733. * Set the emitter of the lens flare system.
  13734. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  13735. * @param newEmitter Define the new emitter of the system
  13736. */
  13737. setEmitter(newEmitter: any): void;
  13738. /**
  13739. * Get the lens flare system emitter position.
  13740. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  13741. * @returns the position
  13742. */
  13743. getEmitterPosition(): Vector3;
  13744. /**
  13745. * @hidden
  13746. */
  13747. computeEffectivePosition(globalViewport: Viewport): boolean;
  13748. /** @hidden */
  13749. _isVisible(): boolean;
  13750. /**
  13751. * @hidden
  13752. */
  13753. render(): boolean;
  13754. /**
  13755. * Dispose and release the lens flare with its associated resources.
  13756. */
  13757. dispose(): void;
  13758. /**
  13759. * Parse a lens flare system from a JSON repressentation
  13760. * @param parsedLensFlareSystem Define the JSON to parse
  13761. * @param scene Define the scene the parsed system should be instantiated in
  13762. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  13763. * @returns the parsed system
  13764. */
  13765. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  13766. /**
  13767. * Serialize the current Lens Flare System into a JSON representation.
  13768. * @returns the serialized JSON
  13769. */
  13770. serialize(): any;
  13771. }
  13772. }
  13773. declare module BABYLON {
  13774. interface AbstractScene {
  13775. /**
  13776. * The list of lens flare system added to the scene
  13777. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  13778. */
  13779. lensFlareSystems: Array<LensFlareSystem>;
  13780. /**
  13781. * Removes the given lens flare system from this scene.
  13782. * @param toRemove The lens flare system to remove
  13783. * @returns The index of the removed lens flare system
  13784. */
  13785. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  13786. /**
  13787. * Adds the given lens flare system to this scene
  13788. * @param newLensFlareSystem The lens flare system to add
  13789. */
  13790. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  13791. /**
  13792. * Gets a lens flare system using its name
  13793. * @param name defines the name to look for
  13794. * @returns the lens flare system or null if not found
  13795. */
  13796. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  13797. /**
  13798. * Gets a lens flare system using its id
  13799. * @param id defines the id to look for
  13800. * @returns the lens flare system or null if not found
  13801. */
  13802. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  13803. }
  13804. /**
  13805. * Defines the lens flare scene component responsible to manage any lens flares
  13806. * in a given scene.
  13807. */
  13808. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  13809. /**
  13810. * The component name helpfull to identify the component in the list of scene components.
  13811. */
  13812. readonly name: string;
  13813. /**
  13814. * The scene the component belongs to.
  13815. */
  13816. scene: Scene;
  13817. /**
  13818. * Creates a new instance of the component for the given scene
  13819. * @param scene Defines the scene to register the component in
  13820. */
  13821. constructor(scene: Scene);
  13822. /**
  13823. * Registers the component in a given scene
  13824. */
  13825. register(): void;
  13826. /**
  13827. * Rebuilds the elements related to this component in case of
  13828. * context lost for instance.
  13829. */
  13830. rebuild(): void;
  13831. /**
  13832. * Adds all the element from the container to the scene
  13833. * @param container the container holding the elements
  13834. */
  13835. addFromContainer(container: AbstractScene): void;
  13836. /**
  13837. * Removes all the elements in the container from the scene
  13838. * @param container contains the elements to remove
  13839. */
  13840. removeFromContainer(container: AbstractScene): void;
  13841. /**
  13842. * Serializes the component data to the specified json object
  13843. * @param serializationObject The object to serialize to
  13844. */
  13845. serialize(serializationObject: any): void;
  13846. /**
  13847. * Disposes the component and the associated ressources.
  13848. */
  13849. dispose(): void;
  13850. private _draw;
  13851. }
  13852. }
  13853. declare module BABYLON {
  13854. /**
  13855. * Effect layer options. This helps customizing the behaviour
  13856. * of the effect layer.
  13857. */
  13858. interface IEffectLayerOptions {
  13859. /**
  13860. * Multiplication factor apply to the canvas size to compute the render target size
  13861. * used to generated the objects (the smaller the faster).
  13862. */
  13863. mainTextureRatio: number;
  13864. /**
  13865. * Enforces a fixed size texture to ensure effect stability across devices.
  13866. */
  13867. mainTextureFixedSize?: number;
  13868. /**
  13869. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  13870. */
  13871. alphaBlendingMode: number;
  13872. /**
  13873. * The camera attached to the layer.
  13874. */
  13875. camera: Nullable<Camera>;
  13876. /**
  13877. * The rendering group to draw the layer in.
  13878. */
  13879. renderingGroupId: number;
  13880. }
  13881. /**
  13882. * The effect layer Helps adding post process effect blended with the main pass.
  13883. *
  13884. * This can be for instance use to generate glow or higlight effects on the scene.
  13885. *
  13886. * The effect layer class can not be used directly and is intented to inherited from to be
  13887. * customized per effects.
  13888. */
  13889. abstract class EffectLayer {
  13890. private _vertexBuffers;
  13891. private _indexBuffer;
  13892. private _cachedDefines;
  13893. private _effectLayerMapGenerationEffect;
  13894. private _effectLayerOptions;
  13895. private _mergeEffect;
  13896. protected _scene: Scene;
  13897. protected _engine: Engine;
  13898. protected _maxSize: number;
  13899. protected _mainTextureDesiredSize: ISize;
  13900. protected _mainTexture: RenderTargetTexture;
  13901. protected _shouldRender: boolean;
  13902. protected _postProcesses: PostProcess[];
  13903. protected _textures: BaseTexture[];
  13904. protected _emissiveTextureAndColor: {
  13905. texture: Nullable<BaseTexture>;
  13906. color: Color4;
  13907. };
  13908. /**
  13909. * The name of the layer
  13910. */
  13911. name: string;
  13912. /**
  13913. * The clear color of the texture used to generate the glow map.
  13914. */
  13915. neutralColor: Color4;
  13916. /**
  13917. * Specifies wether the highlight layer is enabled or not.
  13918. */
  13919. isEnabled: boolean;
  13920. /**
  13921. * Gets the camera attached to the layer.
  13922. */
  13923. readonly camera: Nullable<Camera>;
  13924. /**
  13925. * Gets the rendering group id the layer should render in.
  13926. */
  13927. readonly renderingGroupId: number;
  13928. /**
  13929. * An event triggered when the effect layer has been disposed.
  13930. */
  13931. onDisposeObservable: Observable<EffectLayer>;
  13932. /**
  13933. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  13934. */
  13935. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  13936. /**
  13937. * An event triggered when the generated texture is being merged in the scene.
  13938. */
  13939. onBeforeComposeObservable: Observable<EffectLayer>;
  13940. /**
  13941. * An event triggered when the generated texture has been merged in the scene.
  13942. */
  13943. onAfterComposeObservable: Observable<EffectLayer>;
  13944. /**
  13945. * An event triggered when the efffect layer changes its size.
  13946. */
  13947. onSizeChangedObservable: Observable<EffectLayer>;
  13948. /**
  13949. * Instantiates a new effect Layer and references it in the scene.
  13950. * @param name The name of the layer
  13951. * @param scene The scene to use the layer in
  13952. */
  13953. constructor(
  13954. /** The Friendly of the effect in the scene */
  13955. name: string, scene: Scene);
  13956. /**
  13957. * Get the effect name of the layer.
  13958. * @return The effect name
  13959. */
  13960. abstract getEffectName(): string;
  13961. /**
  13962. * Checks for the readiness of the element composing the layer.
  13963. * @param subMesh the mesh to check for
  13964. * @param useInstances specify wether or not to use instances to render the mesh
  13965. * @return true if ready otherwise, false
  13966. */
  13967. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  13968. /**
  13969. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  13970. * @returns true if the effect requires stencil during the main canvas render pass.
  13971. */
  13972. abstract needStencil(): boolean;
  13973. /**
  13974. * Create the merge effect. This is the shader use to blit the information back
  13975. * to the main canvas at the end of the scene rendering.
  13976. * @returns The effect containing the shader used to merge the effect on the main canvas
  13977. */
  13978. protected abstract _createMergeEffect(): Effect;
  13979. /**
  13980. * Creates the render target textures and post processes used in the effect layer.
  13981. */
  13982. protected abstract _createTextureAndPostProcesses(): void;
  13983. /**
  13984. * Implementation specific of rendering the generating effect on the main canvas.
  13985. * @param effect The effect used to render through
  13986. */
  13987. protected abstract _internalRender(effect: Effect): void;
  13988. /**
  13989. * Sets the required values for both the emissive texture and and the main color.
  13990. */
  13991. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  13992. /**
  13993. * Free any resources and references associated to a mesh.
  13994. * Internal use
  13995. * @param mesh The mesh to free.
  13996. */
  13997. abstract _disposeMesh(mesh: Mesh): void;
  13998. /**
  13999. * Serializes this layer (Glow or Highlight for example)
  14000. * @returns a serialized layer object
  14001. */
  14002. abstract serialize?(): any;
  14003. /**
  14004. * Initializes the effect layer with the required options.
  14005. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14006. */
  14007. protected _init(options: Partial<IEffectLayerOptions>): void;
  14008. /**
  14009. * Generates the index buffer of the full screen quad blending to the main canvas.
  14010. */
  14011. private _generateIndexBuffer;
  14012. /**
  14013. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14014. */
  14015. private _genrateVertexBuffer;
  14016. /**
  14017. * Sets the main texture desired size which is the closest power of two
  14018. * of the engine canvas size.
  14019. */
  14020. private _setMainTextureSize;
  14021. /**
  14022. * Creates the main texture for the effect layer.
  14023. */
  14024. protected _createMainTexture(): void;
  14025. /**
  14026. * Checks for the readiness of the element composing the layer.
  14027. * @param subMesh the mesh to check for
  14028. * @param useInstances specify wether or not to use instances to render the mesh
  14029. * @param emissiveTexture the associated emissive texture used to generate the glow
  14030. * @return true if ready otherwise, false
  14031. */
  14032. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14033. /**
  14034. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14035. */
  14036. render(): void;
  14037. /**
  14038. * Determine if a given mesh will be used in the current effect.
  14039. * @param mesh mesh to test
  14040. * @returns true if the mesh will be used
  14041. */
  14042. hasMesh(mesh: AbstractMesh): boolean;
  14043. /**
  14044. * Returns true if the layer contains information to display, otherwise false.
  14045. * @returns true if the glow layer should be rendered
  14046. */
  14047. shouldRender(): boolean;
  14048. /**
  14049. * Returns true if the mesh should render, otherwise false.
  14050. * @param mesh The mesh to render
  14051. * @returns true if it should render otherwise false
  14052. */
  14053. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14054. /**
  14055. * Returns true if the mesh should render, otherwise false.
  14056. * @param mesh The mesh to render
  14057. * @returns true if it should render otherwise false
  14058. */
  14059. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14060. /**
  14061. * Renders the submesh passed in parameter to the generation map.
  14062. */
  14063. protected _renderSubMesh(subMesh: SubMesh): void;
  14064. /**
  14065. * Rebuild the required buffers.
  14066. * @hidden Internal use only.
  14067. */
  14068. _rebuild(): void;
  14069. /**
  14070. * Dispose only the render target textures and post process.
  14071. */
  14072. private _disposeTextureAndPostProcesses;
  14073. /**
  14074. * Dispose the highlight layer and free resources.
  14075. */
  14076. dispose(): void;
  14077. /**
  14078. * Gets the class name of the effect layer
  14079. * @returns the string with the class name of the effect layer
  14080. */
  14081. getClassName(): string;
  14082. /**
  14083. * Creates an effect layer from parsed effect layer data
  14084. * @param parsedEffectLayer defines effect layer data
  14085. * @param scene defines the current scene
  14086. * @param rootUrl defines the root URL containing the effect layer information
  14087. * @returns a parsed effect Layer
  14088. */
  14089. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14090. }
  14091. }
  14092. declare module BABYLON {
  14093. interface AbstractScene {
  14094. /**
  14095. * The list of effect layers (highlights/glow) added to the scene
  14096. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14097. * @see http://doc.babylonjs.com/how_to/glow_layer
  14098. */
  14099. effectLayers: Array<EffectLayer>;
  14100. /**
  14101. * Removes the given effect layer from this scene.
  14102. * @param toRemove defines the effect layer to remove
  14103. * @returns the index of the removed effect layer
  14104. */
  14105. removeEffectLayer(toRemove: EffectLayer): number;
  14106. /**
  14107. * Adds the given effect layer to this scene
  14108. * @param newEffectLayer defines the effect layer to add
  14109. */
  14110. addEffectLayer(newEffectLayer: EffectLayer): void;
  14111. }
  14112. /**
  14113. * Defines the layer scene component responsible to manage any effect layers
  14114. * in a given scene.
  14115. */
  14116. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14117. /**
  14118. * The component name helpfull to identify the component in the list of scene components.
  14119. */
  14120. readonly name: string;
  14121. /**
  14122. * The scene the component belongs to.
  14123. */
  14124. scene: Scene;
  14125. private _engine;
  14126. private _renderEffects;
  14127. private _needStencil;
  14128. private _previousStencilState;
  14129. /**
  14130. * Creates a new instance of the component for the given scene
  14131. * @param scene Defines the scene to register the component in
  14132. */
  14133. constructor(scene: Scene);
  14134. /**
  14135. * Registers the component in a given scene
  14136. */
  14137. register(): void;
  14138. /**
  14139. * Rebuilds the elements related to this component in case of
  14140. * context lost for instance.
  14141. */
  14142. rebuild(): void;
  14143. /**
  14144. * Serializes the component data to the specified json object
  14145. * @param serializationObject The object to serialize to
  14146. */
  14147. serialize(serializationObject: any): void;
  14148. /**
  14149. * Adds all the element from the container to the scene
  14150. * @param container the container holding the elements
  14151. */
  14152. addFromContainer(container: AbstractScene): void;
  14153. /**
  14154. * Removes all the elements in the container from the scene
  14155. * @param container contains the elements to remove
  14156. */
  14157. removeFromContainer(container: AbstractScene): void;
  14158. /**
  14159. * Disposes the component and the associated ressources.
  14160. */
  14161. dispose(): void;
  14162. private _isReadyForMesh;
  14163. private _renderMainTexture;
  14164. private _setStencil;
  14165. private _setStencilBack;
  14166. private _draw;
  14167. private _drawCamera;
  14168. private _drawRenderingGroup;
  14169. }
  14170. }
  14171. declare module BABYLON {
  14172. interface AbstractScene {
  14173. /**
  14174. * Return a the first highlight layer of the scene with a given name.
  14175. * @param name The name of the highlight layer to look for.
  14176. * @return The highlight layer if found otherwise null.
  14177. */
  14178. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14179. }
  14180. /**
  14181. * Glow layer options. This helps customizing the behaviour
  14182. * of the glow layer.
  14183. */
  14184. interface IGlowLayerOptions {
  14185. /**
  14186. * Multiplication factor apply to the canvas size to compute the render target size
  14187. * used to generated the glowing objects (the smaller the faster).
  14188. */
  14189. mainTextureRatio: number;
  14190. /**
  14191. * Enforces a fixed size texture to ensure resize independant blur.
  14192. */
  14193. mainTextureFixedSize?: number;
  14194. /**
  14195. * How big is the kernel of the blur texture.
  14196. */
  14197. blurKernelSize: number;
  14198. /**
  14199. * The camera attached to the layer.
  14200. */
  14201. camera: Nullable<Camera>;
  14202. /**
  14203. * Enable MSAA by chosing the number of samples.
  14204. */
  14205. mainTextureSamples?: number;
  14206. /**
  14207. * The rendering group to draw the layer in.
  14208. */
  14209. renderingGroupId: number;
  14210. }
  14211. /**
  14212. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14213. *
  14214. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14215. * glowy meshes to your scene.
  14216. *
  14217. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14218. */
  14219. class GlowLayer extends EffectLayer {
  14220. /**
  14221. * Effect Name of the layer.
  14222. */
  14223. static readonly EffectName: string;
  14224. /**
  14225. * The default blur kernel size used for the glow.
  14226. */
  14227. static DefaultBlurKernelSize: number;
  14228. /**
  14229. * The default texture size ratio used for the glow.
  14230. */
  14231. static DefaultTextureRatio: number;
  14232. /**
  14233. * Sets the kernel size of the blur.
  14234. */
  14235. /**
  14236. * Gets the kernel size of the blur.
  14237. */
  14238. blurKernelSize: number;
  14239. /**
  14240. * Sets the glow intensity.
  14241. */
  14242. /**
  14243. * Gets the glow intensity.
  14244. */
  14245. intensity: number;
  14246. private _options;
  14247. private _intensity;
  14248. private _horizontalBlurPostprocess1;
  14249. private _verticalBlurPostprocess1;
  14250. private _horizontalBlurPostprocess2;
  14251. private _verticalBlurPostprocess2;
  14252. private _blurTexture1;
  14253. private _blurTexture2;
  14254. private _postProcesses1;
  14255. private _postProcesses2;
  14256. private _includedOnlyMeshes;
  14257. private _excludedMeshes;
  14258. /**
  14259. * Callback used to let the user override the color selection on a per mesh basis
  14260. */
  14261. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14262. /**
  14263. * Callback used to let the user override the texture selection on a per mesh basis
  14264. */
  14265. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14266. /**
  14267. * Instantiates a new glow Layer and references it to the scene.
  14268. * @param name The name of the layer
  14269. * @param scene The scene to use the layer in
  14270. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14271. */
  14272. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14273. /**
  14274. * Get the effect name of the layer.
  14275. * @return The effect name
  14276. */
  14277. getEffectName(): string;
  14278. /**
  14279. * Create the merge effect. This is the shader use to blit the information back
  14280. * to the main canvas at the end of the scene rendering.
  14281. */
  14282. protected _createMergeEffect(): Effect;
  14283. /**
  14284. * Creates the render target textures and post processes used in the glow layer.
  14285. */
  14286. protected _createTextureAndPostProcesses(): void;
  14287. /**
  14288. * Checks for the readiness of the element composing the layer.
  14289. * @param subMesh the mesh to check for
  14290. * @param useInstances specify wether or not to use instances to render the mesh
  14291. * @param emissiveTexture the associated emissive texture used to generate the glow
  14292. * @return true if ready otherwise, false
  14293. */
  14294. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14295. /**
  14296. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14297. */
  14298. needStencil(): boolean;
  14299. /**
  14300. * Implementation specific of rendering the generating effect on the main canvas.
  14301. * @param effect The effect used to render through
  14302. */
  14303. protected _internalRender(effect: Effect): void;
  14304. /**
  14305. * Sets the required values for both the emissive texture and and the main color.
  14306. */
  14307. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14308. /**
  14309. * Returns true if the mesh should render, otherwise false.
  14310. * @param mesh The mesh to render
  14311. * @returns true if it should render otherwise false
  14312. */
  14313. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14314. /**
  14315. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14316. * @param mesh The mesh to exclude from the glow layer
  14317. */
  14318. addExcludedMesh(mesh: Mesh): void;
  14319. /**
  14320. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14321. * @param mesh The mesh to remove
  14322. */
  14323. removeExcludedMesh(mesh: Mesh): void;
  14324. /**
  14325. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14326. * @param mesh The mesh to include in the glow layer
  14327. */
  14328. addIncludedOnlyMesh(mesh: Mesh): void;
  14329. /**
  14330. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14331. * @param mesh The mesh to remove
  14332. */
  14333. removeIncludedOnlyMesh(mesh: Mesh): void;
  14334. /**
  14335. * Determine if a given mesh will be used in the glow layer
  14336. * @param mesh The mesh to test
  14337. * @returns true if the mesh will be highlighted by the current glow layer
  14338. */
  14339. hasMesh(mesh: AbstractMesh): boolean;
  14340. /**
  14341. * Free any resources and references associated to a mesh.
  14342. * Internal use
  14343. * @param mesh The mesh to free.
  14344. * @hidden
  14345. */
  14346. _disposeMesh(mesh: Mesh): void;
  14347. /**
  14348. * Gets the class name of the effect layer
  14349. * @returns the string with the class name of the effect layer
  14350. */
  14351. getClassName(): string;
  14352. /**
  14353. * Serializes this glow layer
  14354. * @returns a serialized glow layer object
  14355. */
  14356. serialize(): any;
  14357. /**
  14358. * Creates a Glow Layer from parsed glow layer data
  14359. * @param parsedGlowLayer defines glow layer data
  14360. * @param scene defines the current scene
  14361. * @param rootUrl defines the root URL containing the glow layer information
  14362. * @returns a parsed Glow Layer
  14363. */
  14364. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14365. }
  14366. }
  14367. declare module BABYLON {
  14368. interface AbstractScene {
  14369. /**
  14370. * Return a the first highlight layer of the scene with a given name.
  14371. * @param name The name of the highlight layer to look for.
  14372. * @return The highlight layer if found otherwise null.
  14373. */
  14374. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14375. }
  14376. /**
  14377. * Highlight layer options. This helps customizing the behaviour
  14378. * of the highlight layer.
  14379. */
  14380. interface IHighlightLayerOptions {
  14381. /**
  14382. * Multiplication factor apply to the canvas size to compute the render target size
  14383. * used to generated the glowing objects (the smaller the faster).
  14384. */
  14385. mainTextureRatio: number;
  14386. /**
  14387. * Enforces a fixed size texture to ensure resize independant blur.
  14388. */
  14389. mainTextureFixedSize?: number;
  14390. /**
  14391. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14392. * of the picture to blur (the smaller the faster).
  14393. */
  14394. blurTextureSizeRatio: number;
  14395. /**
  14396. * How big in texel of the blur texture is the vertical blur.
  14397. */
  14398. blurVerticalSize: number;
  14399. /**
  14400. * How big in texel of the blur texture is the horizontal blur.
  14401. */
  14402. blurHorizontalSize: number;
  14403. /**
  14404. * Alpha blending mode used to apply the blur. Default is combine.
  14405. */
  14406. alphaBlendingMode: number;
  14407. /**
  14408. * The camera attached to the layer.
  14409. */
  14410. camera: Nullable<Camera>;
  14411. /**
  14412. * Should we display highlight as a solid stroke?
  14413. */
  14414. isStroke?: boolean;
  14415. /**
  14416. * The rendering group to draw the layer in.
  14417. */
  14418. renderingGroupId: number;
  14419. }
  14420. /**
  14421. * The highlight layer Helps adding a glow effect around a mesh.
  14422. *
  14423. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14424. * glowy meshes to your scene.
  14425. *
  14426. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14427. */
  14428. class HighlightLayer extends EffectLayer {
  14429. name: string;
  14430. /**
  14431. * Effect Name of the highlight layer.
  14432. */
  14433. static readonly EffectName: string;
  14434. /**
  14435. * The neutral color used during the preparation of the glow effect.
  14436. * This is black by default as the blend operation is a blend operation.
  14437. */
  14438. static NeutralColor: Color4;
  14439. /**
  14440. * Stencil value used for glowing meshes.
  14441. */
  14442. static GlowingMeshStencilReference: number;
  14443. /**
  14444. * Stencil value used for the other meshes in the scene.
  14445. */
  14446. static NormalMeshStencilReference: number;
  14447. /**
  14448. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14449. */
  14450. innerGlow: boolean;
  14451. /**
  14452. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14453. */
  14454. outerGlow: boolean;
  14455. /**
  14456. * Specifies the horizontal size of the blur.
  14457. */
  14458. /**
  14459. * Gets the horizontal size of the blur.
  14460. */
  14461. blurHorizontalSize: number;
  14462. /**
  14463. * Specifies the vertical size of the blur.
  14464. */
  14465. /**
  14466. * Gets the vertical size of the blur.
  14467. */
  14468. blurVerticalSize: number;
  14469. /**
  14470. * An event triggered when the highlight layer is being blurred.
  14471. */
  14472. onBeforeBlurObservable: Observable<HighlightLayer>;
  14473. /**
  14474. * An event triggered when the highlight layer has been blurred.
  14475. */
  14476. onAfterBlurObservable: Observable<HighlightLayer>;
  14477. private _instanceGlowingMeshStencilReference;
  14478. private _options;
  14479. private _downSamplePostprocess;
  14480. private _horizontalBlurPostprocess;
  14481. private _verticalBlurPostprocess;
  14482. private _blurTexture;
  14483. private _meshes;
  14484. private _excludedMeshes;
  14485. /**
  14486. * Instantiates a new highlight Layer and references it to the scene..
  14487. * @param name The name of the layer
  14488. * @param scene The scene to use the layer in
  14489. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14490. */
  14491. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14492. /**
  14493. * Get the effect name of the layer.
  14494. * @return The effect name
  14495. */
  14496. getEffectName(): string;
  14497. /**
  14498. * Create the merge effect. This is the shader use to blit the information back
  14499. * to the main canvas at the end of the scene rendering.
  14500. */
  14501. protected _createMergeEffect(): Effect;
  14502. /**
  14503. * Creates the render target textures and post processes used in the highlight layer.
  14504. */
  14505. protected _createTextureAndPostProcesses(): void;
  14506. /**
  14507. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14508. */
  14509. needStencil(): boolean;
  14510. /**
  14511. * Checks for the readiness of the element composing the layer.
  14512. * @param subMesh the mesh to check for
  14513. * @param useInstances specify wether or not to use instances to render the mesh
  14514. * @param emissiveTexture the associated emissive texture used to generate the glow
  14515. * @return true if ready otherwise, false
  14516. */
  14517. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14518. /**
  14519. * Implementation specific of rendering the generating effect on the main canvas.
  14520. * @param effect The effect used to render through
  14521. */
  14522. protected _internalRender(effect: Effect): void;
  14523. /**
  14524. * Returns true if the layer contains information to display, otherwise false.
  14525. */
  14526. shouldRender(): boolean;
  14527. /**
  14528. * Returns true if the mesh should render, otherwise false.
  14529. * @param mesh The mesh to render
  14530. * @returns true if it should render otherwise false
  14531. */
  14532. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14533. /**
  14534. * Sets the required values for both the emissive texture and and the main color.
  14535. */
  14536. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14537. /**
  14538. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14539. * @param mesh The mesh to exclude from the highlight layer
  14540. */
  14541. addExcludedMesh(mesh: Mesh): void;
  14542. /**
  14543. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14544. * @param mesh The mesh to highlight
  14545. */
  14546. removeExcludedMesh(mesh: Mesh): void;
  14547. /**
  14548. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14549. * @param mesh mesh to test
  14550. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14551. */
  14552. hasMesh(mesh: AbstractMesh): boolean;
  14553. /**
  14554. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14555. * @param mesh The mesh to highlight
  14556. * @param color The color of the highlight
  14557. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14558. */
  14559. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14560. /**
  14561. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14562. * @param mesh The mesh to highlight
  14563. */
  14564. removeMesh(mesh: Mesh): void;
  14565. /**
  14566. * Force the stencil to the normal expected value for none glowing parts
  14567. */
  14568. private _defaultStencilReference;
  14569. /**
  14570. * Free any resources and references associated to a mesh.
  14571. * Internal use
  14572. * @param mesh The mesh to free.
  14573. * @hidden
  14574. */
  14575. _disposeMesh(mesh: Mesh): void;
  14576. /**
  14577. * Dispose the highlight layer and free resources.
  14578. */
  14579. dispose(): void;
  14580. /**
  14581. * Gets the class name of the effect layer
  14582. * @returns the string with the class name of the effect layer
  14583. */
  14584. getClassName(): string;
  14585. /**
  14586. * Serializes this Highlight layer
  14587. * @returns a serialized Highlight layer object
  14588. */
  14589. serialize(): any;
  14590. /**
  14591. * Creates a Highlight layer from parsed Highlight layer data
  14592. * @param parsedHightlightLayer defines the Highlight layer data
  14593. * @param scene defines the current scene
  14594. * @param rootUrl defines the root URL containing the Highlight layer information
  14595. * @returns a parsed Highlight layer
  14596. */
  14597. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14598. }
  14599. }
  14600. declare module BABYLON {
  14601. /**
  14602. * This represents a full screen 2d layer.
  14603. * This can be usefull to display a picture in the background of your scene for instance.
  14604. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14605. */
  14606. class Layer {
  14607. /**
  14608. * Define the name of the layer.
  14609. */
  14610. name: string;
  14611. /**
  14612. * Define the texture the layer should display.
  14613. */
  14614. texture: Nullable<Texture>;
  14615. /**
  14616. * Is the layer in background or foreground.
  14617. */
  14618. isBackground: boolean;
  14619. /**
  14620. * Define the color of the layer (instead of texture).
  14621. */
  14622. color: Color4;
  14623. /**
  14624. * Define the scale of the layer in order to zoom in out of the texture.
  14625. */
  14626. scale: Vector2;
  14627. /**
  14628. * Define an offset for the layer in order to shift the texture.
  14629. */
  14630. offset: Vector2;
  14631. /**
  14632. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14633. */
  14634. alphaBlendingMode: number;
  14635. /**
  14636. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14637. * Alpha test will not mix with the background color in case of transparency.
  14638. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14639. */
  14640. alphaTest: boolean;
  14641. /**
  14642. * Define a mask to restrict the layer to only some of the scene cameras.
  14643. */
  14644. layerMask: number;
  14645. private _scene;
  14646. private _vertexBuffers;
  14647. private _indexBuffer;
  14648. private _effect;
  14649. private _alphaTestEffect;
  14650. /**
  14651. * An event triggered when the layer is disposed.
  14652. */
  14653. onDisposeObservable: Observable<Layer>;
  14654. private _onDisposeObserver;
  14655. /**
  14656. * Back compatibility with callback before the onDisposeObservable existed.
  14657. * The set callback will be triggered when the layer has been disposed.
  14658. */
  14659. onDispose: () => void;
  14660. /**
  14661. * An event triggered before rendering the scene
  14662. */
  14663. onBeforeRenderObservable: Observable<Layer>;
  14664. private _onBeforeRenderObserver;
  14665. /**
  14666. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14667. * The set callback will be triggered just before rendering the layer.
  14668. */
  14669. onBeforeRender: () => void;
  14670. /**
  14671. * An event triggered after rendering the scene
  14672. */
  14673. onAfterRenderObservable: Observable<Layer>;
  14674. private _onAfterRenderObserver;
  14675. /**
  14676. * Back compatibility with callback before the onAfterRenderObservable existed.
  14677. * The set callback will be triggered just after rendering the layer.
  14678. */
  14679. onAfterRender: () => void;
  14680. /**
  14681. * Instantiates a new layer.
  14682. * This represents a full screen 2d layer.
  14683. * This can be usefull to display a picture in the background of your scene for instance.
  14684. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14685. * @param name Define the name of the layer in the scene
  14686. * @param imgUrl Define the url of the texture to display in the layer
  14687. * @param scene Define the scene the layer belongs to
  14688. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14689. * @param color Defines a color for the layer
  14690. */
  14691. constructor(
  14692. /**
  14693. * Define the name of the layer.
  14694. */
  14695. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14696. private _createIndexBuffer;
  14697. /** @hidden */
  14698. _rebuild(): void;
  14699. /**
  14700. * Renders the layer in the scene.
  14701. */
  14702. render(): void;
  14703. /**
  14704. * Disposes and releases the associated ressources.
  14705. */
  14706. dispose(): void;
  14707. }
  14708. }
  14709. declare module BABYLON {
  14710. interface AbstractScene {
  14711. /**
  14712. * The list of layers (background and foreground) of the scene
  14713. */
  14714. layers: Array<Layer>;
  14715. }
  14716. /**
  14717. * Defines the layer scene component responsible to manage any layers
  14718. * in a given scene.
  14719. */
  14720. class LayerSceneComponent implements ISceneComponent {
  14721. /**
  14722. * The component name helpfull to identify the component in the list of scene components.
  14723. */
  14724. readonly name: string;
  14725. /**
  14726. * The scene the component belongs to.
  14727. */
  14728. scene: Scene;
  14729. private _engine;
  14730. /**
  14731. * Creates a new instance of the component for the given scene
  14732. * @param scene Defines the scene to register the component in
  14733. */
  14734. constructor(scene: Scene);
  14735. /**
  14736. * Registers the component in a given scene
  14737. */
  14738. register(): void;
  14739. /**
  14740. * Rebuilds the elements related to this component in case of
  14741. * context lost for instance.
  14742. */
  14743. rebuild(): void;
  14744. /**
  14745. * Disposes the component and the associated ressources.
  14746. */
  14747. dispose(): void;
  14748. private _draw;
  14749. private _drawBackground;
  14750. private _drawForeground;
  14751. }
  14752. }
  14753. declare module BABYLON {
  14754. /**
  14755. * A directional light is defined by a direction (what a surprise!).
  14756. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  14757. * 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.
  14758. * Documentation: https://doc.babylonjs.com/babylon101/lights
  14759. */
  14760. class DirectionalLight extends ShadowLight {
  14761. private _shadowFrustumSize;
  14762. /**
  14763. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  14764. */
  14765. /**
  14766. * Specifies a fix frustum size for the shadow generation.
  14767. */
  14768. shadowFrustumSize: number;
  14769. private _shadowOrthoScale;
  14770. /**
  14771. * Gets the shadow projection scale against the optimal computed one.
  14772. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14773. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14774. */
  14775. /**
  14776. * Sets the shadow projection scale against the optimal computed one.
  14777. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  14778. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  14779. */
  14780. shadowOrthoScale: number;
  14781. /**
  14782. * Automatically compute the projection matrix to best fit (including all the casters)
  14783. * on each frame.
  14784. */
  14785. autoUpdateExtends: boolean;
  14786. private _orthoLeft;
  14787. private _orthoRight;
  14788. private _orthoTop;
  14789. private _orthoBottom;
  14790. /**
  14791. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  14792. * The directional light is emitted from everywhere in the given direction.
  14793. * It can cast shadows.
  14794. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14795. * @param name The friendly name of the light
  14796. * @param direction The direction of the light
  14797. * @param scene The scene the light belongs to
  14798. */
  14799. constructor(name: string, direction: Vector3, scene: Scene);
  14800. /**
  14801. * Returns the string "DirectionalLight".
  14802. * @return The class name
  14803. */
  14804. getClassName(): string;
  14805. /**
  14806. * Returns the integer 1.
  14807. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14808. */
  14809. getTypeID(): number;
  14810. /**
  14811. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  14812. * Returns the DirectionalLight Shadow projection matrix.
  14813. */
  14814. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14815. /**
  14816. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  14817. * Returns the DirectionalLight Shadow projection matrix.
  14818. */
  14819. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  14820. /**
  14821. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  14822. * Returns the DirectionalLight Shadow projection matrix.
  14823. */
  14824. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  14825. protected _buildUniformLayout(): void;
  14826. /**
  14827. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  14828. * @param effect The effect to update
  14829. * @param lightIndex The index of the light in the effect to update
  14830. * @returns The directional light
  14831. */
  14832. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  14833. /**
  14834. * Gets the minZ used for shadow according to both the scene and the light.
  14835. *
  14836. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14837. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14838. * @param activeCamera The camera we are returning the min for
  14839. * @returns the depth min z
  14840. */
  14841. getDepthMinZ(activeCamera: Camera): number;
  14842. /**
  14843. * Gets the maxZ used for shadow according to both the scene and the light.
  14844. *
  14845. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  14846. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  14847. * @param activeCamera The camera we are returning the max for
  14848. * @returns the depth max z
  14849. */
  14850. getDepthMaxZ(activeCamera: Camera): number;
  14851. /**
  14852. * Prepares the list of defines specific to the light type.
  14853. * @param defines the list of defines
  14854. * @param lightIndex defines the index of the light for the effect
  14855. */
  14856. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14857. }
  14858. }
  14859. declare module BABYLON {
  14860. /**
  14861. * The HemisphericLight simulates the ambient environment light,
  14862. * so the passed direction is the light reflection direction, not the incoming direction.
  14863. */
  14864. class HemisphericLight extends Light {
  14865. /**
  14866. * The groundColor is the light in the opposite direction to the one specified during creation.
  14867. * 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.
  14868. */
  14869. groundColor: Color3;
  14870. /**
  14871. * The light reflection direction, not the incoming direction.
  14872. */
  14873. direction: Vector3;
  14874. /**
  14875. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14876. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14877. * The HemisphericLight can't cast shadows.
  14878. * Documentation : http://doc.babylonjs.com/tutorials/lights
  14879. * @param name The friendly name of the light
  14880. * @param direction The direction of the light reflection
  14881. * @param scene The scene the light belongs to
  14882. */
  14883. constructor(name: string, direction: Vector3, scene: Scene);
  14884. protected _buildUniformLayout(): void;
  14885. /**
  14886. * Returns the string "HemisphericLight".
  14887. * @return The class name
  14888. */
  14889. getClassName(): string;
  14890. /**
  14891. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14892. * Returns the updated direction.
  14893. * @param target The target the direction should point to
  14894. * @return The computed direction
  14895. */
  14896. setDirectionToTarget(target: Vector3): Vector3;
  14897. /**
  14898. * Returns the shadow generator associated to the light.
  14899. * @returns Always null for hemispheric lights because it does not support shadows.
  14900. */
  14901. getShadowGenerator(): Nullable<IShadowGenerator>;
  14902. /**
  14903. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14904. * @param effect The effect to update
  14905. * @param lightIndex The index of the light in the effect to update
  14906. * @returns The hemispheric light
  14907. */
  14908. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14909. /**
  14910. * Computes the world matrix of the node
  14911. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14912. * @param useWasUpdatedFlag defines a reserved property
  14913. * @returns the world matrix
  14914. */
  14915. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  14916. /**
  14917. * Returns the integer 3.
  14918. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14919. */
  14920. getTypeID(): number;
  14921. /**
  14922. * Prepares the list of defines specific to the light type.
  14923. * @param defines the list of defines
  14924. * @param lightIndex defines the index of the light for the effect
  14925. */
  14926. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14927. }
  14928. }
  14929. declare module BABYLON {
  14930. /**
  14931. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  14932. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  14933. * 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.
  14934. */
  14935. abstract class Light extends Node {
  14936. /**
  14937. * Falloff Default: light is falling off following the material specification:
  14938. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  14939. */
  14940. static readonly FALLOFF_DEFAULT: number;
  14941. /**
  14942. * Falloff Physical: light is falling off following the inverse squared distance law.
  14943. */
  14944. static readonly FALLOFF_PHYSICAL: number;
  14945. /**
  14946. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  14947. * to enhance interoperability with other engines.
  14948. */
  14949. static readonly FALLOFF_GLTF: number;
  14950. /**
  14951. * Falloff Standard: light is falling off like in the standard material
  14952. * to enhance interoperability with other materials.
  14953. */
  14954. static readonly FALLOFF_STANDARD: number;
  14955. /**
  14956. * If every light affecting the material is in this lightmapMode,
  14957. * material.lightmapTexture adds or multiplies
  14958. * (depends on material.useLightmapAsShadowmap)
  14959. * after every other light calculations.
  14960. */
  14961. static readonly LIGHTMAP_DEFAULT: number;
  14962. /**
  14963. * material.lightmapTexture as only diffuse lighting from this light
  14964. * adds only specular lighting from this light
  14965. * adds dynamic shadows
  14966. */
  14967. static readonly LIGHTMAP_SPECULAR: number;
  14968. /**
  14969. * material.lightmapTexture as only lighting
  14970. * no light calculation from this light
  14971. * only adds dynamic shadows from this light
  14972. */
  14973. static readonly LIGHTMAP_SHADOWSONLY: number;
  14974. /**
  14975. * Each light type uses the default quantity according to its type:
  14976. * point/spot lights use luminous intensity
  14977. * directional lights use illuminance
  14978. */
  14979. static readonly INTENSITYMODE_AUTOMATIC: number;
  14980. /**
  14981. * lumen (lm)
  14982. */
  14983. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  14984. /**
  14985. * candela (lm/sr)
  14986. */
  14987. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  14988. /**
  14989. * lux (lm/m^2)
  14990. */
  14991. static readonly INTENSITYMODE_ILLUMINANCE: number;
  14992. /**
  14993. * nit (cd/m^2)
  14994. */
  14995. static readonly INTENSITYMODE_LUMINANCE: number;
  14996. /**
  14997. * Light type const id of the point light.
  14998. */
  14999. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15000. /**
  15001. * Light type const id of the directional light.
  15002. */
  15003. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15004. /**
  15005. * Light type const id of the spot light.
  15006. */
  15007. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15008. /**
  15009. * Light type const id of the hemispheric light.
  15010. */
  15011. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15012. /**
  15013. * Diffuse gives the basic color to an object.
  15014. */
  15015. diffuse: Color3;
  15016. /**
  15017. * Specular produces a highlight color on an object.
  15018. * Note: This is note affecting PBR materials.
  15019. */
  15020. specular: Color3;
  15021. /**
  15022. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15023. * falling off base on range or angle.
  15024. * This can be set to any values in Light.FALLOFF_x.
  15025. *
  15026. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15027. * other types of materials.
  15028. */
  15029. falloffType: number;
  15030. /**
  15031. * Strength of the light.
  15032. * Note: By default it is define in the framework own unit.
  15033. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15034. */
  15035. intensity: number;
  15036. private _range;
  15037. protected _inverseSquaredRange: number;
  15038. /**
  15039. * Defines how far from the source the light is impacting in scene units.
  15040. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15041. */
  15042. /**
  15043. * Defines how far from the source the light is impacting in scene units.
  15044. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15045. */
  15046. range: number;
  15047. /**
  15048. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15049. * of light.
  15050. */
  15051. private _photometricScale;
  15052. private _intensityMode;
  15053. /**
  15054. * Gets the photometric scale used to interpret the intensity.
  15055. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15056. */
  15057. /**
  15058. * Sets the photometric scale used to interpret the intensity.
  15059. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15060. */
  15061. intensityMode: number;
  15062. private _radius;
  15063. /**
  15064. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15065. */
  15066. /**
  15067. * sets the light radius used by PBR Materials to simulate soft area lights.
  15068. */
  15069. radius: number;
  15070. private _renderPriority;
  15071. /**
  15072. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15073. * exceeding the number allowed of the materials.
  15074. */
  15075. renderPriority: number;
  15076. private _shadowEnabled;
  15077. /**
  15078. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15079. * the current shadow generator.
  15080. */
  15081. /**
  15082. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15083. * the current shadow generator.
  15084. */
  15085. shadowEnabled: boolean;
  15086. private _includedOnlyMeshes;
  15087. /**
  15088. * Gets the only meshes impacted by this light.
  15089. */
  15090. /**
  15091. * Sets the only meshes impacted by this light.
  15092. */
  15093. includedOnlyMeshes: AbstractMesh[];
  15094. private _excludedMeshes;
  15095. /**
  15096. * Gets the meshes not impacted by this light.
  15097. */
  15098. /**
  15099. * Sets the meshes not impacted by this light.
  15100. */
  15101. excludedMeshes: AbstractMesh[];
  15102. private _excludeWithLayerMask;
  15103. /**
  15104. * Gets the layer id use to find what meshes are not impacted by the light.
  15105. * Inactive if 0
  15106. */
  15107. /**
  15108. * Sets the layer id use to find what meshes are not impacted by the light.
  15109. * Inactive if 0
  15110. */
  15111. excludeWithLayerMask: number;
  15112. private _includeOnlyWithLayerMask;
  15113. /**
  15114. * Gets the layer id use to find what meshes are impacted by the light.
  15115. * Inactive if 0
  15116. */
  15117. /**
  15118. * Sets the layer id use to find what meshes are impacted by the light.
  15119. * Inactive if 0
  15120. */
  15121. includeOnlyWithLayerMask: number;
  15122. private _lightmapMode;
  15123. /**
  15124. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15125. */
  15126. /**
  15127. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15128. */
  15129. lightmapMode: number;
  15130. /**
  15131. * Shadow generator associted to the light.
  15132. * @hidden Internal use only.
  15133. */
  15134. _shadowGenerator: Nullable<IShadowGenerator>;
  15135. /**
  15136. * @hidden Internal use only.
  15137. */
  15138. _excludedMeshesIds: string[];
  15139. /**
  15140. * @hidden Internal use only.
  15141. */
  15142. _includedOnlyMeshesIds: string[];
  15143. /**
  15144. * The current light unifom buffer.
  15145. * @hidden Internal use only.
  15146. */
  15147. _uniformBuffer: UniformBuffer;
  15148. /**
  15149. * Creates a Light object in the scene.
  15150. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15151. * @param name The firendly name of the light
  15152. * @param scene The scene the light belongs too
  15153. */
  15154. constructor(name: string, scene: Scene);
  15155. protected abstract _buildUniformLayout(): void;
  15156. /**
  15157. * Sets the passed Effect "effect" with the Light information.
  15158. * @param effect The effect to update
  15159. * @param lightIndex The index of the light in the effect to update
  15160. * @returns The light
  15161. */
  15162. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15163. /**
  15164. * Returns the string "Light".
  15165. * @returns the class name
  15166. */
  15167. getClassName(): string;
  15168. /**
  15169. * Converts the light information to a readable string for debug purpose.
  15170. * @param fullDetails Supports for multiple levels of logging within scene loading
  15171. * @returns the human readable light info
  15172. */
  15173. toString(fullDetails?: boolean): string;
  15174. /** @hidden */
  15175. protected _syncParentEnabledState(): void;
  15176. /**
  15177. * Set the enabled state of this node.
  15178. * @param value - the new enabled state
  15179. */
  15180. setEnabled(value: boolean): void;
  15181. /**
  15182. * Returns the Light associated shadow generator if any.
  15183. * @return the associated shadow generator.
  15184. */
  15185. getShadowGenerator(): Nullable<IShadowGenerator>;
  15186. /**
  15187. * Returns a Vector3, the absolute light position in the World.
  15188. * @returns the world space position of the light
  15189. */
  15190. getAbsolutePosition(): Vector3;
  15191. /**
  15192. * Specifies if the light will affect the passed mesh.
  15193. * @param mesh The mesh to test against the light
  15194. * @return true the mesh is affected otherwise, false.
  15195. */
  15196. canAffectMesh(mesh: AbstractMesh): boolean;
  15197. /**
  15198. * Sort function to order lights for rendering.
  15199. * @param a First Light object to compare to second.
  15200. * @param b Second Light object to compare first.
  15201. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15202. */
  15203. static CompareLightsPriority(a: Light, b: Light): number;
  15204. /**
  15205. * Releases resources associated with this node.
  15206. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15207. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15208. */
  15209. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15210. /**
  15211. * Returns the light type ID (integer).
  15212. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15213. */
  15214. getTypeID(): number;
  15215. /**
  15216. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15217. * @returns the scaled intensity in intensity mode unit
  15218. */
  15219. getScaledIntensity(): number;
  15220. /**
  15221. * Returns a new Light object, named "name", from the current one.
  15222. * @param name The name of the cloned light
  15223. * @returns the new created light
  15224. */
  15225. clone(name: string): Nullable<Light>;
  15226. /**
  15227. * Serializes the current light into a Serialization object.
  15228. * @returns the serialized object.
  15229. */
  15230. serialize(): any;
  15231. /**
  15232. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15233. * This new light is named "name" and added to the passed scene.
  15234. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15235. * @param name The friendly name of the light
  15236. * @param scene The scene the new light will belong to
  15237. * @returns the constructor function
  15238. */
  15239. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15240. /**
  15241. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15242. * @param parsedLight The JSON representation of the light
  15243. * @param scene The scene to create the parsed light in
  15244. * @returns the created light after parsing
  15245. */
  15246. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15247. private _hookArrayForExcluded;
  15248. private _hookArrayForIncludedOnly;
  15249. private _resyncMeshes;
  15250. /**
  15251. * Forces the meshes to update their light related information in their rendering used effects
  15252. * @hidden Internal Use Only
  15253. */
  15254. _markMeshesAsLightDirty(): void;
  15255. /**
  15256. * Recomputes the cached photometric scale if needed.
  15257. */
  15258. private _computePhotometricScale;
  15259. /**
  15260. * Returns the Photometric Scale according to the light type and intensity mode.
  15261. */
  15262. private _getPhotometricScale;
  15263. /**
  15264. * Reorder the light in the scene according to their defined priority.
  15265. * @hidden Internal Use Only
  15266. */
  15267. _reorderLightsInScene(): void;
  15268. /**
  15269. * Prepares the list of defines specific to the light type.
  15270. * @param defines the list of defines
  15271. * @param lightIndex defines the index of the light for the effect
  15272. */
  15273. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15274. }
  15275. }
  15276. declare module BABYLON {
  15277. /**
  15278. * A point light is a light defined by an unique point in world space.
  15279. * The light is emitted in every direction from this point.
  15280. * A good example of a point light is a standard light bulb.
  15281. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15282. */
  15283. class PointLight extends ShadowLight {
  15284. private _shadowAngle;
  15285. /**
  15286. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15287. * This specifies what angle the shadow will use to be created.
  15288. *
  15289. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15290. */
  15291. /**
  15292. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15293. * This specifies what angle the shadow will use to be created.
  15294. *
  15295. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15296. */
  15297. shadowAngle: number;
  15298. /**
  15299. * Gets the direction if it has been set.
  15300. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15301. */
  15302. /**
  15303. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15304. */
  15305. direction: Vector3;
  15306. /**
  15307. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15308. * A PointLight emits the light in every direction.
  15309. * It can cast shadows.
  15310. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15311. * ```javascript
  15312. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15313. * ```
  15314. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15315. * @param name The light friendly name
  15316. * @param position The position of the point light in the scene
  15317. * @param scene The scene the lights belongs to
  15318. */
  15319. constructor(name: string, position: Vector3, scene: Scene);
  15320. /**
  15321. * Returns the string "PointLight"
  15322. * @returns the class name
  15323. */
  15324. getClassName(): string;
  15325. /**
  15326. * Returns the integer 0.
  15327. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15328. */
  15329. getTypeID(): number;
  15330. /**
  15331. * Specifies wether or not the shadowmap should be a cube texture.
  15332. * @returns true if the shadowmap needs to be a cube texture.
  15333. */
  15334. needCube(): boolean;
  15335. /**
  15336. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15337. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15338. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15339. */
  15340. getShadowDirection(faceIndex?: number): Vector3;
  15341. /**
  15342. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15343. * - fov = PI / 2
  15344. * - aspect ratio : 1.0
  15345. * - z-near and far equal to the active camera minZ and maxZ.
  15346. * Returns the PointLight.
  15347. */
  15348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15349. protected _buildUniformLayout(): void;
  15350. /**
  15351. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15352. * @param effect The effect to update
  15353. * @param lightIndex The index of the light in the effect to update
  15354. * @returns The point light
  15355. */
  15356. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15357. /**
  15358. * Prepares the list of defines specific to the light type.
  15359. * @param defines the list of defines
  15360. * @param lightIndex defines the index of the light for the effect
  15361. */
  15362. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15363. }
  15364. }
  15365. declare module BABYLON {
  15366. /**
  15367. * Interface describing all the common properties and methods a shadow light needs to implement.
  15368. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15369. * as well as binding the different shadow properties to the effects.
  15370. */
  15371. interface IShadowLight extends Light {
  15372. /**
  15373. * The light id in the scene (used in scene.findLighById for instance)
  15374. */
  15375. id: string;
  15376. /**
  15377. * The position the shdow will be casted from.
  15378. */
  15379. position: Vector3;
  15380. /**
  15381. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15382. */
  15383. direction: Vector3;
  15384. /**
  15385. * The transformed position. Position of the light in world space taking parenting in account.
  15386. */
  15387. transformedPosition: Vector3;
  15388. /**
  15389. * The transformed direction. Direction of the light in world space taking parenting in account.
  15390. */
  15391. transformedDirection: Vector3;
  15392. /**
  15393. * The friendly name of the light in the scene.
  15394. */
  15395. name: string;
  15396. /**
  15397. * Defines the shadow projection clipping minimum z value.
  15398. */
  15399. shadowMinZ: number;
  15400. /**
  15401. * Defines the shadow projection clipping maximum z value.
  15402. */
  15403. shadowMaxZ: number;
  15404. /**
  15405. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15406. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15407. */
  15408. computeTransformedInformation(): boolean;
  15409. /**
  15410. * Gets the scene the light belongs to.
  15411. * @returns The scene
  15412. */
  15413. getScene(): Scene;
  15414. /**
  15415. * Callback defining a custom Projection Matrix Builder.
  15416. * This can be used to override the default projection matrix computation.
  15417. */
  15418. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15419. /**
  15420. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15421. * @param matrix The materix to updated with the projection information
  15422. * @param viewMatrix The transform matrix of the light
  15423. * @param renderList The list of mesh to render in the map
  15424. * @returns The current light
  15425. */
  15426. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15427. /**
  15428. * Gets the current depth scale used in ESM.
  15429. * @returns The scale
  15430. */
  15431. getDepthScale(): number;
  15432. /**
  15433. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15434. * @returns true if a cube texture needs to be use
  15435. */
  15436. needCube(): boolean;
  15437. /**
  15438. * Detects if the projection matrix requires to be recomputed this frame.
  15439. * @returns true if it requires to be recomputed otherwise, false.
  15440. */
  15441. needProjectionMatrixCompute(): boolean;
  15442. /**
  15443. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15444. */
  15445. forceProjectionMatrixCompute(): void;
  15446. /**
  15447. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15448. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15449. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15450. */
  15451. getShadowDirection(faceIndex?: number): Vector3;
  15452. /**
  15453. * Gets the minZ used for shadow according to both the scene and the light.
  15454. * @param activeCamera The camera we are returning the min for
  15455. * @returns the depth min z
  15456. */
  15457. getDepthMinZ(activeCamera: Camera): number;
  15458. /**
  15459. * Gets the maxZ used for shadow according to both the scene and the light.
  15460. * @param activeCamera The camera we are returning the max for
  15461. * @returns the depth max z
  15462. */
  15463. getDepthMaxZ(activeCamera: Camera): number;
  15464. }
  15465. /**
  15466. * Base implementation IShadowLight
  15467. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15468. */
  15469. abstract class ShadowLight extends Light implements IShadowLight {
  15470. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15471. protected _position: Vector3;
  15472. protected _setPosition(value: Vector3): void;
  15473. /**
  15474. * Sets the position the shadow will be casted from. Also use as the light position for both
  15475. * point and spot lights.
  15476. */
  15477. /**
  15478. * Sets the position the shadow will be casted from. Also use as the light position for both
  15479. * point and spot lights.
  15480. */
  15481. position: Vector3;
  15482. protected _direction: Vector3;
  15483. protected _setDirection(value: Vector3): void;
  15484. /**
  15485. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15486. * Also use as the light direction on spot and directional lights.
  15487. */
  15488. /**
  15489. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15490. * Also use as the light direction on spot and directional lights.
  15491. */
  15492. direction: Vector3;
  15493. private _shadowMinZ;
  15494. /**
  15495. * Gets the shadow projection clipping minimum z value.
  15496. */
  15497. /**
  15498. * Sets the shadow projection clipping minimum z value.
  15499. */
  15500. shadowMinZ: number;
  15501. private _shadowMaxZ;
  15502. /**
  15503. * Sets the shadow projection clipping maximum z value.
  15504. */
  15505. /**
  15506. * Gets the shadow projection clipping maximum z value.
  15507. */
  15508. shadowMaxZ: number;
  15509. /**
  15510. * Callback defining a custom Projection Matrix Builder.
  15511. * This can be used to override the default projection matrix computation.
  15512. */
  15513. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15514. /**
  15515. * The transformed position. Position of the light in world space taking parenting in account.
  15516. */
  15517. transformedPosition: Vector3;
  15518. /**
  15519. * The transformed direction. Direction of the light in world space taking parenting in account.
  15520. */
  15521. transformedDirection: Vector3;
  15522. private _needProjectionMatrixCompute;
  15523. /**
  15524. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15525. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15526. */
  15527. computeTransformedInformation(): boolean;
  15528. /**
  15529. * Return the depth scale used for the shadow map.
  15530. * @returns the depth scale.
  15531. */
  15532. getDepthScale(): number;
  15533. /**
  15534. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15535. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15536. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15537. */
  15538. getShadowDirection(faceIndex?: number): Vector3;
  15539. /**
  15540. * Returns the ShadowLight absolute position in the World.
  15541. * @returns the position vector in world space
  15542. */
  15543. getAbsolutePosition(): Vector3;
  15544. /**
  15545. * Sets the ShadowLight direction toward the passed target.
  15546. * @param target The point tot target in local space
  15547. * @returns the updated ShadowLight direction
  15548. */
  15549. setDirectionToTarget(target: Vector3): Vector3;
  15550. /**
  15551. * Returns the light rotation in euler definition.
  15552. * @returns the x y z rotation in local space.
  15553. */
  15554. getRotation(): Vector3;
  15555. /**
  15556. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15557. * @returns true if a cube texture needs to be use
  15558. */
  15559. needCube(): boolean;
  15560. /**
  15561. * Detects if the projection matrix requires to be recomputed this frame.
  15562. * @returns true if it requires to be recomputed otherwise, false.
  15563. */
  15564. needProjectionMatrixCompute(): boolean;
  15565. /**
  15566. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15567. */
  15568. forceProjectionMatrixCompute(): void;
  15569. /** @hidden */
  15570. _initCache(): void;
  15571. /** @hidden */
  15572. _isSynchronized(): boolean;
  15573. /**
  15574. * Computes the world matrix of the node
  15575. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15576. * @returns the world matrix
  15577. */
  15578. computeWorldMatrix(force?: boolean): Matrix;
  15579. /**
  15580. * Gets the minZ used for shadow according to both the scene and the light.
  15581. * @param activeCamera The camera we are returning the min for
  15582. * @returns the depth min z
  15583. */
  15584. getDepthMinZ(activeCamera: Camera): number;
  15585. /**
  15586. * Gets the maxZ used for shadow according to both the scene and the light.
  15587. * @param activeCamera The camera we are returning the max for
  15588. * @returns the depth max z
  15589. */
  15590. getDepthMaxZ(activeCamera: Camera): number;
  15591. /**
  15592. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15593. * @param matrix The materix to updated with the projection information
  15594. * @param viewMatrix The transform matrix of the light
  15595. * @param renderList The list of mesh to render in the map
  15596. * @returns The current light
  15597. */
  15598. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15599. }
  15600. }
  15601. declare module BABYLON {
  15602. /**
  15603. * A spot light is defined by a position, a direction, an angle, and an exponent.
  15604. * These values define a cone of light starting from the position, emitting toward the direction.
  15605. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  15606. * and the exponent defines the speed of the decay of the light with distance (reach).
  15607. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15608. */
  15609. class SpotLight extends ShadowLight {
  15610. private _angle;
  15611. private _innerAngle;
  15612. private _cosHalfAngle;
  15613. private _lightAngleScale;
  15614. private _lightAngleOffset;
  15615. /**
  15616. * Gets the cone angle of the spot light in Radians.
  15617. */
  15618. /**
  15619. * Sets the cone angle of the spot light in Radians.
  15620. */
  15621. angle: number;
  15622. /**
  15623. * Only used in gltf falloff mode, this defines the angle where
  15624. * the directional falloff will start before cutting at angle which could be seen
  15625. * as outer angle.
  15626. */
  15627. /**
  15628. * Only used in gltf falloff mode, this defines the angle where
  15629. * the directional falloff will start before cutting at angle which could be seen
  15630. * as outer angle.
  15631. */
  15632. innerAngle: number;
  15633. private _shadowAngleScale;
  15634. /**
  15635. * Allows scaling the angle of the light for shadow generation only.
  15636. */
  15637. /**
  15638. * Allows scaling the angle of the light for shadow generation only.
  15639. */
  15640. shadowAngleScale: number;
  15641. /**
  15642. * The light decay speed with the distance from the emission spot.
  15643. */
  15644. exponent: number;
  15645. private _projectionTextureMatrix;
  15646. /**
  15647. * Allows reading the projecton texture
  15648. */
  15649. readonly projectionTextureMatrix: Matrix;
  15650. protected _projectionTextureLightNear: number;
  15651. /**
  15652. * Gets the near clip of the Spotlight for texture projection.
  15653. */
  15654. /**
  15655. * Sets the near clip of the Spotlight for texture projection.
  15656. */
  15657. projectionTextureLightNear: number;
  15658. protected _projectionTextureLightFar: number;
  15659. /**
  15660. * Gets the far clip of the Spotlight for texture projection.
  15661. */
  15662. /**
  15663. * Sets the far clip of the Spotlight for texture projection.
  15664. */
  15665. projectionTextureLightFar: number;
  15666. protected _projectionTextureUpDirection: Vector3;
  15667. /**
  15668. * Gets the Up vector of the Spotlight for texture projection.
  15669. */
  15670. /**
  15671. * Sets the Up vector of the Spotlight for texture projection.
  15672. */
  15673. projectionTextureUpDirection: Vector3;
  15674. private _projectionTexture;
  15675. /**
  15676. * Gets the projection texture of the light.
  15677. */
  15678. /**
  15679. * Sets the projection texture of the light.
  15680. */
  15681. projectionTexture: Nullable<BaseTexture>;
  15682. private _projectionTextureViewLightDirty;
  15683. private _projectionTextureProjectionLightDirty;
  15684. private _projectionTextureDirty;
  15685. private _projectionTextureViewTargetVector;
  15686. private _projectionTextureViewLightMatrix;
  15687. private _projectionTextureProjectionLightMatrix;
  15688. private _projectionTextureScalingMatrix;
  15689. /**
  15690. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  15691. * It can cast shadows.
  15692. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15693. * @param name The light friendly name
  15694. * @param position The position of the spot light in the scene
  15695. * @param direction The direction of the light in the scene
  15696. * @param angle The cone angle of the light in Radians
  15697. * @param exponent The light decay speed with the distance from the emission spot
  15698. * @param scene The scene the lights belongs to
  15699. */
  15700. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  15701. /**
  15702. * Returns the string "SpotLight".
  15703. * @returns the class name
  15704. */
  15705. getClassName(): string;
  15706. /**
  15707. * Returns the integer 2.
  15708. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15709. */
  15710. getTypeID(): number;
  15711. /**
  15712. * Overrides the direction setter to recompute the projection texture view light Matrix.
  15713. */
  15714. protected _setDirection(value: Vector3): void;
  15715. /**
  15716. * Overrides the position setter to recompute the projection texture view light Matrix.
  15717. */
  15718. protected _setPosition(value: Vector3): void;
  15719. /**
  15720. * 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.
  15721. * Returns the SpotLight.
  15722. */
  15723. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15724. protected _computeProjectionTextureViewLightMatrix(): void;
  15725. protected _computeProjectionTextureProjectionLightMatrix(): void;
  15726. /**
  15727. * Main function for light texture projection matrix computing.
  15728. */
  15729. protected _computeProjectionTextureMatrix(): void;
  15730. protected _buildUniformLayout(): void;
  15731. private _computeAngleValues;
  15732. /**
  15733. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  15734. * @param effect The effect to update
  15735. * @param lightIndex The index of the light in the effect to update
  15736. * @returns The spot light
  15737. */
  15738. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  15739. /**
  15740. * Disposes the light and the associated resources.
  15741. */
  15742. dispose(): void;
  15743. /**
  15744. * Prepares the list of defines specific to the light type.
  15745. * @param defines the list of defines
  15746. * @param lightIndex defines the index of the light for the effect
  15747. */
  15748. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. interface ILoadingScreen {
  15753. displayLoadingUI: () => void;
  15754. hideLoadingUI: () => void;
  15755. loadingUIBackgroundColor: string;
  15756. loadingUIText: string;
  15757. }
  15758. class DefaultLoadingScreen implements ILoadingScreen {
  15759. private _renderingCanvas;
  15760. private _loadingText;
  15761. private _loadingDivBackgroundColor;
  15762. private _loadingDiv;
  15763. private _loadingTextDiv;
  15764. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  15765. displayLoadingUI(): void;
  15766. hideLoadingUI(): void;
  15767. loadingUIText: string;
  15768. loadingUIBackgroundColor: string;
  15769. private _resizeLoadingUI;
  15770. }
  15771. }
  15772. declare module BABYLON {
  15773. class SceneLoaderProgressEvent {
  15774. readonly lengthComputable: boolean;
  15775. readonly loaded: number;
  15776. readonly total: number;
  15777. constructor(lengthComputable: boolean, loaded: number, total: number);
  15778. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  15779. }
  15780. interface ISceneLoaderPluginExtensions {
  15781. [extension: string]: {
  15782. isBinary: boolean;
  15783. };
  15784. }
  15785. interface ISceneLoaderPluginFactory {
  15786. name: string;
  15787. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  15788. canDirectLoad?: (data: string) => boolean;
  15789. }
  15790. interface ISceneLoaderPlugin {
  15791. /**
  15792. * The friendly name of this plugin.
  15793. */
  15794. name: string;
  15795. /**
  15796. * The file extensions supported by this plugin.
  15797. */
  15798. extensions: string | ISceneLoaderPluginExtensions;
  15799. /**
  15800. * Import meshes into a scene.
  15801. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15802. * @param scene The scene to import into
  15803. * @param data The data to import
  15804. * @param rootUrl The root url for scene and resources
  15805. * @param meshes The meshes array to import into
  15806. * @param particleSystems The particle systems array to import into
  15807. * @param skeletons The skeletons array to import into
  15808. * @param onError The callback when import fails
  15809. * @returns True if successful or false otherwise
  15810. */
  15811. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  15812. /**
  15813. * Load into a scene.
  15814. * @param scene The scene to load into
  15815. * @param data The data to import
  15816. * @param rootUrl The root url for scene and resources
  15817. * @param onError The callback when import fails
  15818. * @returns true if successful or false otherwise
  15819. */
  15820. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  15821. /**
  15822. * The callback that returns true if the data can be directly loaded.
  15823. */
  15824. canDirectLoad?: (data: string) => boolean;
  15825. /**
  15826. * The callback that allows custom handling of the root url based on the response url.
  15827. */
  15828. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  15829. /**
  15830. * Load into an asset container.
  15831. * @param scene The scene to load into
  15832. * @param data The data to import
  15833. * @param rootUrl The root url for scene and resources
  15834. * @param onError The callback when import fails
  15835. * @returns The loaded asset container
  15836. */
  15837. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  15838. }
  15839. interface ISceneLoaderPluginAsync {
  15840. /**
  15841. * The friendly name of this plugin.
  15842. */
  15843. name: string;
  15844. /**
  15845. * The file extensions supported by this plugin.
  15846. */
  15847. extensions: string | ISceneLoaderPluginExtensions;
  15848. /**
  15849. * Import meshes into a scene.
  15850. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15851. * @param scene The scene to import into
  15852. * @param data The data to import
  15853. * @param rootUrl The root url for scene and resources
  15854. * @param onProgress The callback when the load progresses
  15855. * @param fileName Defines the name of the file to load
  15856. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  15857. */
  15858. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  15859. meshes: AbstractMesh[];
  15860. particleSystems: IParticleSystem[];
  15861. skeletons: Skeleton[];
  15862. animationGroups: AnimationGroup[];
  15863. }>;
  15864. /**
  15865. * Load into a scene.
  15866. * @param scene The scene to load into
  15867. * @param data The data to import
  15868. * @param rootUrl The root url for scene and resources
  15869. * @param onProgress The callback when the load progresses
  15870. * @param fileName Defines the name of the file to load
  15871. * @returns Nothing
  15872. */
  15873. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  15874. /**
  15875. * The callback that returns true if the data can be directly loaded.
  15876. */
  15877. canDirectLoad?: (data: string) => boolean;
  15878. /**
  15879. * The callback that allows custom handling of the root url based on the response url.
  15880. */
  15881. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  15882. /**
  15883. * Load into an asset container.
  15884. * @param scene The scene to load into
  15885. * @param data The data to import
  15886. * @param rootUrl The root url for scene and resources
  15887. * @param onProgress The callback when the load progresses
  15888. * @param fileName Defines the name of the file to load
  15889. * @returns The loaded asset container
  15890. */
  15891. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  15892. }
  15893. class SceneLoader {
  15894. private static _ForceFullSceneLoadingForIncremental;
  15895. private static _ShowLoadingScreen;
  15896. private static _CleanBoneMatrixWeights;
  15897. static readonly NO_LOGGING: number;
  15898. static readonly MINIMAL_LOGGING: number;
  15899. static readonly SUMMARY_LOGGING: number;
  15900. static readonly DETAILED_LOGGING: number;
  15901. private static _loggingLevel;
  15902. static ForceFullSceneLoadingForIncremental: boolean;
  15903. static ShowLoadingScreen: boolean;
  15904. static loggingLevel: number;
  15905. static CleanBoneMatrixWeights: boolean;
  15906. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  15907. private static _registeredPlugins;
  15908. private static _getDefaultPlugin;
  15909. private static _getPluginForExtension;
  15910. private static _getPluginForDirectLoad;
  15911. private static _getPluginForFilename;
  15912. private static _getDirectLoad;
  15913. private static _loadData;
  15914. private static _getFileInfo;
  15915. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  15916. static IsPluginForExtensionAvailable(extension: string): boolean;
  15917. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  15918. /**
  15919. * Import meshes into a scene
  15920. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15921. * @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)
  15922. * @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)
  15923. * @param scene the instance of BABYLON.Scene to append to
  15924. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  15925. * @param onProgress a callback with a progress event for each file being loaded
  15926. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15927. * @param pluginExtension the extension used to determine the plugin
  15928. * @returns The loaded plugin
  15929. */
  15930. 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>;
  15931. /**
  15932. * Import meshes into a scene
  15933. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  15934. * @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)
  15935. * @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)
  15936. * @param scene the instance of BABYLON.Scene to append to
  15937. * @param onProgress a callback with a progress event for each file being loaded
  15938. * @param pluginExtension the extension used to determine the plugin
  15939. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  15940. */
  15941. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  15942. meshes: AbstractMesh[];
  15943. particleSystems: IParticleSystem[];
  15944. skeletons: Skeleton[];
  15945. animationGroups: AnimationGroup[];
  15946. }>;
  15947. /**
  15948. * Load a scene
  15949. * @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)
  15950. * @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)
  15951. * @param engine is the instance of BABYLON.Engine to use to create the scene
  15952. * @param onSuccess a callback with the scene when import succeeds
  15953. * @param onProgress a callback with a progress event for each file being loaded
  15954. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15955. * @param pluginExtension the extension used to determine the plugin
  15956. * @returns The loaded plugin
  15957. */
  15958. 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>;
  15959. /**
  15960. * Load a scene
  15961. * @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)
  15962. * @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)
  15963. * @param engine is the instance of BABYLON.Engine to use to create the scene
  15964. * @param onProgress a callback with a progress event for each file being loaded
  15965. * @param pluginExtension the extension used to determine the plugin
  15966. * @returns The loaded scene
  15967. */
  15968. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  15969. /**
  15970. * Append a scene
  15971. * @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)
  15972. * @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)
  15973. * @param scene is the instance of BABYLON.Scene to append to
  15974. * @param onSuccess a callback with the scene when import succeeds
  15975. * @param onProgress a callback with a progress event for each file being loaded
  15976. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15977. * @param pluginExtension the extension used to determine the plugin
  15978. * @returns The loaded plugin
  15979. */
  15980. 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>;
  15981. /**
  15982. * Append a scene
  15983. * @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)
  15984. * @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)
  15985. * @param scene is the instance of BABYLON.Scene to append to
  15986. * @param onProgress a callback with a progress event for each file being loaded
  15987. * @param pluginExtension the extension used to determine the plugin
  15988. * @returns The given scene
  15989. */
  15990. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  15991. /**
  15992. * Load a scene into an asset container
  15993. * @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)
  15994. * @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)
  15995. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  15996. * @param onSuccess a callback with the scene when import succeeds
  15997. * @param onProgress a callback with a progress event for each file being loaded
  15998. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  15999. * @param pluginExtension the extension used to determine the plugin
  16000. * @returns The loaded plugin
  16001. */
  16002. 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>;
  16003. /**
  16004. * Load a scene into an asset container
  16005. * @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)
  16006. * @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)
  16007. * @param scene is the instance of BABYLON.Scene to append to
  16008. * @param onProgress a callback with a progress event for each file being loaded
  16009. * @param pluginExtension the extension used to determine the plugin
  16010. * @returns The loaded asset container
  16011. */
  16012. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16013. }
  16014. }
  16015. declare module BABYLON {
  16016. /**
  16017. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16018. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16019. * 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;
  16020. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16021. */
  16022. class ColorCurves {
  16023. private _dirty;
  16024. private _tempColor;
  16025. private _globalCurve;
  16026. private _highlightsCurve;
  16027. private _midtonesCurve;
  16028. private _shadowsCurve;
  16029. private _positiveCurve;
  16030. private _negativeCurve;
  16031. private _globalHue;
  16032. private _globalDensity;
  16033. private _globalSaturation;
  16034. private _globalExposure;
  16035. /**
  16036. * Gets the global Hue value.
  16037. * 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).
  16038. */
  16039. /**
  16040. * Sets the global Hue value.
  16041. * 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).
  16042. */
  16043. globalHue: number;
  16044. /**
  16045. * Gets the global Density value.
  16046. * 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.
  16047. * Values less than zero provide a filter of opposite hue.
  16048. */
  16049. /**
  16050. * Sets the global Density value.
  16051. * 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.
  16052. * Values less than zero provide a filter of opposite hue.
  16053. */
  16054. globalDensity: number;
  16055. /**
  16056. * Gets the global Saturation value.
  16057. * 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.
  16058. */
  16059. /**
  16060. * Sets the global Saturation value.
  16061. * 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.
  16062. */
  16063. globalSaturation: number;
  16064. /**
  16065. * Gets the global Exposure value.
  16066. * 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.
  16067. */
  16068. /**
  16069. * Sets the global Exposure value.
  16070. * 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.
  16071. */
  16072. globalExposure: number;
  16073. private _highlightsHue;
  16074. private _highlightsDensity;
  16075. private _highlightsSaturation;
  16076. private _highlightsExposure;
  16077. /**
  16078. * Gets the highlights Hue value.
  16079. * 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).
  16080. */
  16081. /**
  16082. * Sets the highlights Hue value.
  16083. * 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).
  16084. */
  16085. highlightsHue: number;
  16086. /**
  16087. * Gets the highlights Density value.
  16088. * 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.
  16089. * Values less than zero provide a filter of opposite hue.
  16090. */
  16091. /**
  16092. * Sets the highlights Density value.
  16093. * 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.
  16094. * Values less than zero provide a filter of opposite hue.
  16095. */
  16096. highlightsDensity: number;
  16097. /**
  16098. * Gets the highlights Saturation value.
  16099. * 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.
  16100. */
  16101. /**
  16102. * Sets the highlights Saturation value.
  16103. * 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.
  16104. */
  16105. highlightsSaturation: number;
  16106. /**
  16107. * Gets the highlights Exposure value.
  16108. * 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.
  16109. */
  16110. /**
  16111. * Sets the highlights Exposure value.
  16112. * 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.
  16113. */
  16114. highlightsExposure: number;
  16115. private _midtonesHue;
  16116. private _midtonesDensity;
  16117. private _midtonesSaturation;
  16118. private _midtonesExposure;
  16119. /**
  16120. * Gets the midtones Hue value.
  16121. * 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).
  16122. */
  16123. /**
  16124. * Sets the midtones Hue value.
  16125. * 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).
  16126. */
  16127. midtonesHue: number;
  16128. /**
  16129. * Gets the midtones Density value.
  16130. * 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.
  16131. * Values less than zero provide a filter of opposite hue.
  16132. */
  16133. /**
  16134. * Sets the midtones Density value.
  16135. * 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.
  16136. * Values less than zero provide a filter of opposite hue.
  16137. */
  16138. midtonesDensity: number;
  16139. /**
  16140. * Gets the midtones Saturation value.
  16141. * 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.
  16142. */
  16143. /**
  16144. * Sets the midtones Saturation value.
  16145. * 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.
  16146. */
  16147. midtonesSaturation: number;
  16148. /**
  16149. * Gets the midtones Exposure value.
  16150. * 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.
  16151. */
  16152. /**
  16153. * Sets the midtones Exposure value.
  16154. * 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.
  16155. */
  16156. midtonesExposure: number;
  16157. private _shadowsHue;
  16158. private _shadowsDensity;
  16159. private _shadowsSaturation;
  16160. private _shadowsExposure;
  16161. /**
  16162. * Gets the shadows Hue value.
  16163. * 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).
  16164. */
  16165. /**
  16166. * Sets the shadows Hue value.
  16167. * 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).
  16168. */
  16169. shadowsHue: number;
  16170. /**
  16171. * Gets the shadows Density value.
  16172. * 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.
  16173. * Values less than zero provide a filter of opposite hue.
  16174. */
  16175. /**
  16176. * Sets the shadows Density value.
  16177. * 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.
  16178. * Values less than zero provide a filter of opposite hue.
  16179. */
  16180. shadowsDensity: number;
  16181. /**
  16182. * Gets the shadows Saturation value.
  16183. * 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.
  16184. */
  16185. /**
  16186. * Sets the shadows Saturation value.
  16187. * 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.
  16188. */
  16189. shadowsSaturation: number;
  16190. /**
  16191. * Gets the shadows Exposure value.
  16192. * 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.
  16193. */
  16194. /**
  16195. * Sets the shadows Exposure value.
  16196. * 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.
  16197. */
  16198. shadowsExposure: number;
  16199. /**
  16200. * Returns the class name
  16201. * @returns The class name
  16202. */
  16203. getClassName(): string;
  16204. /**
  16205. * Binds the color curves to the shader.
  16206. * @param colorCurves The color curve to bind
  16207. * @param effect The effect to bind to
  16208. * @param positiveUniform The positive uniform shader parameter
  16209. * @param neutralUniform The neutral uniform shader parameter
  16210. * @param negativeUniform The negative uniform shader parameter
  16211. */
  16212. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16213. /**
  16214. * Prepare the list of uniforms associated with the ColorCurves effects.
  16215. * @param uniformsList The list of uniforms used in the effect
  16216. */
  16217. static PrepareUniforms(uniformsList: string[]): void;
  16218. /**
  16219. * Returns color grading data based on a hue, density, saturation and exposure value.
  16220. * @param filterHue The hue of the color filter.
  16221. * @param filterDensity The density of the color filter.
  16222. * @param saturation The saturation.
  16223. * @param exposure The exposure.
  16224. * @param result The result data container.
  16225. */
  16226. private getColorGradingDataToRef;
  16227. /**
  16228. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16229. * @param value The input slider value in range [-100,100].
  16230. * @returns Adjusted value.
  16231. */
  16232. private static applyColorGradingSliderNonlinear;
  16233. /**
  16234. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16235. * @param hue The hue (H) input.
  16236. * @param saturation The saturation (S) input.
  16237. * @param brightness The brightness (B) input.
  16238. * @result An RGBA color represented as Vector4.
  16239. */
  16240. private static fromHSBToRef;
  16241. /**
  16242. * Returns a value clamped between min and max
  16243. * @param value The value to clamp
  16244. * @param min The minimum of value
  16245. * @param max The maximum of value
  16246. * @returns The clamped value.
  16247. */
  16248. private static clamp;
  16249. /**
  16250. * Clones the current color curve instance.
  16251. * @return The cloned curves
  16252. */
  16253. clone(): ColorCurves;
  16254. /**
  16255. * Serializes the current color curve instance to a json representation.
  16256. * @return a JSON representation
  16257. */
  16258. serialize(): any;
  16259. /**
  16260. * Parses the color curve from a json representation.
  16261. * @param source the JSON source to parse
  16262. * @return The parsed curves
  16263. */
  16264. static Parse(source: any): ColorCurves;
  16265. }
  16266. }
  16267. declare module BABYLON {
  16268. /**
  16269. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16270. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16271. */
  16272. class EffectFallbacks {
  16273. private _defines;
  16274. private _currentRank;
  16275. private _maxRank;
  16276. private _mesh;
  16277. /**
  16278. * Removes the fallback from the bound mesh.
  16279. */
  16280. unBindMesh(): void;
  16281. /**
  16282. * Adds a fallback on the specified property.
  16283. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16284. * @param define The name of the define in the shader
  16285. */
  16286. addFallback(rank: number, define: string): void;
  16287. /**
  16288. * Sets the mesh to use CPU skinning when needing to fallback.
  16289. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16290. * @param mesh The mesh to use the fallbacks.
  16291. */
  16292. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16293. /**
  16294. * Checks to see if more fallbacks are still availible.
  16295. */
  16296. readonly isMoreFallbacks: boolean;
  16297. /**
  16298. * Removes the defines that shoould be removed when falling back.
  16299. * @param currentDefines defines the current define statements for the shader.
  16300. * @param effect defines the current effect we try to compile
  16301. * @returns The resulting defines with defines of the current rank removed.
  16302. */
  16303. reduce(currentDefines: string, effect: Effect): string;
  16304. }
  16305. /**
  16306. * Options to be used when creating an effect.
  16307. */
  16308. class EffectCreationOptions {
  16309. /**
  16310. * Atrributes that will be used in the shader.
  16311. */
  16312. attributes: string[];
  16313. /**
  16314. * Uniform varible names that will be set in the shader.
  16315. */
  16316. uniformsNames: string[];
  16317. /**
  16318. * Uniform buffer varible names that will be set in the shader.
  16319. */
  16320. uniformBuffersNames: string[];
  16321. /**
  16322. * Sampler texture variable names that will be set in the shader.
  16323. */
  16324. samplers: string[];
  16325. /**
  16326. * Define statements that will be set in the shader.
  16327. */
  16328. defines: any;
  16329. /**
  16330. * Possible fallbacks for this effect to improve performance when needed.
  16331. */
  16332. fallbacks: Nullable<EffectFallbacks>;
  16333. /**
  16334. * Callback that will be called when the shader is compiled.
  16335. */
  16336. onCompiled: Nullable<(effect: Effect) => void>;
  16337. /**
  16338. * Callback that will be called if an error occurs during shader compilation.
  16339. */
  16340. onError: Nullable<(effect: Effect, errors: string) => void>;
  16341. /**
  16342. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16343. */
  16344. indexParameters: any;
  16345. /**
  16346. * Max number of lights that can be used in the shader.
  16347. */
  16348. maxSimultaneousLights: number;
  16349. /**
  16350. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16351. */
  16352. transformFeedbackVaryings: Nullable<string[]>;
  16353. }
  16354. /**
  16355. * Effect containing vertex and fragment shader that can be executed on an object.
  16356. */
  16357. class Effect {
  16358. /**
  16359. * Name of the effect.
  16360. */
  16361. name: any;
  16362. /**
  16363. * String container all the define statements that should be set on the shader.
  16364. */
  16365. defines: string;
  16366. /**
  16367. * Callback that will be called when the shader is compiled.
  16368. */
  16369. onCompiled: Nullable<(effect: Effect) => void>;
  16370. /**
  16371. * Callback that will be called if an error occurs during shader compilation.
  16372. */
  16373. onError: Nullable<(effect: Effect, errors: string) => void>;
  16374. /**
  16375. * Callback that will be called when effect is bound.
  16376. */
  16377. onBind: Nullable<(effect: Effect) => void>;
  16378. /**
  16379. * Unique ID of the effect.
  16380. */
  16381. uniqueId: number;
  16382. /**
  16383. * Observable that will be called when the shader is compiled.
  16384. */
  16385. onCompileObservable: Observable<Effect>;
  16386. /**
  16387. * Observable that will be called if an error occurs during shader compilation.
  16388. */
  16389. onErrorObservable: Observable<Effect>;
  16390. /** @hidden */
  16391. _onBindObservable: Nullable<Observable<Effect>>;
  16392. /**
  16393. * Observable that will be called when effect is bound.
  16394. */
  16395. readonly onBindObservable: Observable<Effect>;
  16396. /** @hidden */
  16397. _bonesComputationForcedToCPU: boolean;
  16398. private static _uniqueIdSeed;
  16399. private _engine;
  16400. private _uniformBuffersNames;
  16401. private _uniformsNames;
  16402. private _samplers;
  16403. private _isReady;
  16404. private _compilationError;
  16405. private _attributesNames;
  16406. private _attributes;
  16407. private _uniforms;
  16408. /**
  16409. * Key for the effect.
  16410. * @hidden
  16411. */
  16412. _key: string;
  16413. private _indexParameters;
  16414. private _fallbacks;
  16415. private _vertexSourceCode;
  16416. private _fragmentSourceCode;
  16417. private _vertexSourceCodeOverride;
  16418. private _fragmentSourceCodeOverride;
  16419. private _transformFeedbackVaryings;
  16420. /**
  16421. * Compiled shader to webGL program.
  16422. * @hidden
  16423. */
  16424. _program: WebGLProgram;
  16425. private _valueCache;
  16426. private static _baseCache;
  16427. /**
  16428. * Instantiates an effect.
  16429. * An effect can be used to create/manage/execute vertex and fragment shaders.
  16430. * @param baseName Name of the effect.
  16431. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  16432. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  16433. * @param samplers List of sampler variables that will be passed to the shader.
  16434. * @param engine Engine to be used to render the effect
  16435. * @param defines Define statements to be added to the shader.
  16436. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  16437. * @param onCompiled Callback that will be called when the shader is compiled.
  16438. * @param onError Callback that will be called if an error occurs during shader compilation.
  16439. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16440. */
  16441. 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);
  16442. /**
  16443. * Unique key for this effect
  16444. */
  16445. readonly key: string;
  16446. /**
  16447. * If the effect has been compiled and prepared.
  16448. * @returns if the effect is compiled and prepared.
  16449. */
  16450. isReady(): boolean;
  16451. /**
  16452. * The engine the effect was initialized with.
  16453. * @returns the engine.
  16454. */
  16455. getEngine(): Engine;
  16456. /**
  16457. * The compiled webGL program for the effect
  16458. * @returns the webGL program.
  16459. */
  16460. getProgram(): WebGLProgram;
  16461. /**
  16462. * The set of names of attribute variables for the shader.
  16463. * @returns An array of attribute names.
  16464. */
  16465. getAttributesNames(): string[];
  16466. /**
  16467. * Returns the attribute at the given index.
  16468. * @param index The index of the attribute.
  16469. * @returns The location of the attribute.
  16470. */
  16471. getAttributeLocation(index: number): number;
  16472. /**
  16473. * Returns the attribute based on the name of the variable.
  16474. * @param name of the attribute to look up.
  16475. * @returns the attribute location.
  16476. */
  16477. getAttributeLocationByName(name: string): number;
  16478. /**
  16479. * The number of attributes.
  16480. * @returns the numnber of attributes.
  16481. */
  16482. getAttributesCount(): number;
  16483. /**
  16484. * Gets the index of a uniform variable.
  16485. * @param uniformName of the uniform to look up.
  16486. * @returns the index.
  16487. */
  16488. getUniformIndex(uniformName: string): number;
  16489. /**
  16490. * Returns the attribute based on the name of the variable.
  16491. * @param uniformName of the uniform to look up.
  16492. * @returns the location of the uniform.
  16493. */
  16494. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  16495. /**
  16496. * Returns an array of sampler variable names
  16497. * @returns The array of sampler variable neames.
  16498. */
  16499. getSamplers(): string[];
  16500. /**
  16501. * The error from the last compilation.
  16502. * @returns the error string.
  16503. */
  16504. getCompilationError(): string;
  16505. /**
  16506. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  16507. * @param func The callback to be used.
  16508. */
  16509. executeWhenCompiled(func: (effect: Effect) => void): void;
  16510. /** @hidden */
  16511. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  16512. /** @hidden */
  16513. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  16514. /** @hidden */
  16515. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  16516. private _processShaderConversion;
  16517. private _processIncludes;
  16518. private _processPrecision;
  16519. /**
  16520. * Recompiles the webGL program
  16521. * @param vertexSourceCode The source code for the vertex shader.
  16522. * @param fragmentSourceCode The source code for the fragment shader.
  16523. * @param onCompiled Callback called when completed.
  16524. * @param onError Callback called on error.
  16525. * @hidden
  16526. */
  16527. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  16528. /**
  16529. * Gets the uniform locations of the the specified variable names
  16530. * @param names THe names of the variables to lookup.
  16531. * @returns Array of locations in the same order as variable names.
  16532. */
  16533. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  16534. /**
  16535. * Prepares the effect
  16536. * @hidden
  16537. */
  16538. _prepareEffect(): void;
  16539. /**
  16540. * Checks if the effect is supported. (Must be called after compilation)
  16541. */
  16542. readonly isSupported: boolean;
  16543. /**
  16544. * Binds a texture to the engine to be used as output of the shader.
  16545. * @param channel Name of the output variable.
  16546. * @param texture Texture to bind.
  16547. * @hidden
  16548. */
  16549. _bindTexture(channel: string, texture: InternalTexture): void;
  16550. /**
  16551. * Sets a texture on the engine to be used in the shader.
  16552. * @param channel Name of the sampler variable.
  16553. * @param texture Texture to set.
  16554. */
  16555. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  16556. /**
  16557. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  16558. * @param channel Name of the sampler variable.
  16559. * @param texture Texture to set.
  16560. */
  16561. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  16562. /**
  16563. * Sets an array of textures on the engine to be used in the shader.
  16564. * @param channel Name of the variable.
  16565. * @param textures Textures to set.
  16566. */
  16567. setTextureArray(channel: string, textures: BaseTexture[]): void;
  16568. /**
  16569. * 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)
  16570. * @param channel Name of the sampler variable.
  16571. * @param postProcess Post process to get the input texture from.
  16572. */
  16573. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  16574. /**
  16575. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  16576. * 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)
  16577. * @param channel Name of the sampler variable.
  16578. * @param postProcess Post process to get the output texture from.
  16579. */
  16580. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  16581. /** @hidden */
  16582. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  16583. /** @hidden */
  16584. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  16585. /** @hidden */
  16586. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  16587. /** @hidden */
  16588. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  16589. /**
  16590. * Binds a buffer to a uniform.
  16591. * @param buffer Buffer to bind.
  16592. * @param name Name of the uniform variable to bind to.
  16593. */
  16594. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  16595. /**
  16596. * Binds block to a uniform.
  16597. * @param blockName Name of the block to bind.
  16598. * @param index Index to bind.
  16599. */
  16600. bindUniformBlock(blockName: string, index: number): void;
  16601. /**
  16602. * Sets an interger value on a uniform variable.
  16603. * @param uniformName Name of the variable.
  16604. * @param value Value to be set.
  16605. * @returns this effect.
  16606. */
  16607. setInt(uniformName: string, value: number): Effect;
  16608. /**
  16609. * Sets an int array on a uniform variable.
  16610. * @param uniformName Name of the variable.
  16611. * @param array array to be set.
  16612. * @returns this effect.
  16613. */
  16614. setIntArray(uniformName: string, array: Int32Array): Effect;
  16615. /**
  16616. * 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)
  16617. * @param uniformName Name of the variable.
  16618. * @param array array to be set.
  16619. * @returns this effect.
  16620. */
  16621. setIntArray2(uniformName: string, array: Int32Array): Effect;
  16622. /**
  16623. * 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)
  16624. * @param uniformName Name of the variable.
  16625. * @param array array to be set.
  16626. * @returns this effect.
  16627. */
  16628. setIntArray3(uniformName: string, array: Int32Array): Effect;
  16629. /**
  16630. * 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)
  16631. * @param uniformName Name of the variable.
  16632. * @param array array to be set.
  16633. * @returns this effect.
  16634. */
  16635. setIntArray4(uniformName: string, array: Int32Array): Effect;
  16636. /**
  16637. * Sets an float array on a uniform variable.
  16638. * @param uniformName Name of the variable.
  16639. * @param array array to be set.
  16640. * @returns this effect.
  16641. */
  16642. setFloatArray(uniformName: string, array: Float32Array): Effect;
  16643. /**
  16644. * 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)
  16645. * @param uniformName Name of the variable.
  16646. * @param array array to be set.
  16647. * @returns this effect.
  16648. */
  16649. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  16650. /**
  16651. * 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)
  16652. * @param uniformName Name of the variable.
  16653. * @param array array to be set.
  16654. * @returns this effect.
  16655. */
  16656. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  16657. /**
  16658. * 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)
  16659. * @param uniformName Name of the variable.
  16660. * @param array array to be set.
  16661. * @returns this effect.
  16662. */
  16663. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  16664. /**
  16665. * Sets an array on a uniform variable.
  16666. * @param uniformName Name of the variable.
  16667. * @param array array to be set.
  16668. * @returns this effect.
  16669. */
  16670. setArray(uniformName: string, array: number[]): Effect;
  16671. /**
  16672. * 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)
  16673. * @param uniformName Name of the variable.
  16674. * @param array array to be set.
  16675. * @returns this effect.
  16676. */
  16677. setArray2(uniformName: string, array: number[]): Effect;
  16678. /**
  16679. * 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)
  16680. * @param uniformName Name of the variable.
  16681. * @param array array to be set.
  16682. * @returns this effect.
  16683. */
  16684. setArray3(uniformName: string, array: number[]): Effect;
  16685. /**
  16686. * 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)
  16687. * @param uniformName Name of the variable.
  16688. * @param array array to be set.
  16689. * @returns this effect.
  16690. */
  16691. setArray4(uniformName: string, array: number[]): Effect;
  16692. /**
  16693. * Sets matrices on a uniform variable.
  16694. * @param uniformName Name of the variable.
  16695. * @param matrices matrices to be set.
  16696. * @returns this effect.
  16697. */
  16698. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  16699. /**
  16700. * Sets matrix on a uniform variable.
  16701. * @param uniformName Name of the variable.
  16702. * @param matrix matrix to be set.
  16703. * @returns this effect.
  16704. */
  16705. setMatrix(uniformName: string, matrix: Matrix): Effect;
  16706. /**
  16707. * 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)
  16708. * @param uniformName Name of the variable.
  16709. * @param matrix matrix to be set.
  16710. * @returns this effect.
  16711. */
  16712. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  16713. /**
  16714. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  16715. * @param uniformName Name of the variable.
  16716. * @param matrix matrix to be set.
  16717. * @returns this effect.
  16718. */
  16719. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  16720. /**
  16721. * Sets a float on a uniform variable.
  16722. * @param uniformName Name of the variable.
  16723. * @param value value to be set.
  16724. * @returns this effect.
  16725. */
  16726. setFloat(uniformName: string, value: number): Effect;
  16727. /**
  16728. * Sets a boolean on a uniform variable.
  16729. * @param uniformName Name of the variable.
  16730. * @param bool value to be set.
  16731. * @returns this effect.
  16732. */
  16733. setBool(uniformName: string, bool: boolean): Effect;
  16734. /**
  16735. * Sets a Vector2 on a uniform variable.
  16736. * @param uniformName Name of the variable.
  16737. * @param vector2 vector2 to be set.
  16738. * @returns this effect.
  16739. */
  16740. setVector2(uniformName: string, vector2: Vector2): Effect;
  16741. /**
  16742. * Sets a float2 on a uniform variable.
  16743. * @param uniformName Name of the variable.
  16744. * @param x First float in float2.
  16745. * @param y Second float in float2.
  16746. * @returns this effect.
  16747. */
  16748. setFloat2(uniformName: string, x: number, y: number): Effect;
  16749. /**
  16750. * Sets a Vector3 on a uniform variable.
  16751. * @param uniformName Name of the variable.
  16752. * @param vector3 Value to be set.
  16753. * @returns this effect.
  16754. */
  16755. setVector3(uniformName: string, vector3: Vector3): Effect;
  16756. /**
  16757. * Sets a float3 on a uniform variable.
  16758. * @param uniformName Name of the variable.
  16759. * @param x First float in float3.
  16760. * @param y Second float in float3.
  16761. * @param z Third float in float3.
  16762. * @returns this effect.
  16763. */
  16764. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  16765. /**
  16766. * Sets a Vector4 on a uniform variable.
  16767. * @param uniformName Name of the variable.
  16768. * @param vector4 Value to be set.
  16769. * @returns this effect.
  16770. */
  16771. setVector4(uniformName: string, vector4: Vector4): Effect;
  16772. /**
  16773. * Sets a float4 on a uniform variable.
  16774. * @param uniformName Name of the variable.
  16775. * @param x First float in float4.
  16776. * @param y Second float in float4.
  16777. * @param z Third float in float4.
  16778. * @param w Fourth float in float4.
  16779. * @returns this effect.
  16780. */
  16781. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  16782. /**
  16783. * Sets a Color3 on a uniform variable.
  16784. * @param uniformName Name of the variable.
  16785. * @param color3 Value to be set.
  16786. * @returns this effect.
  16787. */
  16788. setColor3(uniformName: string, color3: Color3): Effect;
  16789. /**
  16790. * Sets a Color4 on a uniform variable.
  16791. * @param uniformName Name of the variable.
  16792. * @param color3 Value to be set.
  16793. * @param alpha Alpha value to be set.
  16794. * @returns this effect.
  16795. */
  16796. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  16797. /**
  16798. * Sets a Color4 on a uniform variable
  16799. * @param uniformName defines the name of the variable
  16800. * @param color4 defines the value to be set
  16801. * @returns this effect.
  16802. */
  16803. setDirectColor4(uniformName: string, color4: Color4): Effect;
  16804. /**
  16805. * This function will add a new shader to the shader store
  16806. * @param name the name of the shader
  16807. * @param pixelShader optional pixel shader content
  16808. * @param vertexShader optional vertex shader content
  16809. */
  16810. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  16811. /**
  16812. * Store of each shader (The can be looked up using effect.key)
  16813. */
  16814. static ShadersStore: {
  16815. [key: string]: string;
  16816. };
  16817. /**
  16818. * Store of each included file for a shader (The can be looked up using effect.key)
  16819. */
  16820. static IncludesShadersStore: {
  16821. [key: string]: string;
  16822. };
  16823. /**
  16824. * Resets the cache of effects.
  16825. */
  16826. static ResetCache(): void;
  16827. }
  16828. }
  16829. declare module BABYLON {
  16830. /**
  16831. * This represents all the required information to add a fresnel effect on a material:
  16832. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  16833. */
  16834. class FresnelParameters {
  16835. private _isEnabled;
  16836. /**
  16837. * Define if the fresnel effect is enable or not.
  16838. */
  16839. isEnabled: boolean;
  16840. /**
  16841. * Define the color used on edges (grazing angle)
  16842. */
  16843. leftColor: Color3;
  16844. /**
  16845. * Define the color used on center
  16846. */
  16847. rightColor: Color3;
  16848. /**
  16849. * Define bias applied to computed fresnel term
  16850. */
  16851. bias: number;
  16852. /**
  16853. * Defined the power exponent applied to fresnel term
  16854. */
  16855. power: number;
  16856. /**
  16857. * Clones the current fresnel and its valuues
  16858. * @returns a clone fresnel configuration
  16859. */
  16860. clone(): FresnelParameters;
  16861. /**
  16862. * Serializes the current fresnel parameters to a JSON representation.
  16863. * @return the JSON serialization
  16864. */
  16865. serialize(): any;
  16866. /**
  16867. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  16868. * @param parsedFresnelParameters Define the JSON representation
  16869. * @returns the parsed parameters
  16870. */
  16871. static Parse(parsedFresnelParameters: any): FresnelParameters;
  16872. }
  16873. }
  16874. declare module BABYLON {
  16875. /**
  16876. * Interface to follow in your material defines to integrate easily the
  16877. * Image proccessing functions.
  16878. * @hidden
  16879. */
  16880. interface IImageProcessingConfigurationDefines {
  16881. IMAGEPROCESSING: boolean;
  16882. VIGNETTE: boolean;
  16883. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16884. VIGNETTEBLENDMODEOPAQUE: boolean;
  16885. TONEMAPPING: boolean;
  16886. TONEMAPPING_ACES: boolean;
  16887. CONTRAST: boolean;
  16888. EXPOSURE: boolean;
  16889. COLORCURVES: boolean;
  16890. COLORGRADING: boolean;
  16891. COLORGRADING3D: boolean;
  16892. SAMPLER3DGREENDEPTH: boolean;
  16893. SAMPLER3DBGRMAP: boolean;
  16894. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16895. }
  16896. /**
  16897. * @hidden
  16898. */
  16899. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  16900. IMAGEPROCESSING: boolean;
  16901. VIGNETTE: boolean;
  16902. VIGNETTEBLENDMODEMULTIPLY: boolean;
  16903. VIGNETTEBLENDMODEOPAQUE: boolean;
  16904. TONEMAPPING: boolean;
  16905. TONEMAPPING_ACES: boolean;
  16906. CONTRAST: boolean;
  16907. COLORCURVES: boolean;
  16908. COLORGRADING: boolean;
  16909. COLORGRADING3D: boolean;
  16910. SAMPLER3DGREENDEPTH: boolean;
  16911. SAMPLER3DBGRMAP: boolean;
  16912. IMAGEPROCESSINGPOSTPROCESS: boolean;
  16913. EXPOSURE: boolean;
  16914. constructor();
  16915. }
  16916. /**
  16917. * This groups together the common properties used for image processing either in direct forward pass
  16918. * or through post processing effect depending on the use of the image processing pipeline in your scene
  16919. * or not.
  16920. */
  16921. class ImageProcessingConfiguration {
  16922. /**
  16923. * Default tone mapping applied in BabylonJS.
  16924. */
  16925. static readonly TONEMAPPING_STANDARD: number;
  16926. /**
  16927. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  16928. * to other engines rendering to increase portability.
  16929. */
  16930. static readonly TONEMAPPING_ACES: number;
  16931. /**
  16932. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  16933. */
  16934. colorCurves: Nullable<ColorCurves>;
  16935. private _colorCurvesEnabled;
  16936. /**
  16937. * Gets wether the color curves effect is enabled.
  16938. */
  16939. /**
  16940. * Sets wether the color curves effect is enabled.
  16941. */
  16942. colorCurvesEnabled: boolean;
  16943. /**
  16944. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  16945. */
  16946. colorGradingTexture: Nullable<BaseTexture>;
  16947. private _colorGradingEnabled;
  16948. /**
  16949. * Gets wether the color grading effect is enabled.
  16950. */
  16951. /**
  16952. * Sets wether the color grading effect is enabled.
  16953. */
  16954. colorGradingEnabled: boolean;
  16955. private _colorGradingWithGreenDepth;
  16956. /**
  16957. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  16958. */
  16959. /**
  16960. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  16961. */
  16962. colorGradingWithGreenDepth: boolean;
  16963. private _colorGradingBGR;
  16964. /**
  16965. * Gets wether the color grading texture contains BGR values.
  16966. */
  16967. /**
  16968. * Sets wether the color grading texture contains BGR values.
  16969. */
  16970. colorGradingBGR: boolean;
  16971. /** @hidden */
  16972. _exposure: number;
  16973. /**
  16974. * Gets the Exposure used in the effect.
  16975. */
  16976. /**
  16977. * Sets the Exposure used in the effect.
  16978. */
  16979. exposure: number;
  16980. private _toneMappingEnabled;
  16981. /**
  16982. * Gets wether the tone mapping effect is enabled.
  16983. */
  16984. /**
  16985. * Sets wether the tone mapping effect is enabled.
  16986. */
  16987. toneMappingEnabled: boolean;
  16988. private _toneMappingType;
  16989. /**
  16990. * Gets the type of tone mapping effect.
  16991. */
  16992. /**
  16993. * Sets the type of tone mapping effect used in BabylonJS.
  16994. */
  16995. toneMappingType: number;
  16996. protected _contrast: number;
  16997. /**
  16998. * Gets the contrast used in the effect.
  16999. */
  17000. /**
  17001. * Sets the contrast used in the effect.
  17002. */
  17003. contrast: number;
  17004. /**
  17005. * Vignette stretch size.
  17006. */
  17007. vignetteStretch: number;
  17008. /**
  17009. * Vignette centre X Offset.
  17010. */
  17011. vignetteCentreX: number;
  17012. /**
  17013. * Vignette centre Y Offset.
  17014. */
  17015. vignetteCentreY: number;
  17016. /**
  17017. * Vignette weight or intensity of the vignette effect.
  17018. */
  17019. vignetteWeight: number;
  17020. /**
  17021. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17022. * if vignetteEnabled is set to true.
  17023. */
  17024. vignetteColor: Color4;
  17025. /**
  17026. * Camera field of view used by the Vignette effect.
  17027. */
  17028. vignetteCameraFov: number;
  17029. private _vignetteBlendMode;
  17030. /**
  17031. * Gets the vignette blend mode allowing different kind of effect.
  17032. */
  17033. /**
  17034. * Sets the vignette blend mode allowing different kind of effect.
  17035. */
  17036. vignetteBlendMode: number;
  17037. private _vignetteEnabled;
  17038. /**
  17039. * Gets wether the vignette effect is enabled.
  17040. */
  17041. /**
  17042. * Sets wether the vignette effect is enabled.
  17043. */
  17044. vignetteEnabled: boolean;
  17045. private _applyByPostProcess;
  17046. /**
  17047. * Gets wether the image processing is applied through a post process or not.
  17048. */
  17049. /**
  17050. * Sets wether the image processing is applied through a post process or not.
  17051. */
  17052. applyByPostProcess: boolean;
  17053. private _isEnabled;
  17054. /**
  17055. * Gets wether the image processing is enabled or not.
  17056. */
  17057. /**
  17058. * Sets wether the image processing is enabled or not.
  17059. */
  17060. isEnabled: boolean;
  17061. /**
  17062. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17063. */
  17064. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17065. /**
  17066. * Method called each time the image processing information changes requires to recompile the effect.
  17067. */
  17068. protected _updateParameters(): void;
  17069. /**
  17070. * Gets the current class name.
  17071. * @return "ImageProcessingConfiguration"
  17072. */
  17073. getClassName(): string;
  17074. /**
  17075. * Prepare the list of uniforms associated with the Image Processing effects.
  17076. * @param uniforms The list of uniforms used in the effect
  17077. * @param defines the list of defines currently in use
  17078. */
  17079. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17080. /**
  17081. * Prepare the list of samplers associated with the Image Processing effects.
  17082. * @param samplersList The list of uniforms used in the effect
  17083. * @param defines the list of defines currently in use
  17084. */
  17085. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17086. /**
  17087. * Prepare the list of defines associated to the shader.
  17088. * @param defines the list of defines to complete
  17089. * @param forPostProcess Define if we are currently in post process mode or not
  17090. */
  17091. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17092. /**
  17093. * Returns true if all the image processing information are ready.
  17094. * @returns True if ready, otherwise, false
  17095. */
  17096. isReady(): boolean;
  17097. /**
  17098. * Binds the image processing to the shader.
  17099. * @param effect The effect to bind to
  17100. * @param aspectRatio Define the current aspect ratio of the effect
  17101. */
  17102. bind(effect: Effect, aspectRatio?: number): void;
  17103. /**
  17104. * Clones the current image processing instance.
  17105. * @return The cloned image processing
  17106. */
  17107. clone(): ImageProcessingConfiguration;
  17108. /**
  17109. * Serializes the current image processing instance to a json representation.
  17110. * @return a JSON representation
  17111. */
  17112. serialize(): any;
  17113. /**
  17114. * Parses the image processing from a json representation.
  17115. * @param source the JSON source to parse
  17116. * @return The parsed image processing
  17117. */
  17118. static Parse(source: any): ImageProcessingConfiguration;
  17119. private static _VIGNETTEMODE_MULTIPLY;
  17120. private static _VIGNETTEMODE_OPAQUE;
  17121. /**
  17122. * Used to apply the vignette as a mix with the pixel color.
  17123. */
  17124. static readonly VIGNETTEMODE_MULTIPLY: number;
  17125. /**
  17126. * Used to apply the vignette as a replacement of the pixel color.
  17127. */
  17128. static readonly VIGNETTEMODE_OPAQUE: number;
  17129. }
  17130. }
  17131. declare module BABYLON {
  17132. /**
  17133. * Manages the defines for the Material
  17134. */
  17135. class MaterialDefines {
  17136. private _keys;
  17137. private _isDirty;
  17138. /** @hidden */
  17139. _renderId: number;
  17140. /** @hidden */
  17141. _areLightsDirty: boolean;
  17142. /** @hidden */
  17143. _areAttributesDirty: boolean;
  17144. /** @hidden */
  17145. _areTexturesDirty: boolean;
  17146. /** @hidden */
  17147. _areFresnelDirty: boolean;
  17148. /** @hidden */
  17149. _areMiscDirty: boolean;
  17150. /** @hidden */
  17151. _areImageProcessingDirty: boolean;
  17152. /** @hidden */
  17153. _normals: boolean;
  17154. /** @hidden */
  17155. _uvs: boolean;
  17156. /** @hidden */
  17157. _needNormals: boolean;
  17158. /** @hidden */
  17159. _needUVs: boolean;
  17160. /**
  17161. * Specifies if the material needs to be re-calculated
  17162. */
  17163. readonly isDirty: boolean;
  17164. /**
  17165. * Marks the material to indicate that it has been re-calculated
  17166. */
  17167. markAsProcessed(): void;
  17168. /**
  17169. * Marks the material to indicate that it needs to be re-calculated
  17170. */
  17171. markAsUnprocessed(): void;
  17172. /**
  17173. * Marks the material to indicate all of its defines need to be re-calculated
  17174. */
  17175. markAllAsDirty(): void;
  17176. /**
  17177. * Marks the material to indicate that image processing needs to be re-calculated
  17178. */
  17179. markAsImageProcessingDirty(): void;
  17180. /**
  17181. * Marks the material to indicate the lights need to be re-calculated
  17182. */
  17183. markAsLightDirty(): void;
  17184. /**
  17185. * Marks the attribute state as changed
  17186. */
  17187. markAsAttributesDirty(): void;
  17188. /**
  17189. * Marks the texture state as changed
  17190. */
  17191. markAsTexturesDirty(): void;
  17192. /**
  17193. * Marks the fresnel state as changed
  17194. */
  17195. markAsFresnelDirty(): void;
  17196. /**
  17197. * Marks the misc state as changed
  17198. */
  17199. markAsMiscDirty(): void;
  17200. /**
  17201. * Rebuilds the material defines
  17202. */
  17203. rebuild(): void;
  17204. /**
  17205. * Specifies if two material defines are equal
  17206. * @param other - A material define instance to compare to
  17207. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17208. */
  17209. isEqual(other: MaterialDefines): boolean;
  17210. /**
  17211. * Clones this instance's defines to another instance
  17212. * @param other - material defines to clone values to
  17213. */
  17214. cloneTo(other: MaterialDefines): void;
  17215. /**
  17216. * Resets the material define values
  17217. */
  17218. reset(): void;
  17219. /**
  17220. * Converts the material define values to a string
  17221. * @returns - String of material define information
  17222. */
  17223. toString(): string;
  17224. }
  17225. /**
  17226. * Base class for the main features of a material in Babylon.js
  17227. */
  17228. class Material implements IAnimatable {
  17229. private static _TriangleFillMode;
  17230. private static _WireFrameFillMode;
  17231. private static _PointFillMode;
  17232. private static _PointListDrawMode;
  17233. private static _LineListDrawMode;
  17234. private static _LineLoopDrawMode;
  17235. private static _LineStripDrawMode;
  17236. private static _TriangleStripDrawMode;
  17237. private static _TriangleFanDrawMode;
  17238. /**
  17239. * Returns the triangle fill mode
  17240. */
  17241. static readonly TriangleFillMode: number;
  17242. /**
  17243. * Returns the wireframe mode
  17244. */
  17245. static readonly WireFrameFillMode: number;
  17246. /**
  17247. * Returns the point fill mode
  17248. */
  17249. static readonly PointFillMode: number;
  17250. /**
  17251. * Returns the point list draw mode
  17252. */
  17253. static readonly PointListDrawMode: number;
  17254. /**
  17255. * Returns the line list draw mode
  17256. */
  17257. static readonly LineListDrawMode: number;
  17258. /**
  17259. * Returns the line loop draw mode
  17260. */
  17261. static readonly LineLoopDrawMode: number;
  17262. /**
  17263. * Returns the line strip draw mode
  17264. */
  17265. static readonly LineStripDrawMode: number;
  17266. /**
  17267. * Returns the triangle strip draw mode
  17268. */
  17269. static readonly TriangleStripDrawMode: number;
  17270. /**
  17271. * Returns the triangle fan draw mode
  17272. */
  17273. static readonly TriangleFanDrawMode: number;
  17274. /**
  17275. * Stores the clock-wise side orientation
  17276. */
  17277. private static _ClockWiseSideOrientation;
  17278. /**
  17279. * Stores the counter clock-wise side orientation
  17280. */
  17281. private static _CounterClockWiseSideOrientation;
  17282. /**
  17283. * Returns the clock-wise side orientation
  17284. */
  17285. static readonly ClockWiseSideOrientation: number;
  17286. /**
  17287. * Returns the counter clock-wise side orientation
  17288. */
  17289. static readonly CounterClockWiseSideOrientation: number;
  17290. /**
  17291. * The dirty texture flag value
  17292. */
  17293. static readonly TextureDirtyFlag: number;
  17294. /**
  17295. * The dirty light flag value
  17296. */
  17297. static readonly LightDirtyFlag: number;
  17298. /**
  17299. * The dirty fresnel flag value
  17300. */
  17301. static readonly FresnelDirtyFlag: number;
  17302. /**
  17303. * The dirty attribute flag value
  17304. */
  17305. static readonly AttributesDirtyFlag: number;
  17306. /**
  17307. * The dirty misc flag value
  17308. */
  17309. static readonly MiscDirtyFlag: number;
  17310. /**
  17311. * The all dirty flag value
  17312. */
  17313. static readonly AllDirtyFlag: number;
  17314. /**
  17315. * The ID of the material
  17316. */
  17317. id: string;
  17318. /**
  17319. * Gets or sets the unique id of the material
  17320. */
  17321. uniqueId: number;
  17322. /**
  17323. * The name of the material
  17324. */
  17325. name: string;
  17326. /**
  17327. * Specifies if the ready state should be checked on each call
  17328. */
  17329. checkReadyOnEveryCall: boolean;
  17330. /**
  17331. * Specifies if the ready state should be checked once
  17332. */
  17333. checkReadyOnlyOnce: boolean;
  17334. /**
  17335. * The state of the material
  17336. */
  17337. state: string;
  17338. /**
  17339. * The alpha value of the material
  17340. */
  17341. protected _alpha: number;
  17342. /**
  17343. * Sets the alpha value of the material
  17344. */
  17345. /**
  17346. * Gets the alpha value of the material
  17347. */
  17348. alpha: number;
  17349. /**
  17350. * Specifies if back face culling is enabled
  17351. */
  17352. protected _backFaceCulling: boolean;
  17353. /**
  17354. * Sets the back-face culling state
  17355. */
  17356. /**
  17357. * Gets the back-face culling state
  17358. */
  17359. backFaceCulling: boolean;
  17360. /**
  17361. * Stores the value for side orientation
  17362. */
  17363. sideOrientation: number;
  17364. /**
  17365. * Callback triggered when the material is compiled
  17366. */
  17367. onCompiled: (effect: Effect) => void;
  17368. /**
  17369. * Callback triggered when an error occurs
  17370. */
  17371. onError: (effect: Effect, errors: string) => void;
  17372. /**
  17373. * Callback triggered to get the render target textures
  17374. */
  17375. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17376. /**
  17377. * Gets a boolean indicating that current material needs to register RTT
  17378. */
  17379. readonly hasRenderTargetTextures: boolean;
  17380. /**
  17381. * Specifies if the material should be serialized
  17382. */
  17383. doNotSerialize: boolean;
  17384. /**
  17385. * Specifies if the effect should be stored on sub meshes
  17386. */
  17387. storeEffectOnSubMeshes: boolean;
  17388. /**
  17389. * Stores the animations for the material
  17390. */
  17391. animations: Array<Animation>;
  17392. /**
  17393. * An event triggered when the material is disposed
  17394. */
  17395. onDisposeObservable: Observable<Material>;
  17396. /**
  17397. * An observer which watches for dispose events
  17398. */
  17399. private _onDisposeObserver;
  17400. private _onUnBindObservable;
  17401. /**
  17402. * Called during a dispose event
  17403. */
  17404. onDispose: () => void;
  17405. private _onBindObservable;
  17406. /**
  17407. * An event triggered when the material is bound
  17408. */
  17409. readonly onBindObservable: Observable<AbstractMesh>;
  17410. /**
  17411. * An observer which watches for bind events
  17412. */
  17413. private _onBindObserver;
  17414. /**
  17415. * Called during a bind event
  17416. */
  17417. onBind: (Mesh: AbstractMesh) => void;
  17418. /**
  17419. * An event triggered when the material is unbound
  17420. */
  17421. readonly onUnBindObservable: Observable<Material>;
  17422. /**
  17423. * Stores the value of the alpha mode
  17424. */
  17425. private _alphaMode;
  17426. /**
  17427. * Sets the value of the alpha mode.
  17428. *
  17429. * | Value | Type | Description |
  17430. * | --- | --- | --- |
  17431. * | 0 | ALPHA_DISABLE | |
  17432. * | 1 | ALPHA_ADD | |
  17433. * | 2 | ALPHA_COMBINE | |
  17434. * | 3 | ALPHA_SUBTRACT | |
  17435. * | 4 | ALPHA_MULTIPLY | |
  17436. * | 5 | ALPHA_MAXIMIZED | |
  17437. * | 6 | ALPHA_ONEONE | |
  17438. * | 7 | ALPHA_PREMULTIPLIED | |
  17439. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17440. * | 9 | ALPHA_INTERPOLATE | |
  17441. * | 10 | ALPHA_SCREENMODE | |
  17442. *
  17443. */
  17444. /**
  17445. * Gets the value of the alpha mode
  17446. */
  17447. alphaMode: number;
  17448. /**
  17449. * Stores the state of the need depth pre-pass value
  17450. */
  17451. private _needDepthPrePass;
  17452. /**
  17453. * Sets the need depth pre-pass value
  17454. */
  17455. /**
  17456. * Gets the depth pre-pass value
  17457. */
  17458. needDepthPrePass: boolean;
  17459. /**
  17460. * Specifies if depth writing should be disabled
  17461. */
  17462. disableDepthWrite: boolean;
  17463. /**
  17464. * Specifies if depth writing should be forced
  17465. */
  17466. forceDepthWrite: boolean;
  17467. /**
  17468. * Specifies if there should be a separate pass for culling
  17469. */
  17470. separateCullingPass: boolean;
  17471. /**
  17472. * Stores the state specifing if fog should be enabled
  17473. */
  17474. private _fogEnabled;
  17475. /**
  17476. * Sets the state for enabling fog
  17477. */
  17478. /**
  17479. * Gets the value of the fog enabled state
  17480. */
  17481. fogEnabled: boolean;
  17482. /**
  17483. * Stores the size of points
  17484. */
  17485. pointSize: number;
  17486. /**
  17487. * Stores the z offset value
  17488. */
  17489. zOffset: number;
  17490. /**
  17491. * Gets a value specifying if wireframe mode is enabled
  17492. */
  17493. /**
  17494. * Sets the state of wireframe mode
  17495. */
  17496. wireframe: boolean;
  17497. /**
  17498. * Gets the value specifying if point clouds are enabled
  17499. */
  17500. /**
  17501. * Sets the state of point cloud mode
  17502. */
  17503. pointsCloud: boolean;
  17504. /**
  17505. * Gets the material fill mode
  17506. */
  17507. /**
  17508. * Sets the material fill mode
  17509. */
  17510. fillMode: number;
  17511. /**
  17512. * @hidden
  17513. * Stores the effects for the material
  17514. */
  17515. _effect: Nullable<Effect>;
  17516. /**
  17517. * @hidden
  17518. * Specifies if the material was previously ready
  17519. */
  17520. _wasPreviouslyReady: boolean;
  17521. /**
  17522. * Specifies if uniform buffers should be used
  17523. */
  17524. private _useUBO;
  17525. /**
  17526. * Stores a reference to the scene
  17527. */
  17528. private _scene;
  17529. /**
  17530. * Stores the fill mode state
  17531. */
  17532. private _fillMode;
  17533. /**
  17534. * Specifies if the depth write state should be cached
  17535. */
  17536. private _cachedDepthWriteState;
  17537. /**
  17538. * Stores the uniform buffer
  17539. */
  17540. protected _uniformBuffer: UniformBuffer;
  17541. /**
  17542. * Creates a material instance
  17543. * @param name defines the name of the material
  17544. * @param scene defines the scene to reference
  17545. * @param doNotAdd specifies if the material should be added to the scene
  17546. */
  17547. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17548. /**
  17549. * Returns a string representation of the current material
  17550. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17551. * @returns a string with material information
  17552. */
  17553. toString(fullDetails?: boolean): string;
  17554. /**
  17555. * Gets the class name of the material
  17556. * @returns a string with the class name of the material
  17557. */
  17558. getClassName(): string;
  17559. /**
  17560. * Specifies if updates for the material been locked
  17561. */
  17562. readonly isFrozen: boolean;
  17563. /**
  17564. * Locks updates for the material
  17565. */
  17566. freeze(): void;
  17567. /**
  17568. * Unlocks updates for the material
  17569. */
  17570. unfreeze(): void;
  17571. /**
  17572. * Specifies if the material is ready to be used
  17573. * @param mesh defines the mesh to check
  17574. * @param useInstances specifies if instances should be used
  17575. * @returns a boolean indicating if the material is ready to be used
  17576. */
  17577. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17578. /**
  17579. * Specifies that the submesh is ready to be used
  17580. * @param mesh defines the mesh to check
  17581. * @param subMesh defines which submesh to check
  17582. * @param useInstances specifies that instances should be used
  17583. * @returns a boolean indicating that the submesh is ready or not
  17584. */
  17585. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17586. /**
  17587. * Returns the material effect
  17588. * @returns the effect associated with the material
  17589. */
  17590. getEffect(): Nullable<Effect>;
  17591. /**
  17592. * Returns the current scene
  17593. * @returns a Scene
  17594. */
  17595. getScene(): Scene;
  17596. /**
  17597. * Specifies if the material will require alpha blending
  17598. * @returns a boolean specifying if alpha blending is needed
  17599. */
  17600. needAlphaBlending(): boolean;
  17601. /**
  17602. * Specifies if the mesh will require alpha blending
  17603. * @param mesh defines the mesh to check
  17604. * @returns a boolean specifying if alpha blending is needed for the mesh
  17605. */
  17606. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17607. /**
  17608. * Specifies if this material should be rendered in alpha test mode
  17609. * @returns a boolean specifying if an alpha test is needed.
  17610. */
  17611. needAlphaTesting(): boolean;
  17612. /**
  17613. * Gets the texture used for the alpha test
  17614. * @returns the texture to use for alpha testing
  17615. */
  17616. getAlphaTestTexture(): Nullable<BaseTexture>;
  17617. /**
  17618. * Marks the material to indicate that it needs to be re-calculated
  17619. */
  17620. markDirty(): void;
  17621. /** @hidden */
  17622. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17623. /**
  17624. * Binds the material to the mesh
  17625. * @param world defines the world transformation matrix
  17626. * @param mesh defines the mesh to bind the material to
  17627. */
  17628. bind(world: Matrix, mesh?: Mesh): void;
  17629. /**
  17630. * Binds the submesh to the material
  17631. * @param world defines the world transformation matrix
  17632. * @param mesh defines the mesh containing the submesh
  17633. * @param subMesh defines the submesh to bind the material to
  17634. */
  17635. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17636. /**
  17637. * Binds the world matrix to the material
  17638. * @param world defines the world transformation matrix
  17639. */
  17640. bindOnlyWorldMatrix(world: Matrix): void;
  17641. /**
  17642. * Binds the scene's uniform buffer to the effect.
  17643. * @param effect defines the effect to bind to the scene uniform buffer
  17644. * @param sceneUbo defines the uniform buffer storing scene data
  17645. */
  17646. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17647. /**
  17648. * Binds the view matrix to the effect
  17649. * @param effect defines the effect to bind the view matrix to
  17650. */
  17651. bindView(effect: Effect): void;
  17652. /**
  17653. * Binds the view projection matrix to the effect
  17654. * @param effect defines the effect to bind the view projection matrix to
  17655. */
  17656. bindViewProjection(effect: Effect): void;
  17657. /**
  17658. * Specifies if material alpha testing should be turned on for the mesh
  17659. * @param mesh defines the mesh to check
  17660. */
  17661. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17662. /**
  17663. * Processes to execute after binding the material to a mesh
  17664. * @param mesh defines the rendered mesh
  17665. */
  17666. protected _afterBind(mesh?: Mesh): void;
  17667. /**
  17668. * Unbinds the material from the mesh
  17669. */
  17670. unbind(): void;
  17671. /**
  17672. * Gets the active textures from the material
  17673. * @returns an array of textures
  17674. */
  17675. getActiveTextures(): BaseTexture[];
  17676. /**
  17677. * Specifies if the material uses a texture
  17678. * @param texture defines the texture to check against the material
  17679. * @returns a boolean specifying if the material uses the texture
  17680. */
  17681. hasTexture(texture: BaseTexture): boolean;
  17682. /**
  17683. * Makes a duplicate of the material, and gives it a new name
  17684. * @param name defines the new name for the duplicated material
  17685. * @returns the cloned material
  17686. */
  17687. clone(name: string): Nullable<Material>;
  17688. /**
  17689. * Gets the meshes bound to the material
  17690. * @returns an array of meshes bound to the material
  17691. */
  17692. getBindedMeshes(): AbstractMesh[];
  17693. /**
  17694. * Force shader compilation
  17695. * @param mesh defines the mesh associated with this material
  17696. * @param onCompiled defines a function to execute once the material is compiled
  17697. * @param options defines the options to configure the compilation
  17698. */
  17699. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17700. clipPlane: boolean;
  17701. }>): void;
  17702. /**
  17703. * Force shader compilation
  17704. * @param mesh defines the mesh that will use this material
  17705. * @param options defines additional options for compiling the shaders
  17706. * @returns a promise that resolves when the compilation completes
  17707. */
  17708. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17709. clipPlane: boolean;
  17710. }>): Promise<void>;
  17711. /**
  17712. * Marks a define in the material to indicate that it needs to be re-computed
  17713. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17714. */
  17715. markAsDirty(flag: number): void;
  17716. /**
  17717. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17718. * @param func defines a function which checks material defines against the submeshes
  17719. */
  17720. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17721. /**
  17722. * Indicates that image processing needs to be re-calculated for all submeshes
  17723. */
  17724. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17725. /**
  17726. * Indicates that textures need to be re-calculated for all submeshes
  17727. */
  17728. protected _markAllSubMeshesAsTexturesDirty(): void;
  17729. /**
  17730. * Indicates that fresnel needs to be re-calculated for all submeshes
  17731. */
  17732. protected _markAllSubMeshesAsFresnelDirty(): void;
  17733. /**
  17734. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17735. */
  17736. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17737. /**
  17738. * Indicates that lights need to be re-calculated for all submeshes
  17739. */
  17740. protected _markAllSubMeshesAsLightsDirty(): void;
  17741. /**
  17742. * Indicates that attributes need to be re-calculated for all submeshes
  17743. */
  17744. protected _markAllSubMeshesAsAttributesDirty(): void;
  17745. /**
  17746. * Indicates that misc needs to be re-calculated for all submeshes
  17747. */
  17748. protected _markAllSubMeshesAsMiscDirty(): void;
  17749. /**
  17750. * Indicates that textures and misc need to be re-calculated for all submeshes
  17751. */
  17752. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17753. /**
  17754. * Disposes the material
  17755. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17756. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17757. */
  17758. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  17759. /**
  17760. * Serializes this material
  17761. * @returns the serialized material object
  17762. */
  17763. serialize(): any;
  17764. /**
  17765. * Creates a MultiMaterial from parsed MultiMaterial data.
  17766. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  17767. * @param scene defines the hosting scene
  17768. * @returns a new MultiMaterial
  17769. */
  17770. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  17771. /**
  17772. * Creates a material from parsed material data
  17773. * @param parsedMaterial defines parsed material data
  17774. * @param scene defines the hosting scene
  17775. * @param rootUrl defines the root URL to use to load textures
  17776. * @returns a new material
  17777. */
  17778. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17779. }
  17780. }
  17781. declare module BABYLON {
  17782. /**
  17783. * "Static Class" containing the most commonly used helper while dealing with material for
  17784. * rendering purpose.
  17785. *
  17786. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  17787. *
  17788. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  17789. */
  17790. class MaterialHelper {
  17791. /**
  17792. * Bind the current view position to an effect.
  17793. * @param effect The effect to be bound
  17794. * @param scene The scene the eyes position is used from
  17795. */
  17796. static BindEyePosition(effect: Effect, scene: Scene): void;
  17797. /**
  17798. * Helps preparing the defines values about the UVs in used in the effect.
  17799. * UVs are shared as much as we can accross channels in the shaders.
  17800. * @param texture The texture we are preparing the UVs for
  17801. * @param defines The defines to update
  17802. * @param key The channel key "diffuse", "specular"... used in the shader
  17803. */
  17804. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  17805. /**
  17806. * Binds a texture matrix value to its corrsponding uniform
  17807. * @param texture The texture to bind the matrix for
  17808. * @param uniformBuffer The uniform buffer receivin the data
  17809. * @param key The channel key "diffuse", "specular"... used in the shader
  17810. */
  17811. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  17812. /**
  17813. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  17814. * @param mesh defines the current mesh
  17815. * @param scene defines the current scene
  17816. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  17817. * @param pointsCloud defines if point cloud rendering has to be turned on
  17818. * @param fogEnabled defines if fog has to be turned on
  17819. * @param alphaTest defines if alpha testing has to be turned on
  17820. * @param defines defines the current list of defines
  17821. */
  17822. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  17823. /**
  17824. * Helper used to prepare the list of defines associated with frame values for shader compilation
  17825. * @param scene defines the current scene
  17826. * @param engine defines the current engine
  17827. * @param defines specifies the list of active defines
  17828. * @param useInstances defines if instances have to be turned on
  17829. * @param useClipPlane defines if clip plane have to be turned on
  17830. */
  17831. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  17832. /**
  17833. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  17834. * @param mesh The mesh containing the geometry data we will draw
  17835. * @param defines The defines to update
  17836. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  17837. * @param useBones Precise whether bones should be used or not (override mesh info)
  17838. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  17839. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  17840. * @returns false if defines are considered not dirty and have not been checked
  17841. */
  17842. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  17843. /**
  17844. * Prepares the defines related to the light information passed in parameter
  17845. * @param scene The scene we are intending to draw
  17846. * @param mesh The mesh the effect is compiling for
  17847. * @param defines The defines to update
  17848. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  17849. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  17850. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  17851. * @returns true if normals will be required for the rest of the effect
  17852. */
  17853. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  17854. /**
  17855. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  17856. * that won t be acctive due to defines being turned off.
  17857. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  17858. * @param samplersList The samplers list
  17859. * @param defines The defines helping in the list generation
  17860. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  17861. */
  17862. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  17863. /**
  17864. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  17865. * @param defines The defines to update while falling back
  17866. * @param fallbacks The authorized effect fallbacks
  17867. * @param maxSimultaneousLights The maximum number of lights allowed
  17868. * @param rank the current rank of the Effect
  17869. * @returns The newly affected rank
  17870. */
  17871. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  17872. /**
  17873. * Prepares the list of attributes required for morph targets according to the effect defines.
  17874. * @param attribs The current list of supported attribs
  17875. * @param mesh The mesh to prepare the morph targets attributes for
  17876. * @param defines The current Defines of the effect
  17877. */
  17878. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  17879. /**
  17880. * Prepares the list of attributes required for bones according to the effect defines.
  17881. * @param attribs The current list of supported attribs
  17882. * @param mesh The mesh to prepare the bones attributes for
  17883. * @param defines The current Defines of the effect
  17884. * @param fallbacks The current efffect fallback strategy
  17885. */
  17886. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  17887. /**
  17888. * Prepares the list of attributes required for instances according to the effect defines.
  17889. * @param attribs The current list of supported attribs
  17890. * @param defines The current Defines of the effect
  17891. */
  17892. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  17893. /**
  17894. * Binds the light shadow information to the effect for the given mesh.
  17895. * @param light The light containing the generator
  17896. * @param scene The scene the lights belongs to
  17897. * @param mesh The mesh we are binding the information to render
  17898. * @param lightIndex The light index in the effect used to render the mesh
  17899. * @param effect The effect we are binding the data to
  17900. */
  17901. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  17902. /**
  17903. * Binds the light information to the effect.
  17904. * @param light The light containing the generator
  17905. * @param effect The effect we are binding the data to
  17906. * @param lightIndex The light index in the effect used to render
  17907. */
  17908. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  17909. /**
  17910. * Binds the lights information from the scene to the effect for the given mesh.
  17911. * @param scene The scene the lights belongs to
  17912. * @param mesh The mesh we are binding the information to render
  17913. * @param effect The effect we are binding the data to
  17914. * @param defines The generated defines for the effect
  17915. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  17916. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  17917. */
  17918. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  17919. private static _tempFogColor;
  17920. /**
  17921. * Binds the fog information from the scene to the effect for the given mesh.
  17922. * @param scene The scene the lights belongs to
  17923. * @param mesh The mesh we are binding the information to render
  17924. * @param effect The effect we are binding the data to
  17925. * @param linearSpace Defines if the fog effect is applied in linear space
  17926. */
  17927. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  17928. /**
  17929. * Binds the bones information from the mesh to the effect.
  17930. * @param mesh The mesh we are binding the information to render
  17931. * @param effect The effect we are binding the data to
  17932. */
  17933. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  17934. /**
  17935. * Binds the morph targets information from the mesh to the effect.
  17936. * @param abstractMesh The mesh we are binding the information to render
  17937. * @param effect The effect we are binding the data to
  17938. */
  17939. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  17940. /**
  17941. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  17942. * @param defines The generated defines used in the effect
  17943. * @param effect The effect we are binding the data to
  17944. * @param scene The scene we are willing to render with logarithmic scale for
  17945. */
  17946. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  17947. /**
  17948. * Binds the clip plane information from the scene to the effect.
  17949. * @param scene The scene the clip plane information are extracted from
  17950. * @param effect The effect we are binding the data to
  17951. */
  17952. static BindClipPlane(effect: Effect, scene: Scene): void;
  17953. }
  17954. }
  17955. declare module BABYLON {
  17956. /**
  17957. * A multi-material is used to apply different materials to different parts of the same object without the need of
  17958. * separate meshes. This can be use to improve performances.
  17959. * @see http://doc.babylonjs.com/how_to/multi_materials
  17960. */
  17961. class MultiMaterial extends Material {
  17962. private _subMaterials;
  17963. /**
  17964. * Gets or Sets the list of Materials used within the multi material.
  17965. * They need to be ordered according to the submeshes order in the associated mesh
  17966. */
  17967. subMaterials: Nullable<Material>[];
  17968. /**
  17969. * Instantiates a new Multi Material
  17970. * A multi-material is used to apply different materials to different parts of the same object without the need of
  17971. * separate meshes. This can be use to improve performances.
  17972. * @see http://doc.babylonjs.com/how_to/multi_materials
  17973. * @param name Define the name in the scene
  17974. * @param scene Define the scene the material belongs to
  17975. */
  17976. constructor(name: string, scene: Scene);
  17977. private _hookArray;
  17978. /**
  17979. * Get one of the submaterial by its index in the submaterials array
  17980. * @param index The index to look the sub material at
  17981. * @returns The Material if the index has been defined
  17982. */
  17983. getSubMaterial(index: number): Nullable<Material>;
  17984. /**
  17985. * Get the list of active textures for the whole sub materials list.
  17986. * @returns All the textures that will be used during the rendering
  17987. */
  17988. getActiveTextures(): BaseTexture[];
  17989. /**
  17990. * Gets the current class name of the material e.g. "MultiMaterial"
  17991. * Mainly use in serialization.
  17992. * @returns the class name
  17993. */
  17994. getClassName(): string;
  17995. /**
  17996. * Checks if the material is ready to render the requested sub mesh
  17997. * @param mesh Define the mesh the submesh belongs to
  17998. * @param subMesh Define the sub mesh to look readyness for
  17999. * @param useInstances Define whether or not the material is used with instances
  18000. * @returns true if ready, otherwise false
  18001. */
  18002. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18003. /**
  18004. * Clones the current material and its related sub materials
  18005. * @param name Define the name of the newly cloned material
  18006. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18007. * @returns the cloned material
  18008. */
  18009. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18010. /**
  18011. * Serializes the materials into a JSON representation.
  18012. * @returns the JSON representation
  18013. */
  18014. serialize(): any;
  18015. /**
  18016. * Dispose the material and release its associated resources
  18017. * @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)
  18018. * @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)
  18019. */
  18020. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18021. }
  18022. }
  18023. declare module BABYLON {
  18024. /**
  18025. * Base class of materials working in push mode in babylon JS
  18026. * @hidden
  18027. */
  18028. class PushMaterial extends Material {
  18029. protected _activeEffect: Effect;
  18030. protected _normalMatrix: Matrix;
  18031. constructor(name: string, scene: Scene);
  18032. getEffect(): Effect;
  18033. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18034. /**
  18035. * Binds the given world matrix to the active effect
  18036. *
  18037. * @param world the matrix to bind
  18038. */
  18039. bindOnlyWorldMatrix(world: Matrix): void;
  18040. /**
  18041. * Binds the given normal matrix to the active effect
  18042. *
  18043. * @param normalMatrix the matrix to bind
  18044. */
  18045. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18046. bind(world: Matrix, mesh?: Mesh): void;
  18047. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18048. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18049. }
  18050. }
  18051. declare module BABYLON {
  18052. /**
  18053. * Defines the options associated with the creation of a shader material.
  18054. */
  18055. interface IShaderMaterialOptions {
  18056. /**
  18057. * Does the material work in alpha blend mode
  18058. */
  18059. needAlphaBlending: boolean;
  18060. /**
  18061. * Does the material work in alpha test mode
  18062. */
  18063. needAlphaTesting: boolean;
  18064. /**
  18065. * The list of attribute names used in the shader
  18066. */
  18067. attributes: string[];
  18068. /**
  18069. * The list of unifrom names used in the shader
  18070. */
  18071. uniforms: string[];
  18072. /**
  18073. * The list of UBO names used in the shader
  18074. */
  18075. uniformBuffers: string[];
  18076. /**
  18077. * The list of sampler names used in the shader
  18078. */
  18079. samplers: string[];
  18080. /**
  18081. * The list of defines used in the shader
  18082. */
  18083. defines: string[];
  18084. }
  18085. /**
  18086. * 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.
  18087. *
  18088. * This returned material effects how the mesh will look based on the code in the shaders.
  18089. *
  18090. * @see http://doc.babylonjs.com/how_to/shader_material
  18091. */
  18092. class ShaderMaterial extends Material {
  18093. private _shaderPath;
  18094. private _options;
  18095. private _textures;
  18096. private _textureArrays;
  18097. private _floats;
  18098. private _ints;
  18099. private _floatsArrays;
  18100. private _colors3;
  18101. private _colors3Arrays;
  18102. private _colors4;
  18103. private _vectors2;
  18104. private _vectors3;
  18105. private _vectors4;
  18106. private _matrices;
  18107. private _matrices3x3;
  18108. private _matrices2x2;
  18109. private _vectors2Arrays;
  18110. private _vectors3Arrays;
  18111. private _cachedWorldViewMatrix;
  18112. private _renderId;
  18113. /**
  18114. * Instantiate a new shader material.
  18115. * 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.
  18116. * This returned material effects how the mesh will look based on the code in the shaders.
  18117. * @see http://doc.babylonjs.com/how_to/shader_material
  18118. * @param name Define the name of the material in the scene
  18119. * @param scene Define the scene the material belongs to
  18120. * @param shaderPath Defines the route to the shader code in one of three ways:
  18121. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18122. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18123. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18124. * @param options Define the options used to create the shader
  18125. */
  18126. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18127. /**
  18128. * Gets the current class name of the material e.g. "ShaderMaterial"
  18129. * Mainly use in serialization.
  18130. * @returns the class name
  18131. */
  18132. getClassName(): string;
  18133. /**
  18134. * Specifies if the material will require alpha blending
  18135. * @returns a boolean specifying if alpha blending is needed
  18136. */
  18137. needAlphaBlending(): boolean;
  18138. /**
  18139. * Specifies if this material should be rendered in alpha test mode
  18140. * @returns a boolean specifying if an alpha test is needed.
  18141. */
  18142. needAlphaTesting(): boolean;
  18143. private _checkUniform;
  18144. /**
  18145. * Set a texture in the shader.
  18146. * @param name Define the name of the uniform samplers as defined in the shader
  18147. * @param texture Define the texture to bind to this sampler
  18148. * @return the material itself allowing "fluent" like uniform updates
  18149. */
  18150. setTexture(name: string, texture: Texture): ShaderMaterial;
  18151. /**
  18152. * Set a texture array in the shader.
  18153. * @param name Define the name of the uniform sampler array as defined in the shader
  18154. * @param textures Define the list of textures to bind to this sampler
  18155. * @return the material itself allowing "fluent" like uniform updates
  18156. */
  18157. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18158. /**
  18159. * Set a float in the shader.
  18160. * @param name Define the name of the uniform as defined in the shader
  18161. * @param value Define the value to give to the uniform
  18162. * @return the material itself allowing "fluent" like uniform updates
  18163. */
  18164. setFloat(name: string, value: number): ShaderMaterial;
  18165. /**
  18166. * Set a int in the shader.
  18167. * @param name Define the name of the uniform as defined in the shader
  18168. * @param value Define the value to give to the uniform
  18169. * @return the material itself allowing "fluent" like uniform updates
  18170. */
  18171. setInt(name: string, value: number): ShaderMaterial;
  18172. /**
  18173. * Set an array of floats in the shader.
  18174. * @param name Define the name of the uniform as defined in the shader
  18175. * @param value Define the value to give to the uniform
  18176. * @return the material itself allowing "fluent" like uniform updates
  18177. */
  18178. setFloats(name: string, value: number[]): ShaderMaterial;
  18179. /**
  18180. * Set a vec3 in the shader from a Color3.
  18181. * @param name Define the name of the uniform as defined in the shader
  18182. * @param value Define the value to give to the uniform
  18183. * @return the material itself allowing "fluent" like uniform updates
  18184. */
  18185. setColor3(name: string, value: Color3): ShaderMaterial;
  18186. /**
  18187. * Set a vec3 array in the shader from a Color3 array.
  18188. * @param name Define the name of the uniform as defined in the shader
  18189. * @param value Define the value to give to the uniform
  18190. * @return the material itself allowing "fluent" like uniform updates
  18191. */
  18192. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18193. /**
  18194. * Set a vec4 in the shader from a Color4.
  18195. * @param name Define the name of the uniform as defined in the shader
  18196. * @param value Define the value to give to the uniform
  18197. * @return the material itself allowing "fluent" like uniform updates
  18198. */
  18199. setColor4(name: string, value: Color4): ShaderMaterial;
  18200. /**
  18201. * Set a vec2 in the shader from a Vector2.
  18202. * @param name Define the name of the uniform as defined in the shader
  18203. * @param value Define the value to give to the uniform
  18204. * @return the material itself allowing "fluent" like uniform updates
  18205. */
  18206. setVector2(name: string, value: Vector2): ShaderMaterial;
  18207. /**
  18208. * Set a vec3 in the shader from a Vector3.
  18209. * @param name Define the name of the uniform as defined in the shader
  18210. * @param value Define the value to give to the uniform
  18211. * @return the material itself allowing "fluent" like uniform updates
  18212. */
  18213. setVector3(name: string, value: Vector3): ShaderMaterial;
  18214. /**
  18215. * Set a vec4 in the shader from a Vector4.
  18216. * @param name Define the name of the uniform as defined in the shader
  18217. * @param value Define the value to give to the uniform
  18218. * @return the material itself allowing "fluent" like uniform updates
  18219. */
  18220. setVector4(name: string, value: Vector4): ShaderMaterial;
  18221. /**
  18222. * Set a mat4 in the shader from a Matrix.
  18223. * @param name Define the name of the uniform as defined in the shader
  18224. * @param value Define the value to give to the uniform
  18225. * @return the material itself allowing "fluent" like uniform updates
  18226. */
  18227. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18228. /**
  18229. * Set a mat3 in the shader from a Float32Array.
  18230. * @param name Define the name of the uniform as defined in the shader
  18231. * @param value Define the value to give to the uniform
  18232. * @return the material itself allowing "fluent" like uniform updates
  18233. */
  18234. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18235. /**
  18236. * Set a mat2 in the shader from a Float32Array.
  18237. * @param name Define the name of the uniform as defined in the shader
  18238. * @param value Define the value to give to the uniform
  18239. * @return the material itself allowing "fluent" like uniform updates
  18240. */
  18241. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18242. /**
  18243. * Set a vec2 array in the shader from a number array.
  18244. * @param name Define the name of the uniform as defined in the shader
  18245. * @param value Define the value to give to the uniform
  18246. * @return the material itself allowing "fluent" like uniform updates
  18247. */
  18248. setArray2(name: string, value: number[]): ShaderMaterial;
  18249. /**
  18250. * Set a vec3 array in the shader from a number array.
  18251. * @param name Define the name of the uniform as defined in the shader
  18252. * @param value Define the value to give to the uniform
  18253. * @return the material itself allowing "fluent" like uniform updates
  18254. */
  18255. setArray3(name: string, value: number[]): ShaderMaterial;
  18256. private _checkCache;
  18257. /**
  18258. * Checks if the material is ready to render the requested mesh
  18259. * @param mesh Define the mesh to render
  18260. * @param useInstances Define whether or not the material is used with instances
  18261. * @returns true if ready, otherwise false
  18262. */
  18263. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18264. /**
  18265. * Binds the world matrix to the material
  18266. * @param world defines the world transformation matrix
  18267. */
  18268. bindOnlyWorldMatrix(world: Matrix): void;
  18269. /**
  18270. * Binds the material to the mesh
  18271. * @param world defines the world transformation matrix
  18272. * @param mesh defines the mesh to bind the material to
  18273. */
  18274. bind(world: Matrix, mesh?: Mesh): void;
  18275. /**
  18276. * Gets the active textures from the material
  18277. * @returns an array of textures
  18278. */
  18279. getActiveTextures(): BaseTexture[];
  18280. /**
  18281. * Specifies if the material uses a texture
  18282. * @param texture defines the texture to check against the material
  18283. * @returns a boolean specifying if the material uses the texture
  18284. */
  18285. hasTexture(texture: BaseTexture): boolean;
  18286. /**
  18287. * Makes a duplicate of the material, and gives it a new name
  18288. * @param name defines the new name for the duplicated material
  18289. * @returns the cloned material
  18290. */
  18291. clone(name: string): ShaderMaterial;
  18292. /**
  18293. * Disposes the material
  18294. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18295. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18296. */
  18297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18298. /**
  18299. * Serializes this material in a JSON representation
  18300. * @returns the serialized material object
  18301. */
  18302. serialize(): any;
  18303. /**
  18304. * Creates a shader material from parsed shader material data
  18305. * @param source defines the JSON represnetation of the material
  18306. * @param scene defines the hosting scene
  18307. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18308. * @returns a new material
  18309. */
  18310. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18311. }
  18312. }
  18313. declare module BABYLON {
  18314. /** @hidden */
  18315. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18316. MAINUV1: boolean;
  18317. MAINUV2: boolean;
  18318. DIFFUSE: boolean;
  18319. DIFFUSEDIRECTUV: number;
  18320. AMBIENT: boolean;
  18321. AMBIENTDIRECTUV: number;
  18322. OPACITY: boolean;
  18323. OPACITYDIRECTUV: number;
  18324. OPACITYRGB: boolean;
  18325. REFLECTION: boolean;
  18326. EMISSIVE: boolean;
  18327. EMISSIVEDIRECTUV: number;
  18328. SPECULAR: boolean;
  18329. SPECULARDIRECTUV: number;
  18330. BUMP: boolean;
  18331. BUMPDIRECTUV: number;
  18332. PARALLAX: boolean;
  18333. PARALLAXOCCLUSION: boolean;
  18334. SPECULAROVERALPHA: boolean;
  18335. CLIPPLANE: boolean;
  18336. CLIPPLANE2: boolean;
  18337. CLIPPLANE3: boolean;
  18338. CLIPPLANE4: boolean;
  18339. ALPHATEST: boolean;
  18340. DEPTHPREPASS: boolean;
  18341. ALPHAFROMDIFFUSE: boolean;
  18342. POINTSIZE: boolean;
  18343. FOG: boolean;
  18344. SPECULARTERM: boolean;
  18345. DIFFUSEFRESNEL: boolean;
  18346. OPACITYFRESNEL: boolean;
  18347. REFLECTIONFRESNEL: boolean;
  18348. REFRACTIONFRESNEL: boolean;
  18349. EMISSIVEFRESNEL: boolean;
  18350. FRESNEL: boolean;
  18351. NORMAL: boolean;
  18352. UV1: boolean;
  18353. UV2: boolean;
  18354. VERTEXCOLOR: boolean;
  18355. VERTEXALPHA: boolean;
  18356. NUM_BONE_INFLUENCERS: number;
  18357. BonesPerMesh: number;
  18358. INSTANCES: boolean;
  18359. GLOSSINESS: boolean;
  18360. ROUGHNESS: boolean;
  18361. EMISSIVEASILLUMINATION: boolean;
  18362. LINKEMISSIVEWITHDIFFUSE: boolean;
  18363. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18364. LIGHTMAP: boolean;
  18365. LIGHTMAPDIRECTUV: number;
  18366. OBJECTSPACE_NORMALMAP: boolean;
  18367. USELIGHTMAPASSHADOWMAP: boolean;
  18368. REFLECTIONMAP_3D: boolean;
  18369. REFLECTIONMAP_SPHERICAL: boolean;
  18370. REFLECTIONMAP_PLANAR: boolean;
  18371. REFLECTIONMAP_CUBIC: boolean;
  18372. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18373. REFLECTIONMAP_PROJECTION: boolean;
  18374. REFLECTIONMAP_SKYBOX: boolean;
  18375. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  18376. REFLECTIONMAP_EXPLICIT: boolean;
  18377. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18378. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18379. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18380. INVERTCUBICMAP: boolean;
  18381. LOGARITHMICDEPTH: boolean;
  18382. REFRACTION: boolean;
  18383. REFRACTIONMAP_3D: boolean;
  18384. REFLECTIONOVERALPHA: boolean;
  18385. TWOSIDEDLIGHTING: boolean;
  18386. SHADOWFLOAT: boolean;
  18387. MORPHTARGETS: boolean;
  18388. MORPHTARGETS_NORMAL: boolean;
  18389. MORPHTARGETS_TANGENT: boolean;
  18390. NUM_MORPH_INFLUENCERS: number;
  18391. NONUNIFORMSCALING: boolean;
  18392. PREMULTIPLYALPHA: boolean;
  18393. IMAGEPROCESSING: boolean;
  18394. VIGNETTE: boolean;
  18395. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18396. VIGNETTEBLENDMODEOPAQUE: boolean;
  18397. TONEMAPPING: boolean;
  18398. TONEMAPPING_ACES: boolean;
  18399. CONTRAST: boolean;
  18400. COLORCURVES: boolean;
  18401. COLORGRADING: boolean;
  18402. COLORGRADING3D: boolean;
  18403. SAMPLER3DGREENDEPTH: boolean;
  18404. SAMPLER3DBGRMAP: boolean;
  18405. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18406. /**
  18407. * If the reflection texture on this material is in linear color space
  18408. * @hidden
  18409. */
  18410. IS_REFLECTION_LINEAR: boolean;
  18411. /**
  18412. * If the refraction texture on this material is in linear color space
  18413. * @hidden
  18414. */
  18415. IS_REFRACTION_LINEAR: boolean;
  18416. EXPOSURE: boolean;
  18417. constructor();
  18418. setReflectionMode(modeToEnable: string): void;
  18419. }
  18420. /**
  18421. * This is the default material used in Babylon. It is the best trade off between quality
  18422. * and performances.
  18423. * @see http://doc.babylonjs.com/babylon101/materials
  18424. */
  18425. class StandardMaterial extends PushMaterial {
  18426. private _diffuseTexture;
  18427. /**
  18428. * The basic texture of the material as viewed under a light.
  18429. */
  18430. diffuseTexture: Nullable<BaseTexture>;
  18431. private _ambientTexture;
  18432. /**
  18433. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18434. */
  18435. ambientTexture: Nullable<BaseTexture>;
  18436. private _opacityTexture;
  18437. /**
  18438. * Define the transparency of the material from a texture.
  18439. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18440. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18441. */
  18442. opacityTexture: Nullable<BaseTexture>;
  18443. private _reflectionTexture;
  18444. /**
  18445. * Define the texture used to display the reflection.
  18446. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18447. */
  18448. reflectionTexture: Nullable<BaseTexture>;
  18449. private _emissiveTexture;
  18450. /**
  18451. * Define texture of the material as if self lit.
  18452. * This will be mixed in the final result even in the absence of light.
  18453. */
  18454. emissiveTexture: Nullable<BaseTexture>;
  18455. private _specularTexture;
  18456. /**
  18457. * Define how the color and intensity of the highlight given by the light in the material.
  18458. */
  18459. specularTexture: Nullable<BaseTexture>;
  18460. private _bumpTexture;
  18461. /**
  18462. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18463. * 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.
  18464. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  18465. */
  18466. bumpTexture: Nullable<BaseTexture>;
  18467. private _lightmapTexture;
  18468. /**
  18469. * Complex lighting can be computationally expensive to compute at runtime.
  18470. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18471. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  18472. */
  18473. lightmapTexture: Nullable<BaseTexture>;
  18474. private _refractionTexture;
  18475. /**
  18476. * Define the texture used to display the refraction.
  18477. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18478. */
  18479. refractionTexture: Nullable<BaseTexture>;
  18480. /**
  18481. * The color of the material lit by the environmental background lighting.
  18482. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18483. */
  18484. ambientColor: Color3;
  18485. /**
  18486. * The basic color of the material as viewed under a light.
  18487. */
  18488. diffuseColor: Color3;
  18489. /**
  18490. * Define how the color and intensity of the highlight given by the light in the material.
  18491. */
  18492. specularColor: Color3;
  18493. /**
  18494. * Define the color of the material as if self lit.
  18495. * This will be mixed in the final result even in the absence of light.
  18496. */
  18497. emissiveColor: Color3;
  18498. /**
  18499. * Defines how sharp are the highlights in the material.
  18500. * The bigger the value the sharper giving a more glossy feeling to the result.
  18501. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18502. */
  18503. specularPower: number;
  18504. private _useAlphaFromDiffuseTexture;
  18505. /**
  18506. * Does the transparency come from the diffuse texture alpha channel.
  18507. */
  18508. useAlphaFromDiffuseTexture: boolean;
  18509. private _useEmissiveAsIllumination;
  18510. /**
  18511. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18512. */
  18513. useEmissiveAsIllumination: boolean;
  18514. private _linkEmissiveWithDiffuse;
  18515. /**
  18516. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18517. * the emissive level when the final color is close to one.
  18518. */
  18519. linkEmissiveWithDiffuse: boolean;
  18520. private _useSpecularOverAlpha;
  18521. /**
  18522. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18523. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18524. */
  18525. useSpecularOverAlpha: boolean;
  18526. private _useReflectionOverAlpha;
  18527. /**
  18528. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18529. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18530. */
  18531. useReflectionOverAlpha: boolean;
  18532. private _disableLighting;
  18533. /**
  18534. * Does lights from the scene impacts this material.
  18535. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18536. */
  18537. disableLighting: boolean;
  18538. private _useObjectSpaceNormalMap;
  18539. /**
  18540. * Allows using an object space normal map (instead of tangent space).
  18541. */
  18542. useObjectSpaceNormalMap: boolean;
  18543. private _useParallax;
  18544. /**
  18545. * Is parallax enabled or not.
  18546. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  18547. */
  18548. useParallax: boolean;
  18549. private _useParallaxOcclusion;
  18550. /**
  18551. * Is parallax occlusion enabled or not.
  18552. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18553. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  18554. */
  18555. useParallaxOcclusion: boolean;
  18556. /**
  18557. * 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.
  18558. */
  18559. parallaxScaleBias: number;
  18560. private _roughness;
  18561. /**
  18562. * Helps to define how blurry the reflections should appears in the material.
  18563. */
  18564. roughness: number;
  18565. /**
  18566. * In case of refraction, define the value of the indice of refraction.
  18567. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18568. */
  18569. indexOfRefraction: number;
  18570. /**
  18571. * Invert the refraction texture alongside the y axis.
  18572. * It can be usefull with procedural textures or probe for instance.
  18573. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18574. */
  18575. invertRefractionY: boolean;
  18576. /**
  18577. * Defines the alpha limits in alpha test mode.
  18578. */
  18579. alphaCutOff: number;
  18580. private _useLightmapAsShadowmap;
  18581. /**
  18582. * In case of light mapping, define whether the map contains light or shadow informations.
  18583. */
  18584. useLightmapAsShadowmap: boolean;
  18585. private _diffuseFresnelParameters;
  18586. /**
  18587. * Define the diffuse fresnel parameters of the material.
  18588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18589. */
  18590. diffuseFresnelParameters: FresnelParameters;
  18591. private _opacityFresnelParameters;
  18592. /**
  18593. * Define the opacity fresnel parameters of the material.
  18594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18595. */
  18596. opacityFresnelParameters: FresnelParameters;
  18597. private _reflectionFresnelParameters;
  18598. /**
  18599. * Define the reflection fresnel parameters of the material.
  18600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18601. */
  18602. reflectionFresnelParameters: FresnelParameters;
  18603. private _refractionFresnelParameters;
  18604. /**
  18605. * Define the refraction fresnel parameters of the material.
  18606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18607. */
  18608. refractionFresnelParameters: FresnelParameters;
  18609. private _emissiveFresnelParameters;
  18610. /**
  18611. * Define the emissive fresnel parameters of the material.
  18612. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18613. */
  18614. emissiveFresnelParameters: FresnelParameters;
  18615. private _useReflectionFresnelFromSpecular;
  18616. /**
  18617. * If true automatically deducts the fresnels values from the material specularity.
  18618. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18619. */
  18620. useReflectionFresnelFromSpecular: boolean;
  18621. private _useGlossinessFromSpecularMapAlpha;
  18622. /**
  18623. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18624. */
  18625. useGlossinessFromSpecularMapAlpha: boolean;
  18626. private _maxSimultaneousLights;
  18627. /**
  18628. * Defines the maximum number of lights that can be used in the material
  18629. */
  18630. maxSimultaneousLights: number;
  18631. private _invertNormalMapX;
  18632. /**
  18633. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18634. */
  18635. invertNormalMapX: boolean;
  18636. private _invertNormalMapY;
  18637. /**
  18638. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18639. */
  18640. invertNormalMapY: boolean;
  18641. private _twoSidedLighting;
  18642. /**
  18643. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18644. */
  18645. twoSidedLighting: boolean;
  18646. /**
  18647. * Default configuration related to image processing available in the standard Material.
  18648. */
  18649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18650. /**
  18651. * Gets the image processing configuration used either in this material.
  18652. */
  18653. /**
  18654. * Sets the Default image processing configuration used either in the this material.
  18655. *
  18656. * If sets to null, the scene one is in use.
  18657. */
  18658. imageProcessingConfiguration: ImageProcessingConfiguration;
  18659. /**
  18660. * Keep track of the image processing observer to allow dispose and replace.
  18661. */
  18662. private _imageProcessingObserver;
  18663. /**
  18664. * Attaches a new image processing configuration to the Standard Material.
  18665. * @param configuration
  18666. */
  18667. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18668. /**
  18669. * Gets wether the color curves effect is enabled.
  18670. */
  18671. /**
  18672. * Sets wether the color curves effect is enabled.
  18673. */
  18674. cameraColorCurvesEnabled: boolean;
  18675. /**
  18676. * Gets wether the color grading effect is enabled.
  18677. */
  18678. /**
  18679. * Gets wether the color grading effect is enabled.
  18680. */
  18681. cameraColorGradingEnabled: boolean;
  18682. /**
  18683. * Gets wether tonemapping is enabled or not.
  18684. */
  18685. /**
  18686. * Sets wether tonemapping is enabled or not
  18687. */
  18688. cameraToneMappingEnabled: boolean;
  18689. /**
  18690. * The camera exposure used on this material.
  18691. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18692. * This corresponds to a photographic exposure.
  18693. */
  18694. /**
  18695. * The camera exposure used on this material.
  18696. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  18697. * This corresponds to a photographic exposure.
  18698. */
  18699. cameraExposure: number;
  18700. /**
  18701. * Gets The camera contrast used on this material.
  18702. */
  18703. /**
  18704. * Sets The camera contrast used on this material.
  18705. */
  18706. cameraContrast: number;
  18707. /**
  18708. * Gets the Color Grading 2D Lookup Texture.
  18709. */
  18710. /**
  18711. * Sets the Color Grading 2D Lookup Texture.
  18712. */
  18713. cameraColorGradingTexture: Nullable<BaseTexture>;
  18714. /**
  18715. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18716. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18717. * 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;
  18718. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18719. */
  18720. /**
  18721. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  18722. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  18723. * 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;
  18724. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  18725. */
  18726. cameraColorCurves: Nullable<ColorCurves>;
  18727. /**
  18728. * Custom callback helping to override the default shader used in the material.
  18729. */
  18730. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  18731. protected _renderTargets: SmartArray<RenderTargetTexture>;
  18732. protected _worldViewProjectionMatrix: Matrix;
  18733. protected _globalAmbientColor: Color3;
  18734. protected _useLogarithmicDepth: boolean;
  18735. /**
  18736. * Instantiates a new standard material.
  18737. * This is the default material used in Babylon. It is the best trade off between quality
  18738. * and performances.
  18739. * @see http://doc.babylonjs.com/babylon101/materials
  18740. * @param name Define the name of the material in the scene
  18741. * @param scene Define the scene the material belong to
  18742. */
  18743. constructor(name: string, scene: Scene);
  18744. /**
  18745. * Gets a boolean indicating that current material needs to register RTT
  18746. */
  18747. readonly hasRenderTargetTextures: boolean;
  18748. /**
  18749. * Gets the current class name of the material e.g. "StandardMaterial"
  18750. * Mainly use in serialization.
  18751. * @returns the class name
  18752. */
  18753. getClassName(): string;
  18754. /**
  18755. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  18756. * You can try switching to logarithmic depth.
  18757. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  18758. */
  18759. useLogarithmicDepth: boolean;
  18760. /**
  18761. * Specifies if the material will require alpha blending
  18762. * @returns a boolean specifying if alpha blending is needed
  18763. */
  18764. needAlphaBlending(): boolean;
  18765. /**
  18766. * Specifies if this material should be rendered in alpha test mode
  18767. * @returns a boolean specifying if an alpha test is needed.
  18768. */
  18769. needAlphaTesting(): boolean;
  18770. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  18771. /**
  18772. * Get the texture used for alpha test purpose.
  18773. * @returns the diffuse texture in case of the standard material.
  18774. */
  18775. getAlphaTestTexture(): Nullable<BaseTexture>;
  18776. /**
  18777. * Get if the submesh is ready to be used and all its information available.
  18778. * Child classes can use it to update shaders
  18779. * @param mesh defines the mesh to check
  18780. * @param subMesh defines which submesh to check
  18781. * @param useInstances specifies that instances should be used
  18782. * @returns a boolean indicating that the submesh is ready or not
  18783. */
  18784. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18785. /**
  18786. * Builds the material UBO layouts.
  18787. * Used internally during the effect preparation.
  18788. */
  18789. buildUniformLayout(): void;
  18790. /**
  18791. * Unbinds the material from the mesh
  18792. */
  18793. unbind(): void;
  18794. /**
  18795. * Binds the submesh to this material by preparing the effect and shader to draw
  18796. * @param world defines the world transformation matrix
  18797. * @param mesh defines the mesh containing the submesh
  18798. * @param subMesh defines the submesh to bind the material to
  18799. */
  18800. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18801. /**
  18802. * Get the list of animatables in the material.
  18803. * @returns the list of animatables object used in the material
  18804. */
  18805. getAnimatables(): IAnimatable[];
  18806. /**
  18807. * Gets the active textures from the material
  18808. * @returns an array of textures
  18809. */
  18810. getActiveTextures(): BaseTexture[];
  18811. /**
  18812. * Specifies if the material uses a texture
  18813. * @param texture defines the texture to check against the material
  18814. * @returns a boolean specifying if the material uses the texture
  18815. */
  18816. hasTexture(texture: BaseTexture): boolean;
  18817. /**
  18818. * Disposes the material
  18819. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18820. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18821. */
  18822. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18823. /**
  18824. * Makes a duplicate of the material, and gives it a new name
  18825. * @param name defines the new name for the duplicated material
  18826. * @returns the cloned material
  18827. */
  18828. clone(name: string): StandardMaterial;
  18829. /**
  18830. * Serializes this material in a JSON representation
  18831. * @returns the serialized material object
  18832. */
  18833. serialize(): any;
  18834. /**
  18835. * Creates a standard material from parsed material data
  18836. * @param source defines the JSON represnetation of the material
  18837. * @param scene defines the hosting scene
  18838. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18839. * @returns a new material
  18840. */
  18841. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  18842. private static _DiffuseTextureEnabled;
  18843. /**
  18844. * Are diffuse textures enabled in the application.
  18845. */
  18846. static DiffuseTextureEnabled: boolean;
  18847. private static _AmbientTextureEnabled;
  18848. /**
  18849. * Are ambient textures enabled in the application.
  18850. */
  18851. static AmbientTextureEnabled: boolean;
  18852. private static _OpacityTextureEnabled;
  18853. /**
  18854. * Are opacity textures enabled in the application.
  18855. */
  18856. static OpacityTextureEnabled: boolean;
  18857. private static _ReflectionTextureEnabled;
  18858. /**
  18859. * Are reflection textures enabled in the application.
  18860. */
  18861. static ReflectionTextureEnabled: boolean;
  18862. private static _EmissiveTextureEnabled;
  18863. /**
  18864. * Are emissive textures enabled in the application.
  18865. */
  18866. static EmissiveTextureEnabled: boolean;
  18867. private static _SpecularTextureEnabled;
  18868. /**
  18869. * Are specular textures enabled in the application.
  18870. */
  18871. static SpecularTextureEnabled: boolean;
  18872. private static _BumpTextureEnabled;
  18873. /**
  18874. * Are bump textures enabled in the application.
  18875. */
  18876. static BumpTextureEnabled: boolean;
  18877. private static _LightmapTextureEnabled;
  18878. /**
  18879. * Are lightmap textures enabled in the application.
  18880. */
  18881. static LightmapTextureEnabled: boolean;
  18882. private static _RefractionTextureEnabled;
  18883. /**
  18884. * Are refraction textures enabled in the application.
  18885. */
  18886. static RefractionTextureEnabled: boolean;
  18887. private static _ColorGradingTextureEnabled;
  18888. /**
  18889. * Are color grading textures enabled in the application.
  18890. */
  18891. static ColorGradingTextureEnabled: boolean;
  18892. private static _FresnelEnabled;
  18893. /**
  18894. * Are fresnels enabled in the application.
  18895. */
  18896. static FresnelEnabled: boolean;
  18897. }
  18898. }
  18899. declare module BABYLON {
  18900. /**
  18901. * Uniform buffer objects.
  18902. *
  18903. * Handles blocks of uniform on the GPU.
  18904. *
  18905. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  18906. *
  18907. * For more information, please refer to :
  18908. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  18909. */
  18910. class UniformBuffer {
  18911. private _engine;
  18912. private _buffer;
  18913. private _data;
  18914. private _bufferData;
  18915. private _dynamic?;
  18916. private _uniformLocations;
  18917. private _uniformSizes;
  18918. private _uniformLocationPointer;
  18919. private _needSync;
  18920. private _noUBO;
  18921. private _currentEffect;
  18922. private static _MAX_UNIFORM_SIZE;
  18923. private static _tempBuffer;
  18924. /**
  18925. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  18926. * This is dynamic to allow compat with webgl 1 and 2.
  18927. * You will need to pass the name of the uniform as well as the value.
  18928. */
  18929. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  18930. /**
  18931. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  18932. * This is dynamic to allow compat with webgl 1 and 2.
  18933. * You will need to pass the name of the uniform as well as the value.
  18934. */
  18935. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  18936. /**
  18937. * Lambda to Update a single float in a uniform buffer.
  18938. * This is dynamic to allow compat with webgl 1 and 2.
  18939. * You will need to pass the name of the uniform as well as the value.
  18940. */
  18941. updateFloat: (name: string, x: number) => void;
  18942. /**
  18943. * Lambda to Update a vec2 of float in a uniform buffer.
  18944. * This is dynamic to allow compat with webgl 1 and 2.
  18945. * You will need to pass the name of the uniform as well as the value.
  18946. */
  18947. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  18948. /**
  18949. * Lambda to Update a vec3 of float in a uniform buffer.
  18950. * This is dynamic to allow compat with webgl 1 and 2.
  18951. * You will need to pass the name of the uniform as well as the value.
  18952. */
  18953. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  18954. /**
  18955. * Lambda to Update a vec4 of float in a uniform buffer.
  18956. * This is dynamic to allow compat with webgl 1 and 2.
  18957. * You will need to pass the name of the uniform as well as the value.
  18958. */
  18959. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  18960. /**
  18961. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  18962. * This is dynamic to allow compat with webgl 1 and 2.
  18963. * You will need to pass the name of the uniform as well as the value.
  18964. */
  18965. updateMatrix: (name: string, mat: Matrix) => void;
  18966. /**
  18967. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  18968. * This is dynamic to allow compat with webgl 1 and 2.
  18969. * You will need to pass the name of the uniform as well as the value.
  18970. */
  18971. updateVector3: (name: string, vector: Vector3) => void;
  18972. /**
  18973. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  18974. * This is dynamic to allow compat with webgl 1 and 2.
  18975. * You will need to pass the name of the uniform as well as the value.
  18976. */
  18977. updateVector4: (name: string, vector: Vector4) => void;
  18978. /**
  18979. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  18980. * This is dynamic to allow compat with webgl 1 and 2.
  18981. * You will need to pass the name of the uniform as well as the value.
  18982. */
  18983. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  18984. /**
  18985. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  18986. * This is dynamic to allow compat with webgl 1 and 2.
  18987. * You will need to pass the name of the uniform as well as the value.
  18988. */
  18989. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  18990. /**
  18991. * Instantiates a new Uniform buffer objects.
  18992. *
  18993. * Handles blocks of uniform on the GPU.
  18994. *
  18995. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  18996. *
  18997. * For more information, please refer to :
  18998. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  18999. * @param engine Define the engine the buffer is associated with
  19000. * @param data Define the data contained in the buffer
  19001. * @param dynamic Define if the buffer is updatable
  19002. */
  19003. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19004. /**
  19005. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19006. * or just falling back on setUniformXXX calls.
  19007. */
  19008. readonly useUbo: boolean;
  19009. /**
  19010. * Indicates if the WebGL underlying uniform buffer is in sync
  19011. * with the javascript cache data.
  19012. */
  19013. readonly isSync: boolean;
  19014. /**
  19015. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19016. * Also, a dynamic UniformBuffer will disable cache verification and always
  19017. * update the underlying WebGL uniform buffer to the GPU.
  19018. * @returns if Dynamic, otherwise false
  19019. */
  19020. isDynamic(): boolean;
  19021. /**
  19022. * The data cache on JS side.
  19023. * @returns the underlying data as a float array
  19024. */
  19025. getData(): Float32Array;
  19026. /**
  19027. * The underlying WebGL Uniform buffer.
  19028. * @returns the webgl buffer
  19029. */
  19030. getBuffer(): Nullable<WebGLBuffer>;
  19031. /**
  19032. * std140 layout specifies how to align data within an UBO structure.
  19033. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19034. * for specs.
  19035. */
  19036. private _fillAlignment;
  19037. /**
  19038. * Adds an uniform in the buffer.
  19039. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19040. * for the layout to be correct !
  19041. * @param name Name of the uniform, as used in the uniform block in the shader.
  19042. * @param size Data size, or data directly.
  19043. */
  19044. addUniform(name: string, size: number | number[]): void;
  19045. /**
  19046. * Adds a Matrix 4x4 to the uniform buffer.
  19047. * @param name Name of the uniform, as used in the uniform block in the shader.
  19048. * @param mat A 4x4 matrix.
  19049. */
  19050. addMatrix(name: string, mat: Matrix): void;
  19051. /**
  19052. * Adds a vec2 to the uniform buffer.
  19053. * @param name Name of the uniform, as used in the uniform block in the shader.
  19054. * @param x Define the x component value of the vec2
  19055. * @param y Define the y component value of the vec2
  19056. */
  19057. addFloat2(name: string, x: number, y: number): void;
  19058. /**
  19059. * Adds a vec3 to the uniform buffer.
  19060. * @param name Name of the uniform, as used in the uniform block in the shader.
  19061. * @param x Define the x component value of the vec3
  19062. * @param y Define the y component value of the vec3
  19063. * @param z Define the z component value of the vec3
  19064. */
  19065. addFloat3(name: string, x: number, y: number, z: number): void;
  19066. /**
  19067. * Adds a vec3 to the uniform buffer.
  19068. * @param name Name of the uniform, as used in the uniform block in the shader.
  19069. * @param color Define the vec3 from a Color
  19070. */
  19071. addColor3(name: string, color: Color3): void;
  19072. /**
  19073. * Adds a vec4 to the uniform buffer.
  19074. * @param name Name of the uniform, as used in the uniform block in the shader.
  19075. * @param color Define the rgb components from a Color
  19076. * @param alpha Define the a component of the vec4
  19077. */
  19078. addColor4(name: string, color: Color3, alpha: number): void;
  19079. /**
  19080. * Adds a vec3 to the uniform buffer.
  19081. * @param name Name of the uniform, as used in the uniform block in the shader.
  19082. * @param vector Define the vec3 components from a Vector
  19083. */
  19084. addVector3(name: string, vector: Vector3): void;
  19085. /**
  19086. * Adds a Matrix 3x3 to the uniform buffer.
  19087. * @param name Name of the uniform, as used in the uniform block in the shader.
  19088. */
  19089. addMatrix3x3(name: string): void;
  19090. /**
  19091. * Adds a Matrix 2x2 to the uniform buffer.
  19092. * @param name Name of the uniform, as used in the uniform block in the shader.
  19093. */
  19094. addMatrix2x2(name: string): void;
  19095. /**
  19096. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19097. */
  19098. create(): void;
  19099. /** @hidden */
  19100. _rebuild(): void;
  19101. /**
  19102. * Updates the WebGL Uniform Buffer on the GPU.
  19103. * If the `dynamic` flag is set to true, no cache comparison is done.
  19104. * Otherwise, the buffer will be updated only if the cache differs.
  19105. */
  19106. update(): void;
  19107. /**
  19108. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19109. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19110. * @param data Define the flattened data
  19111. * @param size Define the size of the data.
  19112. */
  19113. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19114. private _updateMatrix3x3ForUniform;
  19115. private _updateMatrix3x3ForEffect;
  19116. private _updateMatrix2x2ForEffect;
  19117. private _updateMatrix2x2ForUniform;
  19118. private _updateFloatForEffect;
  19119. private _updateFloatForUniform;
  19120. private _updateFloat2ForEffect;
  19121. private _updateFloat2ForUniform;
  19122. private _updateFloat3ForEffect;
  19123. private _updateFloat3ForUniform;
  19124. private _updateFloat4ForEffect;
  19125. private _updateFloat4ForUniform;
  19126. private _updateMatrixForEffect;
  19127. private _updateMatrixForUniform;
  19128. private _updateVector3ForEffect;
  19129. private _updateVector3ForUniform;
  19130. private _updateVector4ForEffect;
  19131. private _updateVector4ForUniform;
  19132. private _updateColor3ForEffect;
  19133. private _updateColor3ForUniform;
  19134. private _updateColor4ForEffect;
  19135. private _updateColor4ForUniform;
  19136. /**
  19137. * Sets a sampler uniform on the effect.
  19138. * @param name Define the name of the sampler.
  19139. * @param texture Define the texture to set in the sampler
  19140. */
  19141. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19142. /**
  19143. * Directly updates the value of the uniform in the cache AND on the GPU.
  19144. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19145. * @param data Define the flattened data
  19146. */
  19147. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19148. /**
  19149. * Binds this uniform buffer to an effect.
  19150. * @param effect Define the effect to bind the buffer to
  19151. * @param name Name of the uniform block in the shader.
  19152. */
  19153. bindToEffect(effect: Effect, name: string): void;
  19154. /**
  19155. * Disposes the uniform buffer.
  19156. */
  19157. dispose(): void;
  19158. }
  19159. }
  19160. declare module BABYLON {
  19161. class Scalar {
  19162. /**
  19163. * Two pi constants convenient for computation.
  19164. */
  19165. static TwoPi: number;
  19166. /**
  19167. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19168. */
  19169. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19170. /**
  19171. * Returns a string : the upper case translation of the number i to hexadecimal.
  19172. */
  19173. static ToHex(i: number): string;
  19174. /**
  19175. * Returns -1 if value is negative and +1 is value is positive.
  19176. * Returns the value itself if it's equal to zero.
  19177. */
  19178. static Sign(value: number): number;
  19179. /**
  19180. * Returns the value itself if it's between min and max.
  19181. * Returns min if the value is lower than min.
  19182. * Returns max if the value is greater than max.
  19183. */
  19184. static Clamp(value: number, min?: number, max?: number): number;
  19185. /**
  19186. * Returns the log2 of value.
  19187. */
  19188. static Log2(value: number): number;
  19189. /**
  19190. * Loops the value, so that it is never larger than length and never smaller than 0.
  19191. *
  19192. * This is similar to the modulo operator but it works with floating point numbers.
  19193. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19194. * With t = 5 and length = 2.5, the result would be 0.0.
  19195. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19196. */
  19197. static Repeat(value: number, length: number): number;
  19198. /**
  19199. * Normalize the value between 0.0 and 1.0 using min and max values
  19200. */
  19201. static Normalize(value: number, min: number, max: number): number;
  19202. /**
  19203. * Denormalize the value from 0.0 and 1.0 using min and max values
  19204. */
  19205. static Denormalize(normalized: number, min: number, max: number): number;
  19206. /**
  19207. * Calculates the shortest difference between two given angles given in degrees.
  19208. */
  19209. static DeltaAngle(current: number, target: number): number;
  19210. /**
  19211. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19212. *
  19213. * The returned value will move back and forth between 0 and length
  19214. */
  19215. static PingPong(tx: number, length: number): number;
  19216. /**
  19217. * Interpolates between min and max with smoothing at the limits.
  19218. *
  19219. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19220. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19221. */
  19222. static SmoothStep(from: number, to: number, tx: number): number;
  19223. /**
  19224. * Moves a value current towards target.
  19225. *
  19226. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19227. * Negative values of maxDelta pushes the value away from target.
  19228. */
  19229. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19230. /**
  19231. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19232. *
  19233. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19234. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19235. */
  19236. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19237. /**
  19238. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19239. */
  19240. static Lerp(start: number, end: number, amount: number): number;
  19241. /**
  19242. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19243. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19244. */
  19245. static LerpAngle(start: number, end: number, amount: number): number;
  19246. /**
  19247. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19248. */
  19249. static InverseLerp(a: number, b: number, value: number): number;
  19250. /**
  19251. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19252. */
  19253. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19254. /**
  19255. * Returns a random float number between and min and max values
  19256. */
  19257. static RandomRange(min: number, max: number): number;
  19258. /**
  19259. * This function returns percentage of a number in a given range.
  19260. *
  19261. * RangeToPercent(40,20,60) will return 0.5 (50%)
  19262. * RangeToPercent(34,0,100) will return 0.34 (34%)
  19263. */
  19264. static RangeToPercent(number: number, min: number, max: number): number;
  19265. /**
  19266. * This function returns number that corresponds to the percentage in a given range.
  19267. *
  19268. * PercentToRange(0.34,0,100) will return 34.
  19269. */
  19270. static PercentToRange(percent: number, min: number, max: number): number;
  19271. /**
  19272. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  19273. * @param angle The angle to normalize in radian.
  19274. * @return The converted angle.
  19275. */
  19276. static NormalizeRadians(angle: number): number;
  19277. }
  19278. }
  19279. declare module BABYLON {
  19280. /**
  19281. * Constant used to convert a value to gamma space
  19282. * @ignorenaming
  19283. */
  19284. const ToGammaSpace: number;
  19285. /**
  19286. * Constant used to convert a value to linear space
  19287. * @ignorenaming
  19288. */
  19289. const ToLinearSpace = 2.2;
  19290. /**
  19291. * Constant used to define the minimal number value in Babylon.js
  19292. * @ignorenaming
  19293. */
  19294. const Epsilon = 0.001;
  19295. /**
  19296. * Class used to hold a RBG color
  19297. */
  19298. class Color3 {
  19299. /**
  19300. * Defines the red component (between 0 and 1, default is 0)
  19301. */
  19302. r: number;
  19303. /**
  19304. * Defines the green component (between 0 and 1, default is 0)
  19305. */
  19306. g: number;
  19307. /**
  19308. * Defines the blue component (between 0 and 1, default is 0)
  19309. */
  19310. b: number;
  19311. /**
  19312. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  19313. * @param r defines the red component (between 0 and 1, default is 0)
  19314. * @param g defines the green component (between 0 and 1, default is 0)
  19315. * @param b defines the blue component (between 0 and 1, default is 0)
  19316. */
  19317. constructor(
  19318. /**
  19319. * Defines the red component (between 0 and 1, default is 0)
  19320. */
  19321. r?: number,
  19322. /**
  19323. * Defines the green component (between 0 and 1, default is 0)
  19324. */
  19325. g?: number,
  19326. /**
  19327. * Defines the blue component (between 0 and 1, default is 0)
  19328. */
  19329. b?: number);
  19330. /**
  19331. * Creates a string with the Color3 current values
  19332. * @returns the string representation of the Color3 object
  19333. */
  19334. toString(): string;
  19335. /**
  19336. * Returns the string "Color3"
  19337. * @returns "Color3"
  19338. */
  19339. getClassName(): string;
  19340. /**
  19341. * Compute the Color3 hash code
  19342. * @returns an unique number that can be used to hash Color3 objects
  19343. */
  19344. getHashCode(): number;
  19345. /**
  19346. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  19347. * @param array defines the array where to store the r,g,b components
  19348. * @param index defines an optional index in the target array to define where to start storing values
  19349. * @returns the current Color3 object
  19350. */
  19351. toArray(array: FloatArray, index?: number): Color3;
  19352. /**
  19353. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  19354. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  19355. * @returns a new {BABYLON.Color4} object
  19356. */
  19357. toColor4(alpha?: number): Color4;
  19358. /**
  19359. * Returns a new array populated with 3 numeric elements : red, green and blue values
  19360. * @returns the new array
  19361. */
  19362. asArray(): number[];
  19363. /**
  19364. * Returns the luminance value
  19365. * @returns a float value
  19366. */
  19367. toLuminance(): number;
  19368. /**
  19369. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  19370. * @param otherColor defines the second operand
  19371. * @returns the new Color3 object
  19372. */
  19373. multiply(otherColor: Color3): Color3;
  19374. /**
  19375. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  19376. * @param otherColor defines the second operand
  19377. * @param result defines the Color3 object where to store the result
  19378. * @returns the current Color3
  19379. */
  19380. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  19381. /**
  19382. * Determines equality between Color3 objects
  19383. * @param otherColor defines the second operand
  19384. * @returns true if the rgb values are equal to the given ones
  19385. */
  19386. equals(otherColor: Color3): boolean;
  19387. /**
  19388. * Determines equality between the current Color3 object and a set of r,b,g values
  19389. * @param r defines the red component to check
  19390. * @param g defines the green component to check
  19391. * @param b defines the blue component to check
  19392. * @returns true if the rgb values are equal to the given ones
  19393. */
  19394. equalsFloats(r: number, g: number, b: number): boolean;
  19395. /**
  19396. * Multiplies in place each rgb value by scale
  19397. * @param scale defines the scaling factor
  19398. * @returns the updated Color3
  19399. */
  19400. scale(scale: number): Color3;
  19401. /**
  19402. * Multiplies the rgb values by scale and stores the result into "result"
  19403. * @param scale defines the scaling factor
  19404. * @param result defines the Color3 object where to store the result
  19405. * @returns the unmodified current Color3
  19406. */
  19407. scaleToRef(scale: number, result: Color3): Color3;
  19408. /**
  19409. * Scale the current Color3 values by a factor and add the result to a given Color3
  19410. * @param scale defines the scale factor
  19411. * @param result defines color to store the result into
  19412. * @returns the unmodified current Color3
  19413. */
  19414. scaleAndAddToRef(scale: number, result: Color3): Color3;
  19415. /**
  19416. * Clamps the rgb values by the min and max values and stores the result into "result"
  19417. * @param min defines minimum clamping value (default is 0)
  19418. * @param max defines maximum clamping value (default is 1)
  19419. * @param result defines color to store the result into
  19420. * @returns the original Color3
  19421. */
  19422. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  19423. /**
  19424. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  19425. * @param otherColor defines the second operand
  19426. * @returns the new Color3
  19427. */
  19428. add(otherColor: Color3): Color3;
  19429. /**
  19430. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  19431. * @param otherColor defines the second operand
  19432. * @param result defines Color3 object to store the result into
  19433. * @returns the unmodified current Color3
  19434. */
  19435. addToRef(otherColor: Color3, result: Color3): Color3;
  19436. /**
  19437. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  19438. * @param otherColor defines the second operand
  19439. * @returns the new Color3
  19440. */
  19441. subtract(otherColor: Color3): Color3;
  19442. /**
  19443. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  19444. * @param otherColor defines the second operand
  19445. * @param result defines Color3 object to store the result into
  19446. * @returns the unmodified current Color3
  19447. */
  19448. subtractToRef(otherColor: Color3, result: Color3): Color3;
  19449. /**
  19450. * Copy the current object
  19451. * @returns a new Color3 copied the current one
  19452. */
  19453. clone(): Color3;
  19454. /**
  19455. * Copies the rgb values from the source in the current Color3
  19456. * @param source defines the source Color3 object
  19457. * @returns the updated Color3 object
  19458. */
  19459. copyFrom(source: Color3): Color3;
  19460. /**
  19461. * Updates the Color3 rgb values from the given floats
  19462. * @param r defines the red component to read from
  19463. * @param g defines the green component to read from
  19464. * @param b defines the blue component to read from
  19465. * @returns the current Color3 object
  19466. */
  19467. copyFromFloats(r: number, g: number, b: number): Color3;
  19468. /**
  19469. * Updates the Color3 rgb values from the given floats
  19470. * @param r defines the red component to read from
  19471. * @param g defines the green component to read from
  19472. * @param b defines the blue component to read from
  19473. * @returns the current Color3 object
  19474. */
  19475. set(r: number, g: number, b: number): Color3;
  19476. /**
  19477. * Compute the Color3 hexadecimal code as a string
  19478. * @returns a string containing the hexadecimal representation of the Color3 object
  19479. */
  19480. toHexString(): string;
  19481. /**
  19482. * Computes a new Color3 converted from the current one to linear space
  19483. * @returns a new Color3 object
  19484. */
  19485. toLinearSpace(): Color3;
  19486. /**
  19487. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  19488. * @param convertedColor defines the Color3 object where to store the linear space version
  19489. * @returns the unmodified Color3
  19490. */
  19491. toLinearSpaceToRef(convertedColor: Color3): Color3;
  19492. /**
  19493. * Computes a new Color3 converted from the current one to gamma space
  19494. * @returns a new Color3 object
  19495. */
  19496. toGammaSpace(): Color3;
  19497. /**
  19498. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  19499. * @param convertedColor defines the Color3 object where to store the gamma space version
  19500. * @returns the unmodified Color3
  19501. */
  19502. toGammaSpaceToRef(convertedColor: Color3): Color3;
  19503. /**
  19504. * Creates a new Color3 from the string containing valid hexadecimal values
  19505. * @param hex defines a string containing valid hexadecimal values
  19506. * @returns a new Color3 object
  19507. */
  19508. static FromHexString(hex: string): Color3;
  19509. /**
  19510. * Creates a new Vector3 from the starting index of the given array
  19511. * @param array defines the source array
  19512. * @param offset defines an offset in the source array
  19513. * @returns a new Color3 object
  19514. */
  19515. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  19516. /**
  19517. * Creates a new Color3 from integer values (< 256)
  19518. * @param r defines the red component to read from (value between 0 and 255)
  19519. * @param g defines the green component to read from (value between 0 and 255)
  19520. * @param b defines the blue component to read from (value between 0 and 255)
  19521. * @returns a new Color3 object
  19522. */
  19523. static FromInts(r: number, g: number, b: number): Color3;
  19524. /**
  19525. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  19526. * @param start defines the start Color3 value
  19527. * @param end defines the end Color3 value
  19528. * @param amount defines the gradient value between start and end
  19529. * @returns a new Color3 object
  19530. */
  19531. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  19532. /**
  19533. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  19534. * @param left defines the start value
  19535. * @param right defines the end value
  19536. * @param amount defines the gradient factor
  19537. * @param result defines the Color3 object where to store the result
  19538. */
  19539. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  19540. /**
  19541. * Returns a Color3 value containing a red color
  19542. * @returns a new Color3 object
  19543. */
  19544. static Red(): Color3;
  19545. /**
  19546. * Returns a Color3 value containing a green color
  19547. * @returns a new Color3 object
  19548. */
  19549. static Green(): Color3;
  19550. /**
  19551. * Returns a Color3 value containing a blue color
  19552. * @returns a new Color3 object
  19553. */
  19554. static Blue(): Color3;
  19555. /**
  19556. * Returns a Color3 value containing a black color
  19557. * @returns a new Color3 object
  19558. */
  19559. static Black(): Color3;
  19560. /**
  19561. * Returns a Color3 value containing a white color
  19562. * @returns a new Color3 object
  19563. */
  19564. static White(): Color3;
  19565. /**
  19566. * Returns a Color3 value containing a purple color
  19567. * @returns a new Color3 object
  19568. */
  19569. static Purple(): Color3;
  19570. /**
  19571. * Returns a Color3 value containing a magenta color
  19572. * @returns a new Color3 object
  19573. */
  19574. static Magenta(): Color3;
  19575. /**
  19576. * Returns a Color3 value containing a yellow color
  19577. * @returns a new Color3 object
  19578. */
  19579. static Yellow(): Color3;
  19580. /**
  19581. * Returns a Color3 value containing a gray color
  19582. * @returns a new Color3 object
  19583. */
  19584. static Gray(): Color3;
  19585. /**
  19586. * Returns a Color3 value containing a teal color
  19587. * @returns a new Color3 object
  19588. */
  19589. static Teal(): Color3;
  19590. /**
  19591. * Returns a Color3 value containing a random color
  19592. * @returns a new Color3 object
  19593. */
  19594. static Random(): Color3;
  19595. }
  19596. /**
  19597. * Class used to hold a RBGA color
  19598. */
  19599. class Color4 {
  19600. /**
  19601. * Defines the red component (between 0 and 1, default is 0)
  19602. */
  19603. r: number;
  19604. /**
  19605. * Defines the green component (between 0 and 1, default is 0)
  19606. */
  19607. g: number;
  19608. /**
  19609. * Defines the blue component (between 0 and 1, default is 0)
  19610. */
  19611. b: number;
  19612. /**
  19613. * Defines the alpha component (between 0 and 1, default is 1)
  19614. */
  19615. a: number;
  19616. /**
  19617. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  19618. * @param r defines the red component (between 0 and 1, default is 0)
  19619. * @param g defines the green component (between 0 and 1, default is 0)
  19620. * @param b defines the blue component (between 0 and 1, default is 0)
  19621. * @param a defines the alpha component (between 0 and 1, default is 1)
  19622. */
  19623. constructor(
  19624. /**
  19625. * Defines the red component (between 0 and 1, default is 0)
  19626. */
  19627. r?: number,
  19628. /**
  19629. * Defines the green component (between 0 and 1, default is 0)
  19630. */
  19631. g?: number,
  19632. /**
  19633. * Defines the blue component (between 0 and 1, default is 0)
  19634. */
  19635. b?: number,
  19636. /**
  19637. * Defines the alpha component (between 0 and 1, default is 1)
  19638. */
  19639. a?: number);
  19640. /**
  19641. * Adds in place the given Color4 values to the current Color4 object
  19642. * @param right defines the second operand
  19643. * @returns the current updated Color4 object
  19644. */
  19645. addInPlace(right: Color4): Color4;
  19646. /**
  19647. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  19648. * @returns the new array
  19649. */
  19650. asArray(): number[];
  19651. /**
  19652. * Stores from the starting index in the given array the Color4 successive values
  19653. * @param array defines the array where to store the r,g,b components
  19654. * @param index defines an optional index in the target array to define where to start storing values
  19655. * @returns the current Color4 object
  19656. */
  19657. toArray(array: number[], index?: number): Color4;
  19658. /**
  19659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  19660. * @param right defines the second operand
  19661. * @returns a new Color4 object
  19662. */
  19663. add(right: Color4): Color4;
  19664. /**
  19665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  19666. * @param right defines the second operand
  19667. * @returns a new Color4 object
  19668. */
  19669. subtract(right: Color4): Color4;
  19670. /**
  19671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  19672. * @param right defines the second operand
  19673. * @param result defines the Color4 object where to store the result
  19674. * @returns the current Color4 object
  19675. */
  19676. subtractToRef(right: Color4, result: Color4): Color4;
  19677. /**
  19678. * Creates a new Color4 with the current Color4 values multiplied by scale
  19679. * @param scale defines the scaling factor to apply
  19680. * @returns a new Color4 object
  19681. */
  19682. scale(scale: number): Color4;
  19683. /**
  19684. * Multiplies the current Color4 values by scale and stores the result in "result"
  19685. * @param scale defines the scaling factor to apply
  19686. * @param result defines the Color4 object where to store the result
  19687. * @returns the current unmodified Color4
  19688. */
  19689. scaleToRef(scale: number, result: Color4): Color4;
  19690. /**
  19691. * Scale the current Color4 values by a factor and add the result to a given Color4
  19692. * @param scale defines the scale factor
  19693. * @param result defines the Color4 object where to store the result
  19694. * @returns the unmodified current Color4
  19695. */
  19696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  19697. /**
  19698. * Clamps the rgb values by the min and max values and stores the result into "result"
  19699. * @param min defines minimum clamping value (default is 0)
  19700. * @param max defines maximum clamping value (default is 1)
  19701. * @param result defines color to store the result into.
  19702. * @returns the cuurent Color4
  19703. */
  19704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  19705. /**
  19706. * Multipy an Color4 value by another and return a new Color4 object
  19707. * @param color defines the Color4 value to multiply by
  19708. * @returns a new Color4 object
  19709. */
  19710. multiply(color: Color4): Color4;
  19711. /**
  19712. * Multipy a Color4 value by another and push the result in a reference value
  19713. * @param color defines the Color4 value to multiply by
  19714. * @param result defines the Color4 to fill the result in
  19715. * @returns the result Color4
  19716. */
  19717. multiplyToRef(color: Color4, result: Color4): Color4;
  19718. /**
  19719. * Creates a string with the Color4 current values
  19720. * @returns the string representation of the Color4 object
  19721. */
  19722. toString(): string;
  19723. /**
  19724. * Returns the string "Color4"
  19725. * @returns "Color4"
  19726. */
  19727. getClassName(): string;
  19728. /**
  19729. * Compute the Color4 hash code
  19730. * @returns an unique number that can be used to hash Color4 objects
  19731. */
  19732. getHashCode(): number;
  19733. /**
  19734. * Creates a new Color4 copied from the current one
  19735. * @returns a new Color4 object
  19736. */
  19737. clone(): Color4;
  19738. /**
  19739. * Copies the given Color4 values into the current one
  19740. * @param source defines the source Color4 object
  19741. * @returns the current updated Color4 object
  19742. */
  19743. copyFrom(source: Color4): Color4;
  19744. /**
  19745. * Copies the given float values into the current one
  19746. * @param r defines the red component to read from
  19747. * @param g defines the green component to read from
  19748. * @param b defines the blue component to read from
  19749. * @param a defines the alpha component to read from
  19750. * @returns the current updated Color4 object
  19751. */
  19752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  19753. /**
  19754. * Copies the given float values into the current one
  19755. * @param r defines the red component to read from
  19756. * @param g defines the green component to read from
  19757. * @param b defines the blue component to read from
  19758. * @param a defines the alpha component to read from
  19759. * @returns the current updated Color4 object
  19760. */
  19761. set(r: number, g: number, b: number, a: number): Color4;
  19762. /**
  19763. * Compute the Color4 hexadecimal code as a string
  19764. * @returns a string containing the hexadecimal representation of the Color4 object
  19765. */
  19766. toHexString(): string;
  19767. /**
  19768. * Computes a new Color4 converted from the current one to linear space
  19769. * @returns a new Color4 object
  19770. */
  19771. toLinearSpace(): Color4;
  19772. /**
  19773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  19774. * @param convertedColor defines the Color4 object where to store the linear space version
  19775. * @returns the unmodified Color4
  19776. */
  19777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  19778. /**
  19779. * Computes a new Color4 converted from the current one to gamma space
  19780. * @returns a new Color4 object
  19781. */
  19782. toGammaSpace(): Color4;
  19783. /**
  19784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  19785. * @param convertedColor defines the Color4 object where to store the gamma space version
  19786. * @returns the unmodified Color4
  19787. */
  19788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  19789. /**
  19790. * Creates a new Color4 from the string containing valid hexadecimal values
  19791. * @param hex defines a string containing valid hexadecimal values
  19792. * @returns a new Color4 object
  19793. */
  19794. static FromHexString(hex: string): Color4;
  19795. /**
  19796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  19797. * @param left defines the start value
  19798. * @param right defines the end value
  19799. * @param amount defines the gradient factor
  19800. * @returns a new Color4 object
  19801. */
  19802. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  19803. /**
  19804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  19805. * @param left defines the start value
  19806. * @param right defines the end value
  19807. * @param amount defines the gradient factor
  19808. * @param result defines the Color4 object where to store data
  19809. */
  19810. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  19811. /**
  19812. * Creates a new Color4 from a Color3 and an alpha value
  19813. * @param color3 defines the source Color3 to read from
  19814. * @param alpha defines the alpha component (1.0 by default)
  19815. * @returns a new Color4 object
  19816. */
  19817. static FromColor3(color3: Color3, alpha?: number): Color4;
  19818. /**
  19819. * Creates a new Color4 from the starting index element of the given array
  19820. * @param array defines the source array to read from
  19821. * @param offset defines the offset in the source array
  19822. * @returns a new Color4 object
  19823. */
  19824. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  19825. /**
  19826. * Creates a new Color3 from integer values (< 256)
  19827. * @param r defines the red component to read from (value between 0 and 255)
  19828. * @param g defines the green component to read from (value between 0 and 255)
  19829. * @param b defines the blue component to read from (value between 0 and 255)
  19830. * @param a defines the alpha component to read from (value between 0 and 255)
  19831. * @returns a new Color3 object
  19832. */
  19833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  19834. /**
  19835. * Check the content of a given array and convert it to an array containing RGBA data
  19836. * If the original array was already containing count * 4 values then it is returned directly
  19837. * @param colors defines the array to check
  19838. * @param count defines the number of RGBA data to expect
  19839. * @returns an array containing count * 4 values (RGBA)
  19840. */
  19841. static CheckColors4(colors: number[], count: number): number[];
  19842. }
  19843. /**
  19844. * Class representing a vector containing 2 coordinates
  19845. */
  19846. class Vector2 {
  19847. /** defines the first coordinate */
  19848. x: number;
  19849. /** defines the second coordinate */
  19850. y: number;
  19851. /**
  19852. * Creates a new Vector2 from the given x and y coordinates
  19853. * @param x defines the first coordinate
  19854. * @param y defines the second coordinate
  19855. */
  19856. constructor(
  19857. /** defines the first coordinate */
  19858. x?: number,
  19859. /** defines the second coordinate */
  19860. y?: number);
  19861. /**
  19862. * Gets a string with the Vector2 coordinates
  19863. * @returns a string with the Vector2 coordinates
  19864. */
  19865. toString(): string;
  19866. /**
  19867. * Gets class name
  19868. * @returns the string "Vector2"
  19869. */
  19870. getClassName(): string;
  19871. /**
  19872. * Gets current vector hash code
  19873. * @returns the Vector2 hash code as a number
  19874. */
  19875. getHashCode(): number;
  19876. /**
  19877. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  19878. * @param array defines the source array
  19879. * @param index defines the offset in source array
  19880. * @returns the current Vector2
  19881. */
  19882. toArray(array: FloatArray, index?: number): Vector2;
  19883. /**
  19884. * Copy the current vector to an array
  19885. * @returns a new array with 2 elements: the Vector2 coordinates.
  19886. */
  19887. asArray(): number[];
  19888. /**
  19889. * Sets the Vector2 coordinates with the given Vector2 coordinates
  19890. * @param source defines the source Vector2
  19891. * @returns the current updated Vector2
  19892. */
  19893. copyFrom(source: Vector2): Vector2;
  19894. /**
  19895. * Sets the Vector2 coordinates with the given floats
  19896. * @param x defines the first coordinate
  19897. * @param y defines the second coordinate
  19898. * @returns the current updated Vector2
  19899. */
  19900. copyFromFloats(x: number, y: number): Vector2;
  19901. /**
  19902. * Sets the Vector2 coordinates with the given floats
  19903. * @param x defines the first coordinate
  19904. * @param y defines the second coordinate
  19905. * @returns the current updated Vector2
  19906. */
  19907. set(x: number, y: number): Vector2;
  19908. /**
  19909. * Add another vector with the current one
  19910. * @param otherVector defines the other vector
  19911. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  19912. */
  19913. add(otherVector: Vector2): Vector2;
  19914. /**
  19915. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  19916. * @param otherVector defines the other vector
  19917. * @param result defines the target vector
  19918. * @returns the unmodified current Vector2
  19919. */
  19920. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  19921. /**
  19922. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  19923. * @param otherVector defines the other vector
  19924. * @returns the current updated Vector2
  19925. */
  19926. addInPlace(otherVector: Vector2): Vector2;
  19927. /**
  19928. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  19929. * @param otherVector defines the other vector
  19930. * @returns a new Vector2
  19931. */
  19932. addVector3(otherVector: Vector3): Vector2;
  19933. /**
  19934. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  19935. * @param otherVector defines the other vector
  19936. * @returns a new Vector2
  19937. */
  19938. subtract(otherVector: Vector2): Vector2;
  19939. /**
  19940. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  19941. * @param otherVector defines the other vector
  19942. * @param result defines the target vector
  19943. * @returns the unmodified current Vector2
  19944. */
  19945. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  19946. /**
  19947. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  19948. * @param otherVector defines the other vector
  19949. * @returns the current updated Vector2
  19950. */
  19951. subtractInPlace(otherVector: Vector2): Vector2;
  19952. /**
  19953. * Multiplies in place the current Vector2 coordinates by the given ones
  19954. * @param otherVector defines the other vector
  19955. * @returns the current updated Vector2
  19956. */
  19957. multiplyInPlace(otherVector: Vector2): Vector2;
  19958. /**
  19959. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  19960. * @param otherVector defines the other vector
  19961. * @returns a new Vector2
  19962. */
  19963. multiply(otherVector: Vector2): Vector2;
  19964. /**
  19965. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  19966. * @param otherVector defines the other vector
  19967. * @param result defines the target vector
  19968. * @returns the unmodified current Vector2
  19969. */
  19970. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  19971. /**
  19972. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  19973. * @param x defines the first coordinate
  19974. * @param y defines the second coordinate
  19975. * @returns a new Vector2
  19976. */
  19977. multiplyByFloats(x: number, y: number): Vector2;
  19978. /**
  19979. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  19980. * @param otherVector defines the other vector
  19981. * @returns a new Vector2
  19982. */
  19983. divide(otherVector: Vector2): Vector2;
  19984. /**
  19985. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  19986. * @param otherVector defines the other vector
  19987. * @param result defines the target vector
  19988. * @returns the unmodified current Vector2
  19989. */
  19990. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  19991. /**
  19992. * Divides the current Vector2 coordinates by the given ones
  19993. * @param otherVector defines the other vector
  19994. * @returns the current updated Vector2
  19995. */
  19996. divideInPlace(otherVector: Vector2): Vector2;
  19997. /**
  19998. * Gets a new Vector2 with current Vector2 negated coordinates
  19999. * @returns a new Vector2
  20000. */
  20001. negate(): Vector2;
  20002. /**
  20003. * Multiply the Vector2 coordinates by scale
  20004. * @param scale defines the scaling factor
  20005. * @returns the current updated Vector2
  20006. */
  20007. scaleInPlace(scale: number): Vector2;
  20008. /**
  20009. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20010. * @param scale defines the scaling factor
  20011. * @returns a new Vector2
  20012. */
  20013. scale(scale: number): Vector2;
  20014. /**
  20015. * Scale the current Vector2 values by a factor to a given Vector2
  20016. * @param scale defines the scale factor
  20017. * @param result defines the Vector2 object where to store the result
  20018. * @returns the unmodified current Vector2
  20019. */
  20020. scaleToRef(scale: number, result: Vector2): Vector2;
  20021. /**
  20022. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20023. * @param scale defines the scale factor
  20024. * @param result defines the Vector2 object where to store the result
  20025. * @returns the unmodified current Vector2
  20026. */
  20027. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20028. /**
  20029. * Gets a boolean if two vectors are equals
  20030. * @param otherVector defines the other vector
  20031. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20032. */
  20033. equals(otherVector: Vector2): boolean;
  20034. /**
  20035. * Gets a boolean if two vectors are equals (using an epsilon value)
  20036. * @param otherVector defines the other vector
  20037. * @param epsilon defines the minimal distance to consider equality
  20038. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20039. */
  20040. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20041. /**
  20042. * Gets a new Vector2 from current Vector2 floored values
  20043. * @returns a new Vector2
  20044. */
  20045. floor(): Vector2;
  20046. /**
  20047. * Gets a new Vector2 from current Vector2 floored values
  20048. * @returns a new Vector2
  20049. */
  20050. fract(): Vector2;
  20051. /**
  20052. * Gets the length of the vector
  20053. * @returns the vector length (float)
  20054. */
  20055. length(): number;
  20056. /**
  20057. * Gets the vector squared length
  20058. * @returns the vector squared length (float)
  20059. */
  20060. lengthSquared(): number;
  20061. /**
  20062. * Normalize the vector
  20063. * @returns the current updated Vector2
  20064. */
  20065. normalize(): Vector2;
  20066. /**
  20067. * Gets a new Vector2 copied from the Vector2
  20068. * @returns a new Vector2
  20069. */
  20070. clone(): Vector2;
  20071. /**
  20072. * Gets a new Vector2(0, 0)
  20073. * @returns a new Vector2
  20074. */
  20075. static Zero(): Vector2;
  20076. /**
  20077. * Gets a new Vector2(1, 1)
  20078. * @returns a new Vector2
  20079. */
  20080. static One(): Vector2;
  20081. /**
  20082. * Gets a new Vector2 set from the given index element of the given array
  20083. * @param array defines the data source
  20084. * @param offset defines the offset in the data source
  20085. * @returns a new Vector2
  20086. */
  20087. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20088. /**
  20089. * Sets "result" from the given index element of the given array
  20090. * @param array defines the data source
  20091. * @param offset defines the offset in the data source
  20092. * @param result defines the target vector
  20093. */
  20094. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20095. /**
  20096. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20097. * @param value1 defines 1st point of control
  20098. * @param value2 defines 2nd point of control
  20099. * @param value3 defines 3rd point of control
  20100. * @param value4 defines 4th point of control
  20101. * @param amount defines the interpolation factor
  20102. * @returns a new Vector2
  20103. */
  20104. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20105. /**
  20106. * 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".
  20107. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20108. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20109. * @param value defines the value to clamp
  20110. * @param min defines the lower limit
  20111. * @param max defines the upper limit
  20112. * @returns a new Vector2
  20113. */
  20114. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20115. /**
  20116. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20117. * @param value1 defines the 1st control point
  20118. * @param tangent1 defines the outgoing tangent
  20119. * @param value2 defines the 2nd control point
  20120. * @param tangent2 defines the incoming tangent
  20121. * @param amount defines the interpolation factor
  20122. * @returns a new Vector2
  20123. */
  20124. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20125. /**
  20126. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20127. * @param start defines the start vector
  20128. * @param end defines the end vector
  20129. * @param amount defines the interpolation factor
  20130. * @returns a new Vector2
  20131. */
  20132. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20133. /**
  20134. * Gets the dot product of the vector "left" and the vector "right"
  20135. * @param left defines first vector
  20136. * @param right defines second vector
  20137. * @returns the dot product (float)
  20138. */
  20139. static Dot(left: Vector2, right: Vector2): number;
  20140. /**
  20141. * Returns a new Vector2 equal to the normalized given vector
  20142. * @param vector defines the vector to normalize
  20143. * @returns a new Vector2
  20144. */
  20145. static Normalize(vector: Vector2): Vector2;
  20146. /**
  20147. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20148. * @param left defines 1st vector
  20149. * @param right defines 2nd vector
  20150. * @returns a new Vector2
  20151. */
  20152. static Minimize(left: Vector2, right: Vector2): Vector2;
  20153. /**
  20154. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20155. * @param left defines 1st vector
  20156. * @param right defines 2nd vector
  20157. * @returns a new Vector2
  20158. */
  20159. static Maximize(left: Vector2, right: Vector2): Vector2;
  20160. /**
  20161. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20162. * @param vector defines the vector to transform
  20163. * @param transformation defines the matrix to apply
  20164. * @returns a new Vector2
  20165. */
  20166. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20167. /**
  20168. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20169. * @param vector defines the vector to transform
  20170. * @param transformation defines the matrix to apply
  20171. * @param result defines the target vector
  20172. */
  20173. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20174. /**
  20175. * Determines if a given vector is included in a triangle
  20176. * @param p defines the vector to test
  20177. * @param p0 defines 1st triangle point
  20178. * @param p1 defines 2nd triangle point
  20179. * @param p2 defines 3rd triangle point
  20180. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20181. */
  20182. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20183. /**
  20184. * Gets the distance between the vectors "value1" and "value2"
  20185. * @param value1 defines first vector
  20186. * @param value2 defines second vector
  20187. * @returns the distance between vectors
  20188. */
  20189. static Distance(value1: Vector2, value2: Vector2): number;
  20190. /**
  20191. * Returns the squared distance between the vectors "value1" and "value2"
  20192. * @param value1 defines first vector
  20193. * @param value2 defines second vector
  20194. * @returns the squared distance between vectors
  20195. */
  20196. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20197. /**
  20198. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20199. * @param value1 defines first vector
  20200. * @param value2 defines second vector
  20201. * @returns a new Vector2
  20202. */
  20203. static Center(value1: Vector2, value2: Vector2): Vector2;
  20204. /**
  20205. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20206. * @param p defines the middle point
  20207. * @param segA defines one point of the segment
  20208. * @param segB defines the other point of the segment
  20209. * @returns the shortest distance
  20210. */
  20211. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20212. }
  20213. /**
  20214. * Classed used to store (x,y,z) vector representation
  20215. * A Vector3 is the main object used in 3D geometry
  20216. * It can represent etiher the coordinates of a point the space, either a direction
  20217. * Reminder: Babylon.js uses a left handed forward facing system
  20218. */
  20219. class Vector3 {
  20220. /**
  20221. * Defines the first coordinates (on X axis)
  20222. */
  20223. x: number;
  20224. /**
  20225. * Defines the second coordinates (on Y axis)
  20226. */
  20227. y: number;
  20228. /**
  20229. * Defines the third coordinates (on Z axis)
  20230. */
  20231. z: number;
  20232. /**
  20233. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20234. * @param x defines the first coordinates (on X axis)
  20235. * @param y defines the second coordinates (on Y axis)
  20236. * @param z defines the third coordinates (on Z axis)
  20237. */
  20238. constructor(
  20239. /**
  20240. * Defines the first coordinates (on X axis)
  20241. */
  20242. x?: number,
  20243. /**
  20244. * Defines the second coordinates (on Y axis)
  20245. */
  20246. y?: number,
  20247. /**
  20248. * Defines the third coordinates (on Z axis)
  20249. */
  20250. z?: number);
  20251. /**
  20252. * Creates a string representation of the Vector3
  20253. * @returns a string with the Vector3 coordinates.
  20254. */
  20255. toString(): string;
  20256. /**
  20257. * Gets the class name
  20258. * @returns the string "Vector3"
  20259. */
  20260. getClassName(): string;
  20261. /**
  20262. * Creates the Vector3 hash code
  20263. * @returns a number which tends to be unique between Vector3 instances
  20264. */
  20265. getHashCode(): number;
  20266. /**
  20267. * Creates an array containing three elements : the coordinates of the Vector3
  20268. * @returns a new array of numbers
  20269. */
  20270. asArray(): number[];
  20271. /**
  20272. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20273. * @param array defines the destination array
  20274. * @param index defines the offset in the destination array
  20275. * @returns the current Vector3
  20276. */
  20277. toArray(array: FloatArray, index?: number): Vector3;
  20278. /**
  20279. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20280. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20281. */
  20282. toQuaternion(): Quaternion;
  20283. /**
  20284. * Adds the given vector to the current Vector3
  20285. * @param otherVector defines the second operand
  20286. * @returns the current updated Vector3
  20287. */
  20288. addInPlace(otherVector: Vector3): Vector3;
  20289. /**
  20290. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20291. * @param otherVector defines the second operand
  20292. * @returns the resulting Vector3
  20293. */
  20294. add(otherVector: Vector3): Vector3;
  20295. /**
  20296. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  20297. * @param otherVector defines the second operand
  20298. * @param result defines the Vector3 object where to store the result
  20299. * @returns the current Vector3
  20300. */
  20301. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  20302. /**
  20303. * Subtract the given vector from the current Vector3
  20304. * @param otherVector defines the second operand
  20305. * @returns the current updated Vector3
  20306. */
  20307. subtractInPlace(otherVector: Vector3): Vector3;
  20308. /**
  20309. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  20310. * @param otherVector defines the second operand
  20311. * @returns the resulting Vector3
  20312. */
  20313. subtract(otherVector: Vector3): Vector3;
  20314. /**
  20315. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  20316. * @param otherVector defines the second operand
  20317. * @param result defines the Vector3 object where to store the result
  20318. * @returns the current Vector3
  20319. */
  20320. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  20321. /**
  20322. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  20323. * @param x defines the x coordinate of the operand
  20324. * @param y defines the y coordinate of the operand
  20325. * @param z defines the z coordinate of the operand
  20326. * @returns the resulting Vector3
  20327. */
  20328. subtractFromFloats(x: number, y: number, z: number): Vector3;
  20329. /**
  20330. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  20331. * @param x defines the x coordinate of the operand
  20332. * @param y defines the y coordinate of the operand
  20333. * @param z defines the z coordinate of the operand
  20334. * @param result defines the Vector3 object where to store the result
  20335. * @returns the current Vector3
  20336. */
  20337. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  20338. /**
  20339. * Gets a new Vector3 set with the current Vector3 negated coordinates
  20340. * @returns a new Vector3
  20341. */
  20342. negate(): Vector3;
  20343. /**
  20344. * Multiplies the Vector3 coordinates by the float "scale"
  20345. * @param scale defines the multiplier factor
  20346. * @returns the current updated Vector3
  20347. */
  20348. scaleInPlace(scale: number): Vector3;
  20349. /**
  20350. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  20351. * @param scale defines the multiplier factor
  20352. * @returns a new Vector3
  20353. */
  20354. scale(scale: number): Vector3;
  20355. /**
  20356. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  20357. * @param scale defines the multiplier factor
  20358. * @param result defines the Vector3 object where to store the result
  20359. * @returns the current Vector3
  20360. */
  20361. scaleToRef(scale: number, result: Vector3): Vector3;
  20362. /**
  20363. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  20364. * @param scale defines the scale factor
  20365. * @param result defines the Vector3 object where to store the result
  20366. * @returns the unmodified current Vector3
  20367. */
  20368. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  20369. /**
  20370. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  20371. * @param otherVector defines the second operand
  20372. * @returns true if both vectors are equals
  20373. */
  20374. equals(otherVector: Vector3): boolean;
  20375. /**
  20376. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  20377. * @param otherVector defines the second operand
  20378. * @param epsilon defines the minimal distance to define values as equals
  20379. * @returns true if both vectors are distant less than epsilon
  20380. */
  20381. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  20382. /**
  20383. * Returns true if the current Vector3 coordinates equals the given floats
  20384. * @param x defines the x coordinate of the operand
  20385. * @param y defines the y coordinate of the operand
  20386. * @param z defines the z coordinate of the operand
  20387. * @returns true if both vectors are equals
  20388. */
  20389. equalsToFloats(x: number, y: number, z: number): boolean;
  20390. /**
  20391. * Multiplies the current Vector3 coordinates by the given ones
  20392. * @param otherVector defines the second operand
  20393. * @returns the current updated Vector3
  20394. */
  20395. multiplyInPlace(otherVector: Vector3): Vector3;
  20396. /**
  20397. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  20398. * @param otherVector defines the second operand
  20399. * @returns the new Vector3
  20400. */
  20401. multiply(otherVector: Vector3): Vector3;
  20402. /**
  20403. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  20404. * @param otherVector defines the second operand
  20405. * @param result defines the Vector3 object where to store the result
  20406. * @returns the current Vector3
  20407. */
  20408. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  20409. /**
  20410. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  20411. * @param x defines the x coordinate of the operand
  20412. * @param y defines the y coordinate of the operand
  20413. * @param z defines the z coordinate of the operand
  20414. * @returns the new Vector3
  20415. */
  20416. multiplyByFloats(x: number, y: number, z: number): Vector3;
  20417. /**
  20418. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  20419. * @param otherVector defines the second operand
  20420. * @returns the new Vector3
  20421. */
  20422. divide(otherVector: Vector3): Vector3;
  20423. /**
  20424. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  20425. * @param otherVector defines the second operand
  20426. * @param result defines the Vector3 object where to store the result
  20427. * @returns the current Vector3
  20428. */
  20429. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  20430. /**
  20431. * Divides the current Vector3 coordinates by the given ones.
  20432. * @param otherVector defines the second operand
  20433. * @returns the current updated Vector3
  20434. */
  20435. divideInPlace(otherVector: Vector3): Vector3;
  20436. /**
  20437. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  20438. * @param other defines the second operand
  20439. * @returns the current updated Vector3
  20440. */
  20441. minimizeInPlace(other: Vector3): Vector3;
  20442. /**
  20443. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  20444. * @param other defines the second operand
  20445. * @returns the current updated Vector3
  20446. */
  20447. maximizeInPlace(other: Vector3): Vector3;
  20448. /**
  20449. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  20450. * @param x defines the x coordinate of the operand
  20451. * @param y defines the y coordinate of the operand
  20452. * @param z defines the z coordinate of the operand
  20453. * @returns the current updated Vector3
  20454. */
  20455. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20456. /**
  20457. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  20458. * @param x defines the x coordinate of the operand
  20459. * @param y defines the y coordinate of the operand
  20460. * @param z defines the z coordinate of the operand
  20461. * @returns the current updated Vector3
  20462. */
  20463. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20464. /**
  20465. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  20466. */
  20467. readonly isNonUniform: boolean;
  20468. /**
  20469. * Gets a new Vector3 from current Vector3 floored values
  20470. * @returns a new Vector3
  20471. */
  20472. floor(): Vector3;
  20473. /**
  20474. * Gets a new Vector3 from current Vector3 floored values
  20475. * @returns a new Vector3
  20476. */
  20477. fract(): Vector3;
  20478. /**
  20479. * Gets the length of the Vector3
  20480. * @returns the length of the Vecto3
  20481. */
  20482. length(): number;
  20483. /**
  20484. * Gets the squared length of the Vector3
  20485. * @returns squared length of the Vector3
  20486. */
  20487. lengthSquared(): number;
  20488. /**
  20489. * Normalize the current Vector3.
  20490. * Please note that this is an in place operation.
  20491. * @returns the current updated Vector3
  20492. */
  20493. normalize(): Vector3;
  20494. /**
  20495. * Normalize the current Vector3 to a new vector
  20496. * @returns the new Vector3
  20497. */
  20498. normalizeToNew(): Vector3;
  20499. /**
  20500. * Normalize the current Vector3 to the reference
  20501. * @param reference define the Vector3 to update
  20502. * @returns the updated Vector3
  20503. */
  20504. normalizeToRef(reference: Vector3): Vector3;
  20505. /**
  20506. * Creates a new Vector3 copied from the current Vector3
  20507. * @returns the new Vector3
  20508. */
  20509. clone(): Vector3;
  20510. /**
  20511. * Copies the given vector coordinates to the current Vector3 ones
  20512. * @param source defines the source Vector3
  20513. * @returns the current updated Vector3
  20514. */
  20515. copyFrom(source: Vector3): Vector3;
  20516. /**
  20517. * Copies the given floats to the current Vector3 coordinates
  20518. * @param x defines the x coordinate of the operand
  20519. * @param y defines the y coordinate of the operand
  20520. * @param z defines the z coordinate of the operand
  20521. * @returns the current updated Vector3
  20522. */
  20523. copyFromFloats(x: number, y: number, z: number): Vector3;
  20524. /**
  20525. * Copies the given floats to the current Vector3 coordinates
  20526. * @param x defines the x coordinate of the operand
  20527. * @param y defines the y coordinate of the operand
  20528. * @param z defines the z coordinate of the operand
  20529. * @returns the current updated Vector3
  20530. */
  20531. set(x: number, y: number, z: number): Vector3;
  20532. /**
  20533. * Get the clip factor between two vectors
  20534. * @param vector0 defines the first operand
  20535. * @param vector1 defines the second operand
  20536. * @param axis defines the axis to use
  20537. * @param size defines the size along the axis
  20538. * @returns the clip factor
  20539. */
  20540. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  20541. /**
  20542. * Get angle between two vectors
  20543. * @param vector0 angle between vector0 and vector1
  20544. * @param vector1 angle between vector0 and vector1
  20545. * @param normal direction of the normal
  20546. * @return the angle between vector0 and vector1
  20547. */
  20548. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  20549. /**
  20550. * Returns a new Vector3 set from the index "offset" of the given array
  20551. * @param array defines the source array
  20552. * @param offset defines the offset in the source array
  20553. * @returns the new Vector3
  20554. */
  20555. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  20556. /**
  20557. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  20558. * This function is deprecated. Use FromArray instead
  20559. * @param array defines the source array
  20560. * @param offset defines the offset in the source array
  20561. * @returns the new Vector3
  20562. */
  20563. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  20564. /**
  20565. * Sets the given vector "result" with the element values from the index "offset" of the given array
  20566. * @param array defines the source array
  20567. * @param offset defines the offset in the source array
  20568. * @param result defines the Vector3 where to store the result
  20569. */
  20570. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  20571. /**
  20572. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  20573. * This function is deprecated. Use FromArrayToRef instead.
  20574. * @param array defines the source array
  20575. * @param offset defines the offset in the source array
  20576. * @param result defines the Vector3 where to store the result
  20577. */
  20578. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  20579. /**
  20580. * Sets the given vector "result" with the given floats.
  20581. * @param x defines the x coordinate of the source
  20582. * @param y defines the y coordinate of the source
  20583. * @param z defines the z coordinate of the source
  20584. * @param result defines the Vector3 where to store the result
  20585. */
  20586. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  20587. /**
  20588. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  20589. * @returns a new empty Vector3
  20590. */
  20591. static Zero(): Vector3;
  20592. /**
  20593. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  20594. * @returns a new unit Vector3
  20595. */
  20596. static One(): Vector3;
  20597. /**
  20598. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  20599. * @returns a new up Vector3
  20600. */
  20601. static Up(): Vector3;
  20602. /**
  20603. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  20604. * @returns a new down Vector3
  20605. */
  20606. static Down(): Vector3;
  20607. /**
  20608. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  20609. * @returns a new forward Vector3
  20610. */
  20611. static Forward(): Vector3;
  20612. /**
  20613. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  20614. * @returns a new forward Vector3
  20615. */
  20616. static Backward(): Vector3;
  20617. /**
  20618. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  20619. * @returns a new right Vector3
  20620. */
  20621. static Right(): Vector3;
  20622. /**
  20623. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  20624. * @returns a new left Vector3
  20625. */
  20626. static Left(): Vector3;
  20627. /**
  20628. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  20629. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  20630. * @param vector defines the Vector3 to transform
  20631. * @param transformation defines the transformation matrix
  20632. * @returns the transformed Vector3
  20633. */
  20634. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  20635. /**
  20636. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  20637. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  20638. * @param vector defines the Vector3 to transform
  20639. * @param transformation defines the transformation matrix
  20640. * @param result defines the Vector3 where to store the result
  20641. */
  20642. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  20643. /**
  20644. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  20645. * This method computes tranformed coordinates only, not transformed direction vectors
  20646. * @param x define the x coordinate of the source vector
  20647. * @param y define the y coordinate of the source vector
  20648. * @param z define the z coordinate of the source vector
  20649. * @param transformation defines the transformation matrix
  20650. * @param result defines the Vector3 where to store the result
  20651. */
  20652. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  20653. /**
  20654. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  20655. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  20656. * @param vector defines the Vector3 to transform
  20657. * @param transformation defines the transformation matrix
  20658. * @returns the new Vector3
  20659. */
  20660. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  20661. /**
  20662. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  20663. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  20664. * @param vector defines the Vector3 to transform
  20665. * @param transformation defines the transformation matrix
  20666. * @param result defines the Vector3 where to store the result
  20667. */
  20668. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  20669. /**
  20670. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  20671. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  20672. * @param x define the x coordinate of the source vector
  20673. * @param y define the y coordinate of the source vector
  20674. * @param z define the z coordinate of the source vector
  20675. * @param transformation defines the transformation matrix
  20676. * @param result defines the Vector3 where to store the result
  20677. */
  20678. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  20679. /**
  20680. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  20681. * @param value1 defines the first control point
  20682. * @param value2 defines the second control point
  20683. * @param value3 defines the third control point
  20684. * @param value4 defines the fourth control point
  20685. * @param amount defines the amount on the spline to use
  20686. * @returns the new Vector3
  20687. */
  20688. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  20689. /**
  20690. * 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"
  20691. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  20692. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  20693. * @param value defines the current value
  20694. * @param min defines the lower range value
  20695. * @param max defines the upper range value
  20696. * @returns the new Vector3
  20697. */
  20698. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  20699. /**
  20700. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  20701. * @param value1 defines the first control point
  20702. * @param tangent1 defines the first tangent vector
  20703. * @param value2 defines the second control point
  20704. * @param tangent2 defines the second tangent vector
  20705. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  20706. * @returns the new Vector3
  20707. */
  20708. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  20709. /**
  20710. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  20711. * @param start defines the start value
  20712. * @param end defines the end value
  20713. * @param amount max defines amount between both (between 0 and 1)
  20714. * @returns the new Vector3
  20715. */
  20716. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  20717. /**
  20718. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  20719. * @param start defines the start value
  20720. * @param end defines the end value
  20721. * @param amount max defines amount between both (between 0 and 1)
  20722. * @param result defines the Vector3 where to store the result
  20723. */
  20724. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  20725. /**
  20726. * Returns the dot product (float) between the vectors "left" and "right"
  20727. * @param left defines the left operand
  20728. * @param right defines the right operand
  20729. * @returns the dot product
  20730. */
  20731. static Dot(left: Vector3, right: Vector3): number;
  20732. /**
  20733. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  20734. * The cross product is then orthogonal to both "left" and "right"
  20735. * @param left defines the left operand
  20736. * @param right defines the right operand
  20737. * @returns the cross product
  20738. */
  20739. static Cross(left: Vector3, right: Vector3): Vector3;
  20740. /**
  20741. * Sets the given vector "result" with the cross product of "left" and "right"
  20742. * The cross product is then orthogonal to both "left" and "right"
  20743. * @param left defines the left operand
  20744. * @param right defines the right operand
  20745. * @param result defines the Vector3 where to store the result
  20746. */
  20747. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  20748. /**
  20749. * Returns a new Vector3 as the normalization of the given vector
  20750. * @param vector defines the Vector3 to normalize
  20751. * @returns the new Vector3
  20752. */
  20753. static Normalize(vector: Vector3): Vector3;
  20754. /**
  20755. * Sets the given vector "result" with the normalization of the given first vector
  20756. * @param vector defines the Vector3 to normalize
  20757. * @param result defines the Vector3 where to store the result
  20758. */
  20759. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  20760. private static _viewportMatrixCache;
  20761. /**
  20762. * Project a Vector3 onto screen space
  20763. * @param vector defines the Vector3 to project
  20764. * @param world defines the world matrix to use
  20765. * @param transform defines the transform (view x projection) matrix to use
  20766. * @param viewport defines the screen viewport to use
  20767. * @returns the new Vector3
  20768. */
  20769. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  20770. /**
  20771. * Unproject from screen space to object space
  20772. * @param source defines the screen space Vector3 to use
  20773. * @param viewportWidth defines the current width of the viewport
  20774. * @param viewportHeight defines the current height of the viewport
  20775. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20776. * @param transform defines the transform (view x projection) matrix to use
  20777. * @returns the new Vector3
  20778. */
  20779. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  20780. /**
  20781. * Unproject from screen space to object space
  20782. * @param source defines the screen space Vector3 to use
  20783. * @param viewportWidth defines the current width of the viewport
  20784. * @param viewportHeight defines the current height of the viewport
  20785. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20786. * @param view defines the view matrix to use
  20787. * @param projection defines the projection matrix to use
  20788. * @returns the new Vector3
  20789. */
  20790. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  20791. /**
  20792. * Unproject from screen space to object space
  20793. * @param source defines the screen space Vector3 to use
  20794. * @param viewportWidth defines the current width of the viewport
  20795. * @param viewportHeight defines the current height of the viewport
  20796. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20797. * @param view defines the view matrix to use
  20798. * @param projection defines the projection matrix to use
  20799. * @param result defines the Vector3 where to store the result
  20800. */
  20801. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  20802. /**
  20803. * Unproject from screen space to object space
  20804. * @param sourceX defines the screen space x coordinate to use
  20805. * @param sourceY defines the screen space y coordinate to use
  20806. * @param sourceZ defines the screen space z coordinate to use
  20807. * @param viewportWidth defines the current width of the viewport
  20808. * @param viewportHeight defines the current height of the viewport
  20809. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20810. * @param view defines the view matrix to use
  20811. * @param projection defines the projection matrix to use
  20812. * @param result defines the Vector3 where to store the result
  20813. */
  20814. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  20815. /**
  20816. * Gets the minimal coordinate values between two Vector3
  20817. * @param left defines the first operand
  20818. * @param right defines the second operand
  20819. * @returns the new Vector3
  20820. */
  20821. static Minimize(left: Vector3, right: Vector3): Vector3;
  20822. /**
  20823. * Gets the maximal coordinate values between two Vector3
  20824. * @param left defines the first operand
  20825. * @param right defines the second operand
  20826. * @returns the new Vector3
  20827. */
  20828. static Maximize(left: Vector3, right: Vector3): Vector3;
  20829. /**
  20830. * Returns the distance between the vectors "value1" and "value2"
  20831. * @param value1 defines the first operand
  20832. * @param value2 defines the second operand
  20833. * @returns the distance
  20834. */
  20835. static Distance(value1: Vector3, value2: Vector3): number;
  20836. /**
  20837. * Returns the squared distance between the vectors "value1" and "value2"
  20838. * @param value1 defines the first operand
  20839. * @param value2 defines the second operand
  20840. * @returns the squared distance
  20841. */
  20842. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  20843. /**
  20844. * Returns a new Vector3 located at the center between "value1" and "value2"
  20845. * @param value1 defines the first operand
  20846. * @param value2 defines the second operand
  20847. * @returns the new Vector3
  20848. */
  20849. static Center(value1: Vector3, value2: Vector3): Vector3;
  20850. /**
  20851. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  20852. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  20853. * to something in order to rotate it from its local system to the given target system
  20854. * Note: axis1, axis2 and axis3 are normalized during this operation
  20855. * @param axis1 defines the first axis
  20856. * @param axis2 defines the second axis
  20857. * @param axis3 defines the third axis
  20858. * @returns a new Vector3
  20859. */
  20860. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  20861. /**
  20862. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  20863. * @param axis1 defines the first axis
  20864. * @param axis2 defines the second axis
  20865. * @param axis3 defines the third axis
  20866. * @param ref defines the Vector3 where to store the result
  20867. */
  20868. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  20869. }
  20870. /**
  20871. * Vector4 class created for EulerAngle class conversion to Quaternion
  20872. */
  20873. class Vector4 {
  20874. /** x value of the vector */
  20875. x: number;
  20876. /** y value of the vector */
  20877. y: number;
  20878. /** z value of the vector */
  20879. z: number;
  20880. /** w value of the vector */
  20881. w: number;
  20882. /**
  20883. * Creates a Vector4 object from the given floats.
  20884. * @param x x value of the vector
  20885. * @param y y value of the vector
  20886. * @param z z value of the vector
  20887. * @param w w value of the vector
  20888. */
  20889. constructor(
  20890. /** x value of the vector */
  20891. x: number,
  20892. /** y value of the vector */
  20893. y: number,
  20894. /** z value of the vector */
  20895. z: number,
  20896. /** w value of the vector */
  20897. w: number);
  20898. /**
  20899. * Returns the string with the Vector4 coordinates.
  20900. * @returns a string containing all the vector values
  20901. */
  20902. toString(): string;
  20903. /**
  20904. * Returns the string "Vector4".
  20905. * @returns "Vector4"
  20906. */
  20907. getClassName(): string;
  20908. /**
  20909. * Returns the Vector4 hash code.
  20910. * @returns a unique hash code
  20911. */
  20912. getHashCode(): number;
  20913. /**
  20914. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  20915. * @returns the resulting array
  20916. */
  20917. asArray(): number[];
  20918. /**
  20919. * Populates the given array from the given index with the Vector4 coordinates.
  20920. * @param array array to populate
  20921. * @param index index of the array to start at (default: 0)
  20922. * @returns the Vector4.
  20923. */
  20924. toArray(array: FloatArray, index?: number): Vector4;
  20925. /**
  20926. * Adds the given vector to the current Vector4.
  20927. * @param otherVector the vector to add
  20928. * @returns the updated Vector4.
  20929. */
  20930. addInPlace(otherVector: Vector4): Vector4;
  20931. /**
  20932. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  20933. * @param otherVector the vector to add
  20934. * @returns the resulting vector
  20935. */
  20936. add(otherVector: Vector4): Vector4;
  20937. /**
  20938. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  20939. * @param otherVector the vector to add
  20940. * @param result the vector to store the result
  20941. * @returns the current Vector4.
  20942. */
  20943. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  20944. /**
  20945. * Subtract in place the given vector from the current Vector4.
  20946. * @param otherVector the vector to subtract
  20947. * @returns the updated Vector4.
  20948. */
  20949. subtractInPlace(otherVector: Vector4): Vector4;
  20950. /**
  20951. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  20952. * @param otherVector the vector to add
  20953. * @returns the new vector with the result
  20954. */
  20955. subtract(otherVector: Vector4): Vector4;
  20956. /**
  20957. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  20958. * @param otherVector the vector to subtract
  20959. * @param result the vector to store the result
  20960. * @returns the current Vector4.
  20961. */
  20962. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  20963. /**
  20964. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  20965. */
  20966. /**
  20967. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  20968. * @param x value to subtract
  20969. * @param y value to subtract
  20970. * @param z value to subtract
  20971. * @param w value to subtract
  20972. * @returns new vector containing the result
  20973. */
  20974. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  20975. /**
  20976. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  20977. * @param x value to subtract
  20978. * @param y value to subtract
  20979. * @param z value to subtract
  20980. * @param w value to subtract
  20981. * @param result the vector to store the result in
  20982. * @returns the current Vector4.
  20983. */
  20984. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  20985. /**
  20986. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  20987. * @returns a new vector with the negated values
  20988. */
  20989. negate(): Vector4;
  20990. /**
  20991. * Multiplies the current Vector4 coordinates by scale (float).
  20992. * @param scale the number to scale with
  20993. * @returns the updated Vector4.
  20994. */
  20995. scaleInPlace(scale: number): Vector4;
  20996. /**
  20997. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  20998. * @param scale the number to scale with
  20999. * @returns a new vector with the result
  21000. */
  21001. scale(scale: number): Vector4;
  21002. /**
  21003. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21004. * @param scale the number to scale with
  21005. * @param result a vector to store the result in
  21006. * @returns the current Vector4.
  21007. */
  21008. scaleToRef(scale: number, result: Vector4): Vector4;
  21009. /**
  21010. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21011. * @param scale defines the scale factor
  21012. * @param result defines the Vector4 object where to store the result
  21013. * @returns the unmodified current Vector4
  21014. */
  21015. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21016. /**
  21017. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21018. * @param otherVector the vector to compare against
  21019. * @returns true if they are equal
  21020. */
  21021. equals(otherVector: Vector4): boolean;
  21022. /**
  21023. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21024. * @param otherVector vector to compare against
  21025. * @param epsilon (Default: very small number)
  21026. * @returns true if they are equal
  21027. */
  21028. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21029. /**
  21030. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21031. * @param x x value to compare against
  21032. * @param y y value to compare against
  21033. * @param z z value to compare against
  21034. * @param w w value to compare against
  21035. * @returns true if equal
  21036. */
  21037. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21038. /**
  21039. * Multiplies in place the current Vector4 by the given one.
  21040. * @param otherVector vector to multiple with
  21041. * @returns the updated Vector4.
  21042. */
  21043. multiplyInPlace(otherVector: Vector4): Vector4;
  21044. /**
  21045. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21046. * @param otherVector vector to multiple with
  21047. * @returns resulting new vector
  21048. */
  21049. multiply(otherVector: Vector4): Vector4;
  21050. /**
  21051. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21052. * @param otherVector vector to multiple with
  21053. * @param result vector to store the result
  21054. * @returns the current Vector4.
  21055. */
  21056. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21057. /**
  21058. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21059. * @param x x value multiply with
  21060. * @param y y value multiply with
  21061. * @param z z value multiply with
  21062. * @param w w value multiply with
  21063. * @returns resulting new vector
  21064. */
  21065. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21066. /**
  21067. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21068. * @param otherVector vector to devide with
  21069. * @returns resulting new vector
  21070. */
  21071. divide(otherVector: Vector4): Vector4;
  21072. /**
  21073. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21074. * @param otherVector vector to devide with
  21075. * @param result vector to store the result
  21076. * @returns the current Vector4.
  21077. */
  21078. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21079. /**
  21080. * Divides the current Vector3 coordinates by the given ones.
  21081. * @param otherVector vector to devide with
  21082. * @returns the updated Vector3.
  21083. */
  21084. divideInPlace(otherVector: Vector4): Vector4;
  21085. /**
  21086. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21087. * @param other defines the second operand
  21088. * @returns the current updated Vector4
  21089. */
  21090. minimizeInPlace(other: Vector4): Vector4;
  21091. /**
  21092. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21093. * @param other defines the second operand
  21094. * @returns the current updated Vector4
  21095. */
  21096. maximizeInPlace(other: Vector4): Vector4;
  21097. /**
  21098. * Gets a new Vector4 from current Vector4 floored values
  21099. * @returns a new Vector4
  21100. */
  21101. floor(): Vector4;
  21102. /**
  21103. * Gets a new Vector4 from current Vector3 floored values
  21104. * @returns a new Vector4
  21105. */
  21106. fract(): Vector4;
  21107. /**
  21108. * Returns the Vector4 length (float).
  21109. * @returns the length
  21110. */
  21111. length(): number;
  21112. /**
  21113. * Returns the Vector4 squared length (float).
  21114. * @returns the length squared
  21115. */
  21116. lengthSquared(): number;
  21117. /**
  21118. * Normalizes in place the Vector4.
  21119. * @returns the updated Vector4.
  21120. */
  21121. normalize(): Vector4;
  21122. /**
  21123. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21124. * @returns this converted to a new vector3
  21125. */
  21126. toVector3(): Vector3;
  21127. /**
  21128. * Returns a new Vector4 copied from the current one.
  21129. * @returns the new cloned vector
  21130. */
  21131. clone(): Vector4;
  21132. /**
  21133. * Updates the current Vector4 with the given one coordinates.
  21134. * @param source the source vector to copy from
  21135. * @returns the updated Vector4.
  21136. */
  21137. copyFrom(source: Vector4): Vector4;
  21138. /**
  21139. * Updates the current Vector4 coordinates with the given floats.
  21140. * @param x float to copy from
  21141. * @param y float to copy from
  21142. * @param z float to copy from
  21143. * @param w float to copy from
  21144. * @returns the updated Vector4.
  21145. */
  21146. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21147. /**
  21148. * Updates the current Vector4 coordinates with the given floats.
  21149. * @param x float to set from
  21150. * @param y float to set from
  21151. * @param z float to set from
  21152. * @param w float to set from
  21153. * @returns the updated Vector4.
  21154. */
  21155. set(x: number, y: number, z: number, w: number): Vector4;
  21156. /**
  21157. * Returns a new Vector4 set from the starting index of the given array.
  21158. * @param array the array to pull values from
  21159. * @param offset the offset into the array to start at
  21160. * @returns the new vector
  21161. */
  21162. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21163. /**
  21164. * Updates the given vector "result" from the starting index of the given array.
  21165. * @param array the array to pull values from
  21166. * @param offset the offset into the array to start at
  21167. * @param result the vector to store the result in
  21168. */
  21169. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21170. /**
  21171. * Updates the given vector "result" from the starting index of the given Float32Array.
  21172. * @param array the array to pull values from
  21173. * @param offset the offset into the array to start at
  21174. * @param result the vector to store the result in
  21175. */
  21176. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21177. /**
  21178. * Updates the given vector "result" coordinates from the given floats.
  21179. * @param x float to set from
  21180. * @param y float to set from
  21181. * @param z float to set from
  21182. * @param w float to set from
  21183. * @param result the vector to the floats in
  21184. */
  21185. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21186. /**
  21187. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21188. * @returns the new vector
  21189. */
  21190. static Zero(): Vector4;
  21191. /**
  21192. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21193. * @returns the new vector
  21194. */
  21195. static One(): Vector4;
  21196. /**
  21197. * Returns a new normalized Vector4 from the given one.
  21198. * @param vector the vector to normalize
  21199. * @returns the vector
  21200. */
  21201. static Normalize(vector: Vector4): Vector4;
  21202. /**
  21203. * Updates the given vector "result" from the normalization of the given one.
  21204. * @param vector the vector to normalize
  21205. * @param result the vector to store the result in
  21206. */
  21207. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  21208. /**
  21209. * Returns a vector with the minimum values from the left and right vectors
  21210. * @param left left vector to minimize
  21211. * @param right right vector to minimize
  21212. * @returns a new vector with the minimum of the left and right vector values
  21213. */
  21214. static Minimize(left: Vector4, right: Vector4): Vector4;
  21215. /**
  21216. * Returns a vector with the maximum values from the left and right vectors
  21217. * @param left left vector to maximize
  21218. * @param right right vector to maximize
  21219. * @returns a new vector with the maximum of the left and right vector values
  21220. */
  21221. static Maximize(left: Vector4, right: Vector4): Vector4;
  21222. /**
  21223. * Returns the distance (float) between the vectors "value1" and "value2".
  21224. * @param value1 value to calulate the distance between
  21225. * @param value2 value to calulate the distance between
  21226. * @return the distance between the two vectors
  21227. */
  21228. static Distance(value1: Vector4, value2: Vector4): number;
  21229. /**
  21230. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21231. * @param value1 value to calulate the distance between
  21232. * @param value2 value to calulate the distance between
  21233. * @return the distance between the two vectors squared
  21234. */
  21235. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  21236. /**
  21237. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21238. * @param value1 value to calulate the center between
  21239. * @param value2 value to calulate the center between
  21240. * @return the center between the two vectors
  21241. */
  21242. static Center(value1: Vector4, value2: Vector4): Vector4;
  21243. /**
  21244. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21245. * This methods computes transformed normalized direction vectors only.
  21246. * @param vector the vector to transform
  21247. * @param transformation the transformation matrix to apply
  21248. * @returns the new vector
  21249. */
  21250. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  21251. /**
  21252. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21253. * This methods computes transformed normalized direction vectors only.
  21254. * @param vector the vector to transform
  21255. * @param transformation the transformation matrix to apply
  21256. * @param result the vector to store the result in
  21257. */
  21258. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  21259. /**
  21260. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  21261. * This methods computes transformed normalized direction vectors only.
  21262. * @param x value to transform
  21263. * @param y value to transform
  21264. * @param z value to transform
  21265. * @param w value to transform
  21266. * @param transformation the transformation matrix to apply
  21267. * @param result the vector to store the results in
  21268. */
  21269. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  21270. }
  21271. /**
  21272. * Interface for the size containing width and height
  21273. */
  21274. interface ISize {
  21275. /**
  21276. * Width
  21277. */
  21278. width: number;
  21279. /**
  21280. * Heighht
  21281. */
  21282. height: number;
  21283. }
  21284. /**
  21285. * Size containing widht and height
  21286. */
  21287. class Size implements ISize {
  21288. /**
  21289. * Width
  21290. */
  21291. width: number;
  21292. /**
  21293. * Height
  21294. */
  21295. height: number;
  21296. /**
  21297. * Creates a Size object from the given width and height (floats).
  21298. * @param width width of the new size
  21299. * @param height height of the new size
  21300. */
  21301. constructor(width: number, height: number);
  21302. /**
  21303. * Returns a string with the Size width and height
  21304. * @returns a string with the Size width and height
  21305. */
  21306. toString(): string;
  21307. /**
  21308. * "Size"
  21309. * @returns the string "Size"
  21310. */
  21311. getClassName(): string;
  21312. /**
  21313. * Returns the Size hash code.
  21314. * @returns a hash code for a unique width and height
  21315. */
  21316. getHashCode(): number;
  21317. /**
  21318. * Updates the current size from the given one.
  21319. * @param src the given size
  21320. */
  21321. copyFrom(src: Size): void;
  21322. /**
  21323. * Updates in place the current Size from the given floats.
  21324. * @param width width of the new size
  21325. * @param height height of the new size
  21326. * @returns the updated Size.
  21327. */
  21328. copyFromFloats(width: number, height: number): Size;
  21329. /**
  21330. * Updates in place the current Size from the given floats.
  21331. * @param width width to set
  21332. * @param height height to set
  21333. * @returns the updated Size.
  21334. */
  21335. set(width: number, height: number): Size;
  21336. /**
  21337. * Multiplies the width and height by numbers
  21338. * @param w factor to multiple the width by
  21339. * @param h factor to multiple the height by
  21340. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  21341. */
  21342. multiplyByFloats(w: number, h: number): Size;
  21343. /**
  21344. * Clones the size
  21345. * @returns a new Size copied from the given one.
  21346. */
  21347. clone(): Size;
  21348. /**
  21349. * True if the current Size and the given one width and height are strictly equal.
  21350. * @param other the other size to compare against
  21351. * @returns True if the current Size and the given one width and height are strictly equal.
  21352. */
  21353. equals(other: Size): boolean;
  21354. /**
  21355. * The surface of the Size : width * height (float).
  21356. */
  21357. readonly surface: number;
  21358. /**
  21359. * Create a new size of zero
  21360. * @returns a new Size set to (0.0, 0.0)
  21361. */
  21362. static Zero(): Size;
  21363. /**
  21364. * Sums the width and height of two sizes
  21365. * @param otherSize size to add to this size
  21366. * @returns a new Size set as the addition result of the current Size and the given one.
  21367. */
  21368. add(otherSize: Size): Size;
  21369. /**
  21370. * Subtracts the width and height of two
  21371. * @param otherSize size to subtract to this size
  21372. * @returns a new Size set as the subtraction result of the given one from the current Size.
  21373. */
  21374. subtract(otherSize: Size): Size;
  21375. /**
  21376. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  21377. * @param start starting size to lerp between
  21378. * @param end end size to lerp between
  21379. * @param amount amount to lerp between the start and end values
  21380. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  21381. */
  21382. static Lerp(start: Size, end: Size, amount: number): Size;
  21383. }
  21384. /**
  21385. * Class used to store quaternion data
  21386. * @see https://en.wikipedia.org/wiki/Quaternion
  21387. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  21388. */
  21389. class Quaternion {
  21390. /** defines the first component (0 by default) */
  21391. x: number;
  21392. /** defines the second component (0 by default) */
  21393. y: number;
  21394. /** defines the third component (0 by default) */
  21395. z: number;
  21396. /** defines the fourth component (1.0 by default) */
  21397. w: number;
  21398. /**
  21399. * Creates a new Quaternion from the given floats
  21400. * @param x defines the first component (0 by default)
  21401. * @param y defines the second component (0 by default)
  21402. * @param z defines the third component (0 by default)
  21403. * @param w defines the fourth component (1.0 by default)
  21404. */
  21405. constructor(
  21406. /** defines the first component (0 by default) */
  21407. x?: number,
  21408. /** defines the second component (0 by default) */
  21409. y?: number,
  21410. /** defines the third component (0 by default) */
  21411. z?: number,
  21412. /** defines the fourth component (1.0 by default) */
  21413. w?: number);
  21414. /**
  21415. * Gets a string representation for the current quaternion
  21416. * @returns a string with the Quaternion coordinates
  21417. */
  21418. toString(): string;
  21419. /**
  21420. * Gets the class name of the quaternion
  21421. * @returns the string "Quaternion"
  21422. */
  21423. getClassName(): string;
  21424. /**
  21425. * Gets a hash code for this quaternion
  21426. * @returns the quaternion hash code
  21427. */
  21428. getHashCode(): number;
  21429. /**
  21430. * Copy the quaternion to an array
  21431. * @returns a new array populated with 4 elements from the quaternion coordinates
  21432. */
  21433. asArray(): number[];
  21434. /**
  21435. * Check if two quaternions are equals
  21436. * @param otherQuaternion defines the second operand
  21437. * @return true if the current quaternion and the given one coordinates are strictly equals
  21438. */
  21439. equals(otherQuaternion: Quaternion): boolean;
  21440. /**
  21441. * Clone the current quaternion
  21442. * @returns a new quaternion copied from the current one
  21443. */
  21444. clone(): Quaternion;
  21445. /**
  21446. * Copy a quaternion to the current one
  21447. * @param other defines the other quaternion
  21448. * @returns the updated current quaternion
  21449. */
  21450. copyFrom(other: Quaternion): Quaternion;
  21451. /**
  21452. * Updates the current quaternion with the given float coordinates
  21453. * @param x defines the x coordinate
  21454. * @param y defines the y coordinate
  21455. * @param z defines the z coordinate
  21456. * @param w defines the w coordinate
  21457. * @returns the updated current quaternion
  21458. */
  21459. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  21460. /**
  21461. * Updates the current quaternion from the given float coordinates
  21462. * @param x defines the x coordinate
  21463. * @param y defines the y coordinate
  21464. * @param z defines the z coordinate
  21465. * @param w defines the w coordinate
  21466. * @returns the updated current quaternion
  21467. */
  21468. set(x: number, y: number, z: number, w: number): Quaternion;
  21469. /**
  21470. * Adds two quaternions
  21471. * @param other defines the second operand
  21472. * @returns a new quaternion as the addition result of the given one and the current quaternion
  21473. */
  21474. add(other: Quaternion): Quaternion;
  21475. /**
  21476. * Add a quaternion to the current one
  21477. * @param other defines the quaternion to add
  21478. * @returns the current quaternion
  21479. */
  21480. addInPlace(other: Quaternion): Quaternion;
  21481. /**
  21482. * Subtract two quaternions
  21483. * @param other defines the second operand
  21484. * @returns a new quaternion as the subtraction result of the given one from the current one
  21485. */
  21486. subtract(other: Quaternion): Quaternion;
  21487. /**
  21488. * Multiplies the current quaternion by a scale factor
  21489. * @param value defines the scale factor
  21490. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  21491. */
  21492. scale(value: number): Quaternion;
  21493. /**
  21494. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  21495. * @param scale defines the scale factor
  21496. * @param result defines the Quaternion object where to store the result
  21497. * @returns the unmodified current quaternion
  21498. */
  21499. scaleToRef(scale: number, result: Quaternion): Quaternion;
  21500. /**
  21501. * Multiplies in place the current quaternion by a scale factor
  21502. * @param value defines the scale factor
  21503. * @returns the current modified quaternion
  21504. */
  21505. scaleInPlace(value: number): Quaternion;
  21506. /**
  21507. * Scale the current quaternion values by a factor and add the result to a given quaternion
  21508. * @param scale defines the scale factor
  21509. * @param result defines the Quaternion object where to store the result
  21510. * @returns the unmodified current quaternion
  21511. */
  21512. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  21513. /**
  21514. * Multiplies two quaternions
  21515. * @param q1 defines the second operand
  21516. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  21517. */
  21518. multiply(q1: Quaternion): Quaternion;
  21519. /**
  21520. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  21521. * @param q1 defines the second operand
  21522. * @param result defines the target quaternion
  21523. * @returns the current quaternion
  21524. */
  21525. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  21526. /**
  21527. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  21528. * @param q1 defines the second operand
  21529. * @returns the currentupdated quaternion
  21530. */
  21531. multiplyInPlace(q1: Quaternion): Quaternion;
  21532. /**
  21533. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  21534. * @param ref defines the target quaternion
  21535. * @returns the current quaternion
  21536. */
  21537. conjugateToRef(ref: Quaternion): Quaternion;
  21538. /**
  21539. * Conjugates in place (1-q) the current quaternion
  21540. * @returns the current updated quaternion
  21541. */
  21542. conjugateInPlace(): Quaternion;
  21543. /**
  21544. * Conjugates in place (1-q) the current quaternion
  21545. * @returns a new quaternion
  21546. */
  21547. conjugate(): Quaternion;
  21548. /**
  21549. * Gets length of current quaternion
  21550. * @returns the quaternion length (float)
  21551. */
  21552. length(): number;
  21553. /**
  21554. * Normalize in place the current quaternion
  21555. * @returns the current updated quaternion
  21556. */
  21557. normalize(): Quaternion;
  21558. /**
  21559. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  21560. * @param order is a reserved parameter and is ignore for now
  21561. * @returns a new Vector3 containing the Euler angles
  21562. */
  21563. toEulerAngles(order?: string): Vector3;
  21564. /**
  21565. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  21566. * @param result defines the vector which will be filled with the Euler angles
  21567. * @param order is a reserved parameter and is ignore for now
  21568. * @returns the current unchanged quaternion
  21569. */
  21570. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  21571. /**
  21572. * Updates the given rotation matrix with the current quaternion values
  21573. * @param result defines the target matrix
  21574. * @returns the current unchanged quaternion
  21575. */
  21576. toRotationMatrix(result: Matrix): Quaternion;
  21577. /**
  21578. * Updates the current quaternion from the given rotation matrix values
  21579. * @param matrix defines the source matrix
  21580. * @returns the current updated quaternion
  21581. */
  21582. fromRotationMatrix(matrix: Matrix): Quaternion;
  21583. /**
  21584. * Creates a new quaternion from a rotation matrix
  21585. * @param matrix defines the source matrix
  21586. * @returns a new quaternion created from the given rotation matrix values
  21587. */
  21588. static FromRotationMatrix(matrix: Matrix): Quaternion;
  21589. /**
  21590. * Updates the given quaternion with the given rotation matrix values
  21591. * @param matrix defines the source matrix
  21592. * @param result defines the target quaternion
  21593. */
  21594. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  21595. /**
  21596. * Returns the dot product (float) between the quaternions "left" and "right"
  21597. * @param left defines the left operand
  21598. * @param right defines the right operand
  21599. * @returns the dot product
  21600. */
  21601. static Dot(left: Quaternion, right: Quaternion): number;
  21602. /**
  21603. * Checks if the two quaternions are close to each other
  21604. * @param quat0 defines the first quaternion to check
  21605. * @param quat1 defines the second quaternion to check
  21606. * @returns true if the two quaternions are close to each other
  21607. */
  21608. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  21609. /**
  21610. * Creates an empty quaternion
  21611. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  21612. */
  21613. static Zero(): Quaternion;
  21614. /**
  21615. * Inverse a given quaternion
  21616. * @param q defines the source quaternion
  21617. * @returns a new quaternion as the inverted current quaternion
  21618. */
  21619. static Inverse(q: Quaternion): Quaternion;
  21620. /**
  21621. * Creates an identity quaternion
  21622. * @returns the identity quaternion
  21623. */
  21624. static Identity(): Quaternion;
  21625. /**
  21626. * Gets a boolean indicating if the given quaternion is identity
  21627. * @param quaternion defines the quaternion to check
  21628. * @returns true if the quaternion is identity
  21629. */
  21630. static IsIdentity(quaternion: Quaternion): boolean;
  21631. /**
  21632. * Creates a quaternion from a rotation around an axis
  21633. * @param axis defines the axis to use
  21634. * @param angle defines the angle to use
  21635. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  21636. */
  21637. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  21638. /**
  21639. * Creates a rotation around an axis and stores it into the given quaternion
  21640. * @param axis defines the axis to use
  21641. * @param angle defines the angle to use
  21642. * @param result defines the target quaternion
  21643. * @returns the target quaternion
  21644. */
  21645. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  21646. /**
  21647. * Creates a new quaternion from data stored into an array
  21648. * @param array defines the data source
  21649. * @param offset defines the offset in the source array where the data starts
  21650. * @returns a new quaternion
  21651. */
  21652. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  21653. /**
  21654. * Creates a new quaternion from the given Euler float angles (y, x, z)
  21655. * @param yaw defines the rotation around Y axis
  21656. * @param pitch defines the rotation around X axis
  21657. * @param roll defines the rotation around Z axis
  21658. * @returns the new quaternion
  21659. */
  21660. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  21661. /**
  21662. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  21663. * @param yaw defines the rotation around Y axis
  21664. * @param pitch defines the rotation around X axis
  21665. * @param roll defines the rotation around Z axis
  21666. * @param result defines the target quaternion
  21667. */
  21668. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  21669. /**
  21670. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  21671. * @param alpha defines the rotation around first axis
  21672. * @param beta defines the rotation around second axis
  21673. * @param gamma defines the rotation around third axis
  21674. * @returns the new quaternion
  21675. */
  21676. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  21677. /**
  21678. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  21679. * @param alpha defines the rotation around first axis
  21680. * @param beta defines the rotation around second axis
  21681. * @param gamma defines the rotation around third axis
  21682. * @param result defines the target quaternion
  21683. */
  21684. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  21685. /**
  21686. * 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)
  21687. * @param axis1 defines the first axis
  21688. * @param axis2 defines the second axis
  21689. * @param axis3 defines the third axis
  21690. * @returns the new quaternion
  21691. */
  21692. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  21693. /**
  21694. * 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
  21695. * @param axis1 defines the first axis
  21696. * @param axis2 defines the second axis
  21697. * @param axis3 defines the third axis
  21698. * @param ref defines the target quaternion
  21699. */
  21700. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  21701. /**
  21702. * Interpolates between two quaternions
  21703. * @param left defines first quaternion
  21704. * @param right defines second quaternion
  21705. * @param amount defines the gradient to use
  21706. * @returns the new interpolated quaternion
  21707. */
  21708. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  21709. /**
  21710. * Interpolates between two quaternions and stores it into a target quaternion
  21711. * @param left defines first quaternion
  21712. * @param right defines second quaternion
  21713. * @param amount defines the gradient to use
  21714. * @param result defines the target quaternion
  21715. */
  21716. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  21717. /**
  21718. * Interpolate between two quaternions using Hermite interpolation
  21719. * @param value1 defines first quaternion
  21720. * @param tangent1 defines the incoming tangent
  21721. * @param value2 defines second quaternion
  21722. * @param tangent2 defines the outgoing tangent
  21723. * @param amount defines the target quaternion
  21724. * @returns the new interpolated quaternion
  21725. */
  21726. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  21727. }
  21728. /**
  21729. * Class used to store matrix data (4x4)
  21730. */
  21731. class Matrix {
  21732. private static _tempQuaternion;
  21733. private static _xAxis;
  21734. private static _yAxis;
  21735. private static _zAxis;
  21736. private static _updateFlagSeed;
  21737. private static _identityReadOnly;
  21738. private _isIdentity;
  21739. private _isIdentityDirty;
  21740. /**
  21741. * Gets the update flag of the matrix which is an unique number for the matrix.
  21742. * It will be incremented every time the matrix data change.
  21743. * You can use it to speed the comparison between two versions of the same matrix.
  21744. */
  21745. updateFlag: number;
  21746. /**
  21747. * Gets or sets the internal data of the matrix
  21748. */
  21749. m: Float32Array;
  21750. /** @hidden */
  21751. _markAsUpdated(): void;
  21752. /**
  21753. * Creates an empty matrix (filled with zeros)
  21754. */
  21755. constructor();
  21756. /**
  21757. * Check if the current matrix is indentity
  21758. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  21759. * @returns true is the matrix is the identity matrix
  21760. */
  21761. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  21762. /**
  21763. * Gets the determinant of the matrix
  21764. * @returns the matrix determinant
  21765. */
  21766. determinant(): number;
  21767. /**
  21768. * Returns the matrix as a Float32Array
  21769. * @returns the matrix underlying array
  21770. */
  21771. toArray(): Float32Array;
  21772. /**
  21773. * Returns the matrix as a Float32Array
  21774. * @returns the matrix underlying array.
  21775. */
  21776. asArray(): Float32Array;
  21777. /**
  21778. * Inverts the current matrix in place
  21779. * @returns the current inverted matrix
  21780. */
  21781. invert(): Matrix;
  21782. /**
  21783. * Sets all the matrix elements to zero
  21784. * @returns the current matrix
  21785. */
  21786. reset(): Matrix;
  21787. /**
  21788. * Adds the current matrix with a second one
  21789. * @param other defines the matrix to add
  21790. * @returns a new matrix as the addition of the current matrix and the given one
  21791. */
  21792. add(other: Matrix): Matrix;
  21793. /**
  21794. * Sets the given matrix "result" to the addition of the current matrix and the given one
  21795. * @param other defines the matrix to add
  21796. * @param result defines the target matrix
  21797. * @returns the current matrix
  21798. */
  21799. addToRef(other: Matrix, result: Matrix): Matrix;
  21800. /**
  21801. * Adds in place the given matrix to the current matrix
  21802. * @param other defines the second operand
  21803. * @returns the current updated matrix
  21804. */
  21805. addToSelf(other: Matrix): Matrix;
  21806. /**
  21807. * Sets the given matrix to the current inverted Matrix
  21808. * @param other defines the target matrix
  21809. * @returns the unmodified current matrix
  21810. */
  21811. invertToRef(other: Matrix): Matrix;
  21812. /**
  21813. * Inserts the translation vector (using 3 floats) in the current matrix
  21814. * @param x defines the 1st component of the translation
  21815. * @param y defines the 2nd component of the translation
  21816. * @param z defines the 3rd component of the translation
  21817. * @returns the current updated matrix
  21818. */
  21819. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  21820. /**
  21821. * Inserts the translation vector in the current matrix
  21822. * @param vector3 defines the translation to insert
  21823. * @returns the current updated matrix
  21824. */
  21825. setTranslation(vector3: Vector3): Matrix;
  21826. /**
  21827. * Gets the translation value of the current matrix
  21828. * @returns a new Vector3 as the extracted translation from the matrix
  21829. */
  21830. getTranslation(): Vector3;
  21831. /**
  21832. * Fill a Vector3 with the extracted translation from the matrix
  21833. * @param result defines the Vector3 where to store the translation
  21834. * @returns the current matrix
  21835. */
  21836. getTranslationToRef(result: Vector3): Matrix;
  21837. /**
  21838. * Remove rotation and scaling part from the matrix
  21839. * @returns the updated matrix
  21840. */
  21841. removeRotationAndScaling(): Matrix;
  21842. /**
  21843. * Multiply two matrices
  21844. * @param other defines the second operand
  21845. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  21846. */
  21847. multiply(other: Matrix): Matrix;
  21848. /**
  21849. * Copy the current matrix from the given one
  21850. * @param other defines the source matrix
  21851. * @returns the current updated matrix
  21852. */
  21853. copyFrom(other: Matrix): Matrix;
  21854. /**
  21855. * Populates the given array from the starting index with the current matrix values
  21856. * @param array defines the target array
  21857. * @param offset defines the offset in the target array where to start storing values
  21858. * @returns the current matrix
  21859. */
  21860. copyToArray(array: Float32Array, offset?: number): Matrix;
  21861. /**
  21862. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  21863. * @param other defines the second operand
  21864. * @param result defines the matrix where to store the multiplication
  21865. * @returns the current matrix
  21866. */
  21867. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  21868. /**
  21869. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  21870. * @param other defines the second operand
  21871. * @param result defines the array where to store the multiplication
  21872. * @param offset defines the offset in the target array where to start storing values
  21873. * @returns the current matrix
  21874. */
  21875. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  21876. /**
  21877. * Check equality between this matrix and a second one
  21878. * @param value defines the second matrix to compare
  21879. * @returns true is the current matrix and the given one values are strictly equal
  21880. */
  21881. equals(value: Matrix): boolean;
  21882. /**
  21883. * Clone the current matrix
  21884. * @returns a new matrix from the current matrix
  21885. */
  21886. clone(): Matrix;
  21887. /**
  21888. * Returns the name of the current matrix class
  21889. * @returns the string "Matrix"
  21890. */
  21891. getClassName(): string;
  21892. /**
  21893. * Gets the hash code of the current matrix
  21894. * @returns the hash code
  21895. */
  21896. getHashCode(): number;
  21897. /**
  21898. * Decomposes the current Matrix into a translation, rotation and scaling components
  21899. * @param scale defines the scale vector3 given as a reference to update
  21900. * @param rotation defines the rotation quaternion given as a reference to update
  21901. * @param translation defines the translation vector3 given as a reference to update
  21902. * @returns true if operation was successful
  21903. */
  21904. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  21905. /**
  21906. * Gets specific row of the matrix
  21907. * @param index defines the number of the row to get
  21908. * @returns the index-th row of the current matrix as a new Vector4
  21909. */
  21910. getRow(index: number): Nullable<Vector4>;
  21911. /**
  21912. * Sets the index-th row of the current matrix to the vector4 values
  21913. * @param index defines the number of the row to set
  21914. * @param row defines the target vector4
  21915. * @returns the updated current matrix
  21916. */
  21917. setRow(index: number, row: Vector4): Matrix;
  21918. /**
  21919. * Compute the transpose of the matrix
  21920. * @returns the new transposed matrix
  21921. */
  21922. transpose(): Matrix;
  21923. /**
  21924. * Compute the transpose of the matrix and store it in a given matrix
  21925. * @param result defines the target matrix
  21926. * @returns the current matrix
  21927. */
  21928. transposeToRef(result: Matrix): Matrix;
  21929. /**
  21930. * Sets the index-th row of the current matrix with the given 4 x float values
  21931. * @param index defines the row index
  21932. * @param x defines the x component to set
  21933. * @param y defines the y component to set
  21934. * @param z defines the z component to set
  21935. * @param w defines the w component to set
  21936. * @returns the updated current matrix
  21937. */
  21938. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  21939. /**
  21940. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  21941. * @param scale defines the scale factor
  21942. * @returns a new matrix
  21943. */
  21944. scale(scale: number): Matrix;
  21945. /**
  21946. * Scale the current matrix values by a factor to a given result matrix
  21947. * @param scale defines the scale factor
  21948. * @param result defines the matrix to store the result
  21949. * @returns the current matrix
  21950. */
  21951. scaleToRef(scale: number, result: Matrix): Matrix;
  21952. /**
  21953. * Scale the current matrix values by a factor and add the result to a given matrix
  21954. * @param scale defines the scale factor
  21955. * @param result defines the Matrix to store the result
  21956. * @returns the current matrix
  21957. */
  21958. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  21959. /**
  21960. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  21961. * @param ref matrix to store the result
  21962. */
  21963. toNormalMatrix(ref: Matrix): void;
  21964. /**
  21965. * Gets only rotation part of the current matrix
  21966. * @returns a new matrix sets to the extracted rotation matrix from the current one
  21967. */
  21968. getRotationMatrix(): Matrix;
  21969. /**
  21970. * Extracts the rotation matrix from the current one and sets it as the given "result"
  21971. * @param result defines the target matrix to store data to
  21972. * @returns the current matrix
  21973. */
  21974. getRotationMatrixToRef(result: Matrix): Matrix;
  21975. /**
  21976. * Creates a matrix from an array
  21977. * @param array defines the source array
  21978. * @param offset defines an offset in the source array
  21979. * @returns a new Matrix set from the starting index of the given array
  21980. */
  21981. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  21982. /**
  21983. * Copy the content of an array into a given matrix
  21984. * @param array defines the source array
  21985. * @param offset defines an offset in the source array
  21986. * @param result defines the target matrix
  21987. */
  21988. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  21989. /**
  21990. * Stores an array into a matrix after having multiplied each component by a given factor
  21991. * @param array defines the source array
  21992. * @param offset defines the offset in the source array
  21993. * @param scale defines the scaling factor
  21994. * @param result defines the target matrix
  21995. */
  21996. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  21997. /**
  21998. * Stores a list of values (16) inside a given matrix
  21999. * @param initialM11 defines 1st value of 1st row
  22000. * @param initialM12 defines 2nd value of 1st row
  22001. * @param initialM13 defines 3rd value of 1st row
  22002. * @param initialM14 defines 4th value of 1st row
  22003. * @param initialM21 defines 1st value of 2nd row
  22004. * @param initialM22 defines 2nd value of 2nd row
  22005. * @param initialM23 defines 3rd value of 2nd row
  22006. * @param initialM24 defines 4th value of 2nd row
  22007. * @param initialM31 defines 1st value of 3rd row
  22008. * @param initialM32 defines 2nd value of 3rd row
  22009. * @param initialM33 defines 3rd value of 3rd row
  22010. * @param initialM34 defines 4th value of 3rd row
  22011. * @param initialM41 defines 1st value of 4th row
  22012. * @param initialM42 defines 2nd value of 4th row
  22013. * @param initialM43 defines 3rd value of 4th row
  22014. * @param initialM44 defines 4th value of 4th row
  22015. * @param result defines the target matrix
  22016. */
  22017. 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;
  22018. /**
  22019. * Gets an identity matrix that must not be updated
  22020. */
  22021. static readonly IdentityReadOnly: Matrix;
  22022. /**
  22023. * Creates new matrix from a list of values (16)
  22024. * @param initialM11 defines 1st value of 1st row
  22025. * @param initialM12 defines 2nd value of 1st row
  22026. * @param initialM13 defines 3rd value of 1st row
  22027. * @param initialM14 defines 4th value of 1st row
  22028. * @param initialM21 defines 1st value of 2nd row
  22029. * @param initialM22 defines 2nd value of 2nd row
  22030. * @param initialM23 defines 3rd value of 2nd row
  22031. * @param initialM24 defines 4th value of 2nd row
  22032. * @param initialM31 defines 1st value of 3rd row
  22033. * @param initialM32 defines 2nd value of 3rd row
  22034. * @param initialM33 defines 3rd value of 3rd row
  22035. * @param initialM34 defines 4th value of 3rd row
  22036. * @param initialM41 defines 1st value of 4th row
  22037. * @param initialM42 defines 2nd value of 4th row
  22038. * @param initialM43 defines 3rd value of 4th row
  22039. * @param initialM44 defines 4th value of 4th row
  22040. * @returns the new matrix
  22041. */
  22042. 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;
  22043. /**
  22044. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22045. * @param scale defines the scale vector3
  22046. * @param rotation defines the rotation quaternion
  22047. * @param translation defines the translation vector3
  22048. * @returns a new matrix
  22049. */
  22050. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22051. /**
  22052. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22053. * @param scale defines the scale vector3
  22054. * @param rotation defines the rotation quaternion
  22055. * @param translation defines the translation vector3
  22056. * @param result defines the target matrix
  22057. */
  22058. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22059. /**
  22060. * Creates a new identity matrix
  22061. * @returns a new identity matrix
  22062. */
  22063. static Identity(): Matrix;
  22064. /**
  22065. * Creates a new identity matrix and stores the result in a given matrix
  22066. * @param result defines the target matrix
  22067. */
  22068. static IdentityToRef(result: Matrix): void;
  22069. /**
  22070. * Creates a new zero matrix
  22071. * @returns a new zero matrix
  22072. */
  22073. static Zero(): Matrix;
  22074. /**
  22075. * Creates a new rotation matrix for "angle" radians around the X axis
  22076. * @param angle defines the angle (in radians) to use
  22077. * @return the new matrix
  22078. */
  22079. static RotationX(angle: number): Matrix;
  22080. /**
  22081. * Creates a new matrix as the invert of a given matrix
  22082. * @param source defines the source matrix
  22083. * @returns the new matrix
  22084. */
  22085. static Invert(source: Matrix): Matrix;
  22086. /**
  22087. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22088. * @param angle defines the angle (in radians) to use
  22089. * @param result defines the target matrix
  22090. */
  22091. static RotationXToRef(angle: number, result: Matrix): void;
  22092. /**
  22093. * Creates a new rotation matrix for "angle" radians around the Y axis
  22094. * @param angle defines the angle (in radians) to use
  22095. * @return the new matrix
  22096. */
  22097. static RotationY(angle: number): Matrix;
  22098. /**
  22099. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22100. * @param angle defines the angle (in radians) to use
  22101. * @param result defines the target matrix
  22102. */
  22103. static RotationYToRef(angle: number, result: Matrix): void;
  22104. /**
  22105. * Creates a new rotation matrix for "angle" radians around the Z axis
  22106. * @param angle defines the angle (in radians) to use
  22107. * @return the new matrix
  22108. */
  22109. static RotationZ(angle: number): Matrix;
  22110. /**
  22111. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22112. * @param angle defines the angle (in radians) to use
  22113. * @param result defines the target matrix
  22114. */
  22115. static RotationZToRef(angle: number, result: Matrix): void;
  22116. /**
  22117. * Creates a new rotation matrix for "angle" radians around the given axis
  22118. * @param axis defines the axis to use
  22119. * @param angle defines the angle (in radians) to use
  22120. * @return the new matrix
  22121. */
  22122. static RotationAxis(axis: Vector3, angle: number): Matrix;
  22123. /**
  22124. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22125. * @param axis defines the axis to use
  22126. * @param angle defines the angle (in radians) to use
  22127. * @param result defines the target matrix
  22128. */
  22129. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  22130. /**
  22131. * Creates a rotation matrix
  22132. * @param yaw defines the yaw angle in radians (Y axis)
  22133. * @param pitch defines the pitch angle in radians (X axis)
  22134. * @param roll defines the roll angle in radians (X axis)
  22135. * @returns the new rotation matrix
  22136. */
  22137. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22138. /**
  22139. * Creates a rotation matrix and stores it in a given matrix
  22140. * @param yaw defines the yaw angle in radians (Y axis)
  22141. * @param pitch defines the pitch angle in radians (X axis)
  22142. * @param roll defines the roll angle in radians (X axis)
  22143. * @param result defines the target matrix
  22144. */
  22145. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22146. /**
  22147. * Creates a scaling matrix
  22148. * @param x defines the scale factor on X axis
  22149. * @param y defines the scale factor on Y axis
  22150. * @param z defines the scale factor on Z axis
  22151. * @returns the new matrix
  22152. */
  22153. static Scaling(x: number, y: number, z: number): Matrix;
  22154. /**
  22155. * Creates a scaling matrix and stores it in a given matrix
  22156. * @param x defines the scale factor on X axis
  22157. * @param y defines the scale factor on Y axis
  22158. * @param z defines the scale factor on Z axis
  22159. * @param result defines the target matrix
  22160. */
  22161. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22162. /**
  22163. * Creates a translation matrix
  22164. * @param x defines the translation on X axis
  22165. * @param y defines the translation on Y axis
  22166. * @param z defines the translationon Z axis
  22167. * @returns the new matrix
  22168. */
  22169. static Translation(x: number, y: number, z: number): Matrix;
  22170. /**
  22171. * Creates a translation matrix and stores it in a given matrix
  22172. * @param x defines the translation on X axis
  22173. * @param y defines the translation on Y axis
  22174. * @param z defines the translationon Z axis
  22175. * @param result defines the target matrix
  22176. */
  22177. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22178. /**
  22179. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22180. * @param startValue defines the start value
  22181. * @param endValue defines the end value
  22182. * @param gradient defines the gradient factor
  22183. * @returns the new matrix
  22184. */
  22185. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22186. /**
  22187. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22188. * @param startValue defines the start value
  22189. * @param endValue defines the end value
  22190. * @param gradient defines the gradient factor
  22191. * @param result defines the Matrix object where to store data
  22192. */
  22193. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22194. /**
  22195. * Builds a new matrix whose values are computed by:
  22196. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22197. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22198. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22199. * @param startValue defines the first matrix
  22200. * @param endValue defines the second matrix
  22201. * @param gradient defines the gradient between the two matrices
  22202. * @returns the new matrix
  22203. */
  22204. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22205. /**
  22206. * Update a matrix to values which are computed by:
  22207. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22208. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22209. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22210. * @param startValue defines the first matrix
  22211. * @param endValue defines the second matrix
  22212. * @param gradient defines the gradient between the two matrices
  22213. * @param result defines the target matrix
  22214. */
  22215. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22216. /**
  22217. * 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"
  22218. * This function works in left handed mode
  22219. * @param eye defines the final position of the entity
  22220. * @param target defines where the entity should look at
  22221. * @param up defines the up vector for the entity
  22222. * @returns the new matrix
  22223. */
  22224. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22225. /**
  22226. * 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".
  22227. * This function works in left handed mode
  22228. * @param eye defines the final position of the entity
  22229. * @param target defines where the entity should look at
  22230. * @param up defines the up vector for the entity
  22231. * @param result defines the target matrix
  22232. */
  22233. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22234. /**
  22235. * 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"
  22236. * This function works in right handed mode
  22237. * @param eye defines the final position of the entity
  22238. * @param target defines where the entity should look at
  22239. * @param up defines the up vector for the entity
  22240. * @returns the new matrix
  22241. */
  22242. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22243. /**
  22244. * 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".
  22245. * This function works in right handed mode
  22246. * @param eye defines the final position of the entity
  22247. * @param target defines where the entity should look at
  22248. * @param up defines the up vector for the entity
  22249. * @param result defines the target matrix
  22250. */
  22251. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22252. /**
  22253. * Create a left-handed orthographic projection matrix
  22254. * @param width defines the viewport width
  22255. * @param height defines the viewport height
  22256. * @param znear defines the near clip plane
  22257. * @param zfar defines the far clip plane
  22258. * @returns a new matrix as a left-handed orthographic projection matrix
  22259. */
  22260. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22261. /**
  22262. * Store a left-handed orthographic projection to a given matrix
  22263. * @param width defines the viewport width
  22264. * @param height defines the viewport height
  22265. * @param znear defines the near clip plane
  22266. * @param zfar defines the far clip plane
  22267. * @param result defines the target matrix
  22268. */
  22269. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  22270. /**
  22271. * Create a left-handed orthographic projection matrix
  22272. * @param left defines the viewport left coordinate
  22273. * @param right defines the viewport right coordinate
  22274. * @param bottom defines the viewport bottom coordinate
  22275. * @param top defines the viewport top coordinate
  22276. * @param znear defines the near clip plane
  22277. * @param zfar defines the far clip plane
  22278. * @returns a new matrix as a left-handed orthographic projection matrix
  22279. */
  22280. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22281. /**
  22282. * Stores a left-handed orthographic projection into a given matrix
  22283. * @param left defines the viewport left coordinate
  22284. * @param right defines the viewport right coordinate
  22285. * @param bottom defines the viewport bottom coordinate
  22286. * @param top defines the viewport top coordinate
  22287. * @param znear defines the near clip plane
  22288. * @param zfar defines the far clip plane
  22289. * @param result defines the target matrix
  22290. */
  22291. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22292. /**
  22293. * Creates a right-handed orthographic projection matrix
  22294. * @param left defines the viewport left coordinate
  22295. * @param right defines the viewport right coordinate
  22296. * @param bottom defines the viewport bottom coordinate
  22297. * @param top defines the viewport top coordinate
  22298. * @param znear defines the near clip plane
  22299. * @param zfar defines the far clip plane
  22300. * @returns a new matrix as a right-handed orthographic projection matrix
  22301. */
  22302. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22303. /**
  22304. * Stores a right-handed orthographic projection into a given matrix
  22305. * @param left defines the viewport left coordinate
  22306. * @param right defines the viewport right coordinate
  22307. * @param bottom defines the viewport bottom coordinate
  22308. * @param top defines the viewport top coordinate
  22309. * @param znear defines the near clip plane
  22310. * @param zfar defines the far clip plane
  22311. * @param result defines the target matrix
  22312. */
  22313. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22314. /**
  22315. * Creates a left-handed perspective projection matrix
  22316. * @param width defines the viewport width
  22317. * @param height defines the viewport height
  22318. * @param znear defines the near clip plane
  22319. * @param zfar defines the far clip plane
  22320. * @returns a new matrix as a left-handed perspective projection matrix
  22321. */
  22322. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22323. /**
  22324. * Creates a left-handed perspective projection matrix
  22325. * @param fov defines the horizontal field of view
  22326. * @param aspect defines the aspect ratio
  22327. * @param znear defines the near clip plane
  22328. * @param zfar defines the far clip plane
  22329. * @returns a new matrix as a left-handed perspective projection matrix
  22330. */
  22331. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22332. /**
  22333. * Stores a left-handed perspective projection into a given matrix
  22334. * @param fov defines the horizontal field of view
  22335. * @param aspect defines the aspect ratio
  22336. * @param znear defines the near clip plane
  22337. * @param zfar defines the far clip plane
  22338. * @param result defines the target matrix
  22339. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22340. */
  22341. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  22342. /**
  22343. * Creates a right-handed perspective projection matrix
  22344. * @param fov defines the horizontal field of view
  22345. * @param aspect defines the aspect ratio
  22346. * @param znear defines the near clip plane
  22347. * @param zfar defines the far clip plane
  22348. * @returns a new matrix as a right-handed perspective projection matrix
  22349. */
  22350. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  22351. /**
  22352. * Stores a right-handed perspective projection into a given matrix
  22353. * @param fov defines the horizontal field of view
  22354. * @param aspect defines the aspect ratio
  22355. * @param znear defines the near clip plane
  22356. * @param zfar defines the far clip plane
  22357. * @param result defines the target matrix
  22358. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  22359. */
  22360. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  22361. /**
  22362. * Stores a perspective projection for WebVR info a given matrix
  22363. * @param fov defines the field of view
  22364. * @param znear defines the near clip plane
  22365. * @param zfar defines the far clip plane
  22366. * @param result defines the target matrix
  22367. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  22368. */
  22369. static PerspectiveFovWebVRToRef(fov: {
  22370. upDegrees: number;
  22371. downDegrees: number;
  22372. leftDegrees: number;
  22373. rightDegrees: number;
  22374. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  22375. /**
  22376. * Computes a complete transformation matrix
  22377. * @param viewport defines the viewport to use
  22378. * @param world defines the world matrix
  22379. * @param view defines the view matrix
  22380. * @param projection defines the projection matrix
  22381. * @param zmin defines the near clip plane
  22382. * @param zmax defines the far clip plane
  22383. * @returns the transformation matrix
  22384. */
  22385. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  22386. /**
  22387. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  22388. * @param matrix defines the matrix to use
  22389. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  22390. */
  22391. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  22392. /**
  22393. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  22394. * @param matrix defines the matrix to use
  22395. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  22396. */
  22397. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  22398. /**
  22399. * Compute the transpose of a given matrix
  22400. * @param matrix defines the matrix to transpose
  22401. * @returns the new matrix
  22402. */
  22403. static Transpose(matrix: Matrix): Matrix;
  22404. /**
  22405. * Compute the transpose of a matrix and store it in a target matrix
  22406. * @param matrix defines the matrix to transpose
  22407. * @param result defines the target matrix
  22408. */
  22409. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  22410. /**
  22411. * Computes a reflection matrix from a plane
  22412. * @param plane defines the reflection plane
  22413. * @returns a new matrix
  22414. */
  22415. static Reflection(plane: Plane): Matrix;
  22416. /**
  22417. * Computes a reflection matrix from a plane
  22418. * @param plane defines the reflection plane
  22419. * @param result defines the target matrix
  22420. */
  22421. static ReflectionToRef(plane: Plane, result: Matrix): void;
  22422. /**
  22423. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  22424. * @param xaxis defines the value of the 1st axis
  22425. * @param yaxis defines the value of the 2nd axis
  22426. * @param zaxis defines the value of the 3rd axis
  22427. * @param result defines the target matrix
  22428. */
  22429. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  22430. /**
  22431. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  22432. * @param quat defines the quaternion to use
  22433. * @param result defines the target matrix
  22434. */
  22435. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  22436. }
  22437. /**
  22438. * Represens a plane by the equation ax + by + cz + d = 0
  22439. */
  22440. class Plane {
  22441. /**
  22442. * Normal of the plane (a,b,c)
  22443. */
  22444. normal: Vector3;
  22445. /**
  22446. * d component of the plane
  22447. */
  22448. d: number;
  22449. /**
  22450. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  22451. * @param a a component of the plane
  22452. * @param b b component of the plane
  22453. * @param c c component of the plane
  22454. * @param d d component of the plane
  22455. */
  22456. constructor(a: number, b: number, c: number, d: number);
  22457. /**
  22458. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  22459. */
  22460. asArray(): number[];
  22461. /**
  22462. * @returns a new plane copied from the current Plane.
  22463. */
  22464. clone(): Plane;
  22465. /**
  22466. * @returns the string "Plane".
  22467. */
  22468. getClassName(): string;
  22469. /**
  22470. * @returns the Plane hash code.
  22471. */
  22472. getHashCode(): number;
  22473. /**
  22474. * Normalize the current Plane in place.
  22475. * @returns the updated Plane.
  22476. */
  22477. normalize(): Plane;
  22478. /**
  22479. * Applies a transformation the plane and returns the result
  22480. * @param transformation the transformation matrix to be applied to the plane
  22481. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  22482. */
  22483. transform(transformation: Matrix): Plane;
  22484. /**
  22485. * Calcualtte the dot product between the point and the plane normal
  22486. * @param point point to calculate the dot product with
  22487. * @returns the dot product (float) of the point coordinates and the plane normal.
  22488. */
  22489. dotCoordinate(point: Vector3): number;
  22490. /**
  22491. * Updates the current Plane from the plane defined by the three given points.
  22492. * @param point1 one of the points used to contruct the plane
  22493. * @param point2 one of the points used to contruct the plane
  22494. * @param point3 one of the points used to contruct the plane
  22495. * @returns the updated Plane.
  22496. */
  22497. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  22498. /**
  22499. * Checks if the plane is facing a given direction
  22500. * @param direction the direction to check if the plane is facing
  22501. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  22502. * @returns True is the vector "direction" is the same side than the plane normal.
  22503. */
  22504. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  22505. /**
  22506. * Calculates the distance to a point
  22507. * @param point point to calculate distance to
  22508. * @returns the signed distance (float) from the given point to the Plane.
  22509. */
  22510. signedDistanceTo(point: Vector3): number;
  22511. /**
  22512. * Creates a plane from an array
  22513. * @param array the array to create a plane from
  22514. * @returns a new Plane from the given array.
  22515. */
  22516. static FromArray(array: ArrayLike<number>): Plane;
  22517. /**
  22518. * Creates a plane from three points
  22519. * @param point1 point used to create the plane
  22520. * @param point2 point used to create the plane
  22521. * @param point3 point used to create the plane
  22522. * @returns a new Plane defined by the three given points.
  22523. */
  22524. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  22525. /**
  22526. * Creates a plane from an origin point and a normal
  22527. * @param origin origin of the plane to be constructed
  22528. * @param normal normal of the plane to be constructed
  22529. * @returns a new Plane the normal vector to this plane at the given origin point.
  22530. * Note : the vector "normal" is updated because normalized.
  22531. */
  22532. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  22533. /**
  22534. * Calculates the distance from a plane and a point
  22535. * @param origin origin of the plane to be constructed
  22536. * @param normal normal of the plane to be constructed
  22537. * @param point point to calculate distance to
  22538. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  22539. */
  22540. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  22541. }
  22542. /**
  22543. * Class used to represent a viewport on screen
  22544. */
  22545. class Viewport {
  22546. /** viewport left coordinate */
  22547. x: number;
  22548. /** viewport top coordinate */
  22549. y: number;
  22550. /**viewport width */
  22551. width: number;
  22552. /** viewport height */
  22553. height: number;
  22554. /**
  22555. * Creates a Viewport object located at (x, y) and sized (width, height)
  22556. * @param x defines viewport left coordinate
  22557. * @param y defines viewport top coordinate
  22558. * @param width defines the viewport width
  22559. * @param height defines the viewport height
  22560. */
  22561. constructor(
  22562. /** viewport left coordinate */
  22563. x: number,
  22564. /** viewport top coordinate */
  22565. y: number,
  22566. /**viewport width */
  22567. width: number,
  22568. /** viewport height */
  22569. height: number);
  22570. /**
  22571. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  22572. * @param renderWidthOrEngine defines either an engine or the rendering width
  22573. * @param renderHeight defines the rendering height
  22574. * @returns a new Viewport
  22575. */
  22576. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  22577. /**
  22578. * Returns a new Viewport copied from the current one
  22579. * @returns a new Viewport
  22580. */
  22581. clone(): Viewport;
  22582. }
  22583. /**
  22584. * Reprasents a camera frustum
  22585. */
  22586. class Frustum {
  22587. /**
  22588. * Gets the planes representing the frustum
  22589. * @param transform matrix to be applied to the returned planes
  22590. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  22591. */
  22592. static GetPlanes(transform: Matrix): Plane[];
  22593. /**
  22594. * Gets the near frustum plane transformed by the transform matrix
  22595. * @param transform transformation matrix to be applied to the resulting frustum plane
  22596. * @param frustumPlane the resuling frustum plane
  22597. */
  22598. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22599. /**
  22600. * Gets the far frustum plane transformed by the transform matrix
  22601. * @param transform transformation matrix to be applied to the resulting frustum plane
  22602. * @param frustumPlane the resuling frustum plane
  22603. */
  22604. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22605. /**
  22606. * Gets the left frustum plane transformed by the transform matrix
  22607. * @param transform transformation matrix to be applied to the resulting frustum plane
  22608. * @param frustumPlane the resuling frustum plane
  22609. */
  22610. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22611. /**
  22612. * Gets the right frustum plane transformed by the transform matrix
  22613. * @param transform transformation matrix to be applied to the resulting frustum plane
  22614. * @param frustumPlane the resuling frustum plane
  22615. */
  22616. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22617. /**
  22618. * Gets the top frustum plane transformed by the transform matrix
  22619. * @param transform transformation matrix to be applied to the resulting frustum plane
  22620. * @param frustumPlane the resuling frustum plane
  22621. */
  22622. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22623. /**
  22624. * Gets the bottom frustum plane transformed by the transform matrix
  22625. * @param transform transformation matrix to be applied to the resulting frustum plane
  22626. * @param frustumPlane the resuling frustum plane
  22627. */
  22628. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  22629. /**
  22630. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  22631. * @param transform transformation matrix to be applied to the resulting frustum planes
  22632. * @param frustumPlanes the resuling frustum planes
  22633. */
  22634. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  22635. }
  22636. /** Defines supported spaces */
  22637. enum Space {
  22638. /** Local (object) space */
  22639. LOCAL = 0,
  22640. /** World space */
  22641. WORLD = 1,
  22642. /** Bone space */
  22643. BONE = 2
  22644. }
  22645. /** Defines the 3 main axes */
  22646. class Axis {
  22647. /** X axis */
  22648. static X: Vector3;
  22649. /** Y axis */
  22650. static Y: Vector3;
  22651. /** Z axis */
  22652. static Z: Vector3;
  22653. }
  22654. /** Class used to represent a Bezier curve */
  22655. class BezierCurve {
  22656. /**
  22657. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  22658. * @param t defines the time
  22659. * @param x1 defines the left coordinate on X axis
  22660. * @param y1 defines the left coordinate on Y axis
  22661. * @param x2 defines the right coordinate on X axis
  22662. * @param y2 defines the right coordinate on Y axis
  22663. * @returns the interpolated value
  22664. */
  22665. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  22666. }
  22667. /**
  22668. * Defines potential orientation for back face culling
  22669. */
  22670. enum Orientation {
  22671. /**
  22672. * Clockwise
  22673. */
  22674. CW = 0,
  22675. /** Counter clockwise */
  22676. CCW = 1
  22677. }
  22678. /**
  22679. * Defines angle representation
  22680. */
  22681. class Angle {
  22682. private _radians;
  22683. /**
  22684. * Creates an Angle object of "radians" radians (float).
  22685. */
  22686. constructor(radians: number);
  22687. /**
  22688. * Get value in degrees
  22689. * @returns the Angle value in degrees (float)
  22690. */
  22691. degrees(): number;
  22692. /**
  22693. * Get value in radians
  22694. * @returns the Angle value in radians (float)
  22695. */
  22696. radians(): number;
  22697. /**
  22698. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  22699. * @param a defines first vector
  22700. * @param b defines second vector
  22701. * @returns a new Angle
  22702. */
  22703. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  22704. /**
  22705. * Gets a new Angle object from the given float in radians
  22706. * @param radians defines the angle value in radians
  22707. * @returns a new Angle
  22708. */
  22709. static FromRadians(radians: number): Angle;
  22710. /**
  22711. * Gets a new Angle object from the given float in degrees
  22712. * @param degrees defines the angle value in degrees
  22713. * @returns a new Angle
  22714. */
  22715. static FromDegrees(degrees: number): Angle;
  22716. }
  22717. /**
  22718. * This represents an arc in a 2d space.
  22719. */
  22720. class Arc2 {
  22721. /** Defines the start point of the arc */
  22722. startPoint: Vector2;
  22723. /** Defines the mid point of the arc */
  22724. midPoint: Vector2;
  22725. /** Defines the end point of the arc */
  22726. endPoint: Vector2;
  22727. /**
  22728. * Defines the center point of the arc.
  22729. */
  22730. centerPoint: Vector2;
  22731. /**
  22732. * Defines the radius of the arc.
  22733. */
  22734. radius: number;
  22735. /**
  22736. * Defines the angle of the arc (from mid point to end point).
  22737. */
  22738. angle: Angle;
  22739. /**
  22740. * Defines the start angle of the arc (from start point to middle point).
  22741. */
  22742. startAngle: Angle;
  22743. /**
  22744. * Defines the orientation of the arc (clock wise/counter clock wise).
  22745. */
  22746. orientation: Orientation;
  22747. /**
  22748. * Creates an Arc object from the three given points : start, middle and end.
  22749. * @param startPoint Defines the start point of the arc
  22750. * @param midPoint Defines the midlle point of the arc
  22751. * @param endPoint Defines the end point of the arc
  22752. */
  22753. constructor(
  22754. /** Defines the start point of the arc */
  22755. startPoint: Vector2,
  22756. /** Defines the mid point of the arc */
  22757. midPoint: Vector2,
  22758. /** Defines the end point of the arc */
  22759. endPoint: Vector2);
  22760. }
  22761. /**
  22762. * Represents a 2D path made up of multiple 2D points
  22763. */
  22764. class Path2 {
  22765. private _points;
  22766. private _length;
  22767. /**
  22768. * If the path start and end point are the same
  22769. */
  22770. closed: boolean;
  22771. /**
  22772. * Creates a Path2 object from the starting 2D coordinates x and y.
  22773. * @param x the starting points x value
  22774. * @param y the starting points y value
  22775. */
  22776. constructor(x: number, y: number);
  22777. /**
  22778. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  22779. * @param x the added points x value
  22780. * @param y the added points y value
  22781. * @returns the updated Path2.
  22782. */
  22783. addLineTo(x: number, y: number): Path2;
  22784. /**
  22785. * 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.
  22786. * @param midX middle point x value
  22787. * @param midY middle point y value
  22788. * @param endX end point x value
  22789. * @param endY end point y value
  22790. * @param numberOfSegments (default: 36)
  22791. * @returns the updated Path2.
  22792. */
  22793. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  22794. /**
  22795. * Closes the Path2.
  22796. * @returns the Path2.
  22797. */
  22798. close(): Path2;
  22799. /**
  22800. * Gets the sum of the distance between each sequential point in the path
  22801. * @returns the Path2 total length (float).
  22802. */
  22803. length(): number;
  22804. /**
  22805. * Gets the points which construct the path
  22806. * @returns the Path2 internal array of points.
  22807. */
  22808. getPoints(): Vector2[];
  22809. /**
  22810. * Retreives the point at the distance aways from the starting point
  22811. * @param normalizedLengthPosition the length along the path to retreive the point from
  22812. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  22813. */
  22814. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  22815. /**
  22816. * Creates a new path starting from an x and y position
  22817. * @param x starting x value
  22818. * @param y starting y value
  22819. * @returns a new Path2 starting at the coordinates (x, y).
  22820. */
  22821. static StartingAt(x: number, y: number): Path2;
  22822. }
  22823. /**
  22824. * Represents a 3D path made up of multiple 3D points
  22825. */
  22826. class Path3D {
  22827. /**
  22828. * an array of Vector3, the curve axis of the Path3D
  22829. */
  22830. path: Vector3[];
  22831. private _curve;
  22832. private _distances;
  22833. private _tangents;
  22834. private _normals;
  22835. private _binormals;
  22836. private _raw;
  22837. /**
  22838. * new Path3D(path, normal, raw)
  22839. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  22840. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  22841. * @param path an array of Vector3, the curve axis of the Path3D
  22842. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  22843. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  22844. */
  22845. constructor(
  22846. /**
  22847. * an array of Vector3, the curve axis of the Path3D
  22848. */
  22849. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  22850. /**
  22851. * Returns the Path3D array of successive Vector3 designing its curve.
  22852. * @returns the Path3D array of successive Vector3 designing its curve.
  22853. */
  22854. getCurve(): Vector3[];
  22855. /**
  22856. * Returns an array populated with tangent vectors on each Path3D curve point.
  22857. * @returns an array populated with tangent vectors on each Path3D curve point.
  22858. */
  22859. getTangents(): Vector3[];
  22860. /**
  22861. * Returns an array populated with normal vectors on each Path3D curve point.
  22862. * @returns an array populated with normal vectors on each Path3D curve point.
  22863. */
  22864. getNormals(): Vector3[];
  22865. /**
  22866. * Returns an array populated with binormal vectors on each Path3D curve point.
  22867. * @returns an array populated with binormal vectors on each Path3D curve point.
  22868. */
  22869. getBinormals(): Vector3[];
  22870. /**
  22871. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  22872. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  22873. */
  22874. getDistances(): number[];
  22875. /**
  22876. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  22877. * @param path path which all values are copied into the curves points
  22878. * @param firstNormal which should be projected onto the curve
  22879. * @returns the same object updated.
  22880. */
  22881. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  22882. private _compute;
  22883. private _getFirstNonNullVector;
  22884. private _getLastNonNullVector;
  22885. private _normalVector;
  22886. }
  22887. /**
  22888. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  22889. * A Curve3 is designed from a series of successive Vector3.
  22890. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  22891. */
  22892. class Curve3 {
  22893. private _points;
  22894. private _length;
  22895. /**
  22896. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  22897. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  22898. * @param v1 (Vector3) the control point
  22899. * @param v2 (Vector3) the end point of the Quadratic Bezier
  22900. * @param nbPoints (integer) the wanted number of points in the curve
  22901. * @returns the created Curve3
  22902. */
  22903. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  22904. /**
  22905. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  22906. * @param v0 (Vector3) the origin point of the Cubic Bezier
  22907. * @param v1 (Vector3) the first control point
  22908. * @param v2 (Vector3) the second control point
  22909. * @param v3 (Vector3) the end point of the Cubic Bezier
  22910. * @param nbPoints (integer) the wanted number of points in the curve
  22911. * @returns the created Curve3
  22912. */
  22913. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  22914. /**
  22915. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  22916. * @param p1 (Vector3) the origin point of the Hermite Spline
  22917. * @param t1 (Vector3) the tangent vector at the origin point
  22918. * @param p2 (Vector3) the end point of the Hermite Spline
  22919. * @param t2 (Vector3) the tangent vector at the end point
  22920. * @param nbPoints (integer) the wanted number of points in the curve
  22921. * @returns the created Curve3
  22922. */
  22923. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  22924. /**
  22925. * Returns a Curve3 object along a CatmullRom Spline curve :
  22926. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  22927. * @param nbPoints (integer) the wanted number of points between each curve control points
  22928. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  22929. * @returns the created Curve3
  22930. */
  22931. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  22932. /**
  22933. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  22934. * A Curve3 is designed from a series of successive Vector3.
  22935. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  22936. * @param points points which make up the curve
  22937. */
  22938. constructor(points: Vector3[]);
  22939. /**
  22940. * @returns the Curve3 stored array of successive Vector3
  22941. */
  22942. getPoints(): Vector3[];
  22943. /**
  22944. * @returns the computed length (float) of the curve.
  22945. */
  22946. length(): number;
  22947. /**
  22948. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  22949. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  22950. * curveA and curveB keep unchanged.
  22951. * @param curve the curve to continue from this curve
  22952. * @returns the newly constructed curve
  22953. */
  22954. continue(curve: Curve3): Curve3;
  22955. private _computeLength;
  22956. }
  22957. /**
  22958. * Contains position and normal vectors for a vertex
  22959. */
  22960. class PositionNormalVertex {
  22961. /** the position of the vertex (defaut: 0,0,0) */
  22962. position: Vector3;
  22963. /** the normal of the vertex (defaut: 0,1,0) */
  22964. normal: Vector3;
  22965. /**
  22966. * Creates a PositionNormalVertex
  22967. * @param position the position of the vertex (defaut: 0,0,0)
  22968. * @param normal the normal of the vertex (defaut: 0,1,0)
  22969. */
  22970. constructor(
  22971. /** the position of the vertex (defaut: 0,0,0) */
  22972. position?: Vector3,
  22973. /** the normal of the vertex (defaut: 0,1,0) */
  22974. normal?: Vector3);
  22975. /**
  22976. * Clones the PositionNormalVertex
  22977. * @returns the cloned PositionNormalVertex
  22978. */
  22979. clone(): PositionNormalVertex;
  22980. }
  22981. /**
  22982. * Contains position, normal and uv vectors for a vertex
  22983. */
  22984. class PositionNormalTextureVertex {
  22985. /** the position of the vertex (defaut: 0,0,0) */
  22986. position: Vector3;
  22987. /** the normal of the vertex (defaut: 0,1,0) */
  22988. normal: Vector3;
  22989. /** the uv of the vertex (default: 0,0) */
  22990. uv: Vector2;
  22991. /**
  22992. * Creates a PositionNormalTextureVertex
  22993. * @param position the position of the vertex (defaut: 0,0,0)
  22994. * @param normal the normal of the vertex (defaut: 0,1,0)
  22995. * @param uv the uv of the vertex (default: 0,0)
  22996. */
  22997. constructor(
  22998. /** the position of the vertex (defaut: 0,0,0) */
  22999. position?: Vector3,
  23000. /** the normal of the vertex (defaut: 0,1,0) */
  23001. normal?: Vector3,
  23002. /** the uv of the vertex (default: 0,0) */
  23003. uv?: Vector2);
  23004. /**
  23005. * Clones the PositionNormalTextureVertex
  23006. * @returns the cloned PositionNormalTextureVertex
  23007. */
  23008. clone(): PositionNormalTextureVertex;
  23009. }
  23010. /**
  23011. * @hidden
  23012. */
  23013. class Tmp {
  23014. static Color3: Color3[];
  23015. static Color4: Color4[];
  23016. static Vector2: Vector2[];
  23017. static Vector3: Vector3[];
  23018. static Vector4: Vector4[];
  23019. static Quaternion: Quaternion[];
  23020. static Matrix: Matrix[];
  23021. }
  23022. }
  23023. declare module BABYLON {
  23024. /**
  23025. * Class representing spherical polynomial coefficients to the 3rd degree
  23026. */
  23027. class SphericalPolynomial {
  23028. /**
  23029. * The x coefficients of the spherical polynomial
  23030. */
  23031. x: Vector3;
  23032. /**
  23033. * The y coefficients of the spherical polynomial
  23034. */
  23035. y: Vector3;
  23036. /**
  23037. * The z coefficients of the spherical polynomial
  23038. */
  23039. z: Vector3;
  23040. /**
  23041. * The xx coefficients of the spherical polynomial
  23042. */
  23043. xx: Vector3;
  23044. /**
  23045. * The yy coefficients of the spherical polynomial
  23046. */
  23047. yy: Vector3;
  23048. /**
  23049. * The zz coefficients of the spherical polynomial
  23050. */
  23051. zz: Vector3;
  23052. /**
  23053. * The xy coefficients of the spherical polynomial
  23054. */
  23055. xy: Vector3;
  23056. /**
  23057. * The yz coefficients of the spherical polynomial
  23058. */
  23059. yz: Vector3;
  23060. /**
  23061. * The zx coefficients of the spherical polynomial
  23062. */
  23063. zx: Vector3;
  23064. /**
  23065. * Adds an ambient color to the spherical polynomial
  23066. * @param color the color to add
  23067. */
  23068. addAmbient(color: Color3): void;
  23069. /**
  23070. * Scales the spherical polynomial by the given amount
  23071. * @param scale the amount to scale
  23072. */
  23073. scale(scale: number): void;
  23074. /**
  23075. * Gets the spherical polynomial from harmonics
  23076. * @param harmonics the spherical harmonics
  23077. * @returns the spherical polynomial
  23078. */
  23079. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23080. /**
  23081. * Constructs a spherical polynomial from an array.
  23082. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23083. * @returns the spherical polynomial
  23084. */
  23085. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23086. }
  23087. /**
  23088. * Class representing spherical harmonics coefficients to the 3rd degree
  23089. */
  23090. class SphericalHarmonics {
  23091. /**
  23092. * The l0,0 coefficients of the spherical harmonics
  23093. */
  23094. l00: Vector3;
  23095. /**
  23096. * The l1,-1 coefficients of the spherical harmonics
  23097. */
  23098. l1_1: Vector3;
  23099. /**
  23100. * The l1,0 coefficients of the spherical harmonics
  23101. */
  23102. l10: Vector3;
  23103. /**
  23104. * The l1,1 coefficients of the spherical harmonics
  23105. */
  23106. l11: Vector3;
  23107. /**
  23108. * The l2,-2 coefficients of the spherical harmonics
  23109. */
  23110. l2_2: Vector3;
  23111. /**
  23112. * The l2,-1 coefficients of the spherical harmonics
  23113. */
  23114. l2_1: Vector3;
  23115. /**
  23116. * The l2,0 coefficients of the spherical harmonics
  23117. */
  23118. l20: Vector3;
  23119. /**
  23120. * The l2,1 coefficients of the spherical harmonics
  23121. */
  23122. l21: Vector3;
  23123. /**
  23124. * The l2,2 coefficients of the spherical harmonics
  23125. */
  23126. lL22: Vector3;
  23127. /**
  23128. * Adds a light to the spherical harmonics
  23129. * @param direction the direction of the light
  23130. * @param color the color of the light
  23131. * @param deltaSolidAngle the delta solid angle of the light
  23132. */
  23133. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23134. /**
  23135. * Scales the spherical harmonics by the given amount
  23136. * @param scale the amount to scale
  23137. */
  23138. scale(scale: number): void;
  23139. /**
  23140. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23141. *
  23142. * ```
  23143. * E_lm = A_l * L_lm
  23144. * ```
  23145. *
  23146. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23147. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23148. * the scaling factors are given in equation 9.
  23149. */
  23150. convertIncidentRadianceToIrradiance(): void;
  23151. /**
  23152. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23153. *
  23154. * ```
  23155. * L = (1/pi) * E * rho
  23156. * ```
  23157. *
  23158. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23159. */
  23160. convertIrradianceToLambertianRadiance(): void;
  23161. /**
  23162. * Gets the spherical harmonics from polynomial
  23163. * @param polynomial the spherical polynomial
  23164. * @returns the spherical harmonics
  23165. */
  23166. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23167. /**
  23168. * Constructs a spherical harmonics from an array.
  23169. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23170. * @returns the spherical harmonics
  23171. */
  23172. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23173. }
  23174. }
  23175. declare module BABYLON {
  23176. /**
  23177. * Class used to store all common mesh properties
  23178. */
  23179. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23180. /** No occlusion */
  23181. static OCCLUSION_TYPE_NONE: number;
  23182. /** Occlusion set to optimisitic */
  23183. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23184. /** Occlusion set to strict */
  23185. static OCCLUSION_TYPE_STRICT: number;
  23186. /** Use an accurante occlusion algorithm */
  23187. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23188. /** Use a conservative occlusion algorithm */
  23189. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23190. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  23191. static readonly CULLINGSTRATEGY_STANDARD: number;
  23192. /** Culling strategy with bounding sphere only and then frustum culling */
  23193. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23194. /**
  23195. * No billboard
  23196. */
  23197. static readonly BILLBOARDMODE_NONE: number;
  23198. /** Billboard on X axis */
  23199. static readonly BILLBOARDMODE_X: number;
  23200. /** Billboard on Y axis */
  23201. static readonly BILLBOARDMODE_Y: number;
  23202. /** Billboard on Z axis */
  23203. static readonly BILLBOARDMODE_Z: number;
  23204. /** Billboard on all axes */
  23205. static readonly BILLBOARDMODE_ALL: number;
  23206. private _facetData;
  23207. /** Gets ot sets the culling strategy to use to find visible meshes */
  23208. cullingStrategy: number;
  23209. /**
  23210. * Gets the number of facets in the mesh
  23211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23212. */
  23213. readonly facetNb: number;
  23214. /**
  23215. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23217. */
  23218. partitioningSubdivisions: number;
  23219. /**
  23220. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23221. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23223. */
  23224. partitioningBBoxRatio: number;
  23225. /**
  23226. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23227. * Works only for updatable meshes.
  23228. * Doesn't work with multi-materials
  23229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23230. */
  23231. mustDepthSortFacets: boolean;
  23232. /**
  23233. * The location (Vector3) where the facet depth sort must be computed from.
  23234. * By default, the active camera position.
  23235. * Used only when facet depth sort is enabled
  23236. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23237. */
  23238. facetDepthSortFrom: Vector3;
  23239. /**
  23240. * gets a boolean indicating if facetData is enabled
  23241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23242. */
  23243. readonly isFacetDataEnabled: boolean;
  23244. /** @hidden */
  23245. _updateNonUniformScalingState(value: boolean): boolean;
  23246. /**
  23247. * An event triggered when this mesh collides with another one
  23248. */
  23249. onCollideObservable: Observable<AbstractMesh>;
  23250. private _onCollideObserver;
  23251. /** Set a function to call when this mesh collides with another one */
  23252. onCollide: () => void;
  23253. /**
  23254. * An event triggered when the collision's position changes
  23255. */
  23256. onCollisionPositionChangeObservable: Observable<Vector3>;
  23257. private _onCollisionPositionChangeObserver;
  23258. /** Set a function to call when the collision's position changes */
  23259. onCollisionPositionChange: () => void;
  23260. /**
  23261. * An event triggered when material is changed
  23262. */
  23263. onMaterialChangedObservable: Observable<AbstractMesh>;
  23264. /**
  23265. * Gets or sets the orientation for POV movement & rotation
  23266. */
  23267. definedFacingForward: boolean;
  23268. /** @hidden */
  23269. _occlusionQuery: Nullable<WebGLQuery>;
  23270. private _visibility;
  23271. /**
  23272. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23273. */
  23274. /**
  23275. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23276. */
  23277. visibility: number;
  23278. /** Gets or sets the alpha index used to sort transparent meshes
  23279. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23280. */
  23281. alphaIndex: number;
  23282. /**
  23283. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23284. */
  23285. isVisible: boolean;
  23286. /**
  23287. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23288. */
  23289. isPickable: boolean;
  23290. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23291. showSubMeshesBoundingBox: boolean;
  23292. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23293. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23294. */
  23295. isBlocker: boolean;
  23296. /**
  23297. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23298. */
  23299. enablePointerMoveEvents: boolean;
  23300. /**
  23301. * Specifies the rendering group id for this mesh (0 by default)
  23302. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23303. */
  23304. renderingGroupId: number;
  23305. private _material;
  23306. /** Gets or sets current material */
  23307. material: Nullable<Material>;
  23308. private _receiveShadows;
  23309. /**
  23310. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23311. * @see http://doc.babylonjs.com/babylon101/shadows
  23312. */
  23313. receiveShadows: boolean;
  23314. /** Defines color to use when rendering outline */
  23315. outlineColor: Color3;
  23316. /** Define width to use when rendering outline */
  23317. outlineWidth: number;
  23318. /** Defines color to use when rendering overlay */
  23319. overlayColor: Color3;
  23320. /** Defines alpha to use when rendering overlay */
  23321. overlayAlpha: number;
  23322. private _hasVertexAlpha;
  23323. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23324. hasVertexAlpha: boolean;
  23325. private _useVertexColors;
  23326. /** 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) */
  23327. useVertexColors: boolean;
  23328. private _computeBonesUsingShaders;
  23329. /**
  23330. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23331. */
  23332. computeBonesUsingShaders: boolean;
  23333. private _numBoneInfluencers;
  23334. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23335. numBoneInfluencers: number;
  23336. private _applyFog;
  23337. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23338. applyFog: boolean;
  23339. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23340. useOctreeForRenderingSelection: boolean;
  23341. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23342. useOctreeForPicking: boolean;
  23343. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23344. useOctreeForCollisions: boolean;
  23345. private _layerMask;
  23346. /**
  23347. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23348. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23349. */
  23350. layerMask: number;
  23351. /**
  23352. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23353. */
  23354. alwaysSelectAsActiveMesh: boolean;
  23355. /**
  23356. * Gets or sets the current action manager
  23357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23358. */
  23359. actionManager: Nullable<ActionManager>;
  23360. private _checkCollisions;
  23361. private _collisionMask;
  23362. private _collisionGroup;
  23363. /**
  23364. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23366. */
  23367. ellipsoid: Vector3;
  23368. /**
  23369. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23370. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23371. */
  23372. ellipsoidOffset: Vector3;
  23373. private _collider;
  23374. private _oldPositionForCollisions;
  23375. private _diffPositionForCollisions;
  23376. /**
  23377. * Gets or sets a collision mask used to mask collisions (default is -1).
  23378. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23379. */
  23380. collisionMask: number;
  23381. /**
  23382. * Gets or sets the current collision group mask (-1 by default).
  23383. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23384. */
  23385. collisionGroup: number;
  23386. /**
  23387. * Defines edge width used when edgesRenderer is enabled
  23388. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23389. */
  23390. edgesWidth: number;
  23391. /**
  23392. * Defines edge color used when edgesRenderer is enabled
  23393. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23394. */
  23395. edgesColor: Color4;
  23396. /** @hidden */
  23397. _edgesRenderer: Nullable<IEdgesRenderer>;
  23398. /** @hidden */
  23399. _masterMesh: Nullable<AbstractMesh>;
  23400. /** @hidden */
  23401. _boundingInfo: Nullable<BoundingInfo>;
  23402. /** @hidden */
  23403. _renderId: number;
  23404. /**
  23405. * Gets or sets the list of subMeshes
  23406. * @see http://doc.babylonjs.com/how_to/multi_materials
  23407. */
  23408. subMeshes: SubMesh[];
  23409. /** @hidden */
  23410. _intersectionsInProgress: AbstractMesh[];
  23411. /** @hidden */
  23412. _unIndexed: boolean;
  23413. /** @hidden */
  23414. _lightSources: Light[];
  23415. /** @hidden */
  23416. readonly _positions: Nullable<Vector3[]>;
  23417. /** @hidden */
  23418. _waitingActions: any;
  23419. /** @hidden */
  23420. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23421. private _skeleton;
  23422. /** @hidden */
  23423. _bonesTransformMatrices: Nullable<Float32Array>;
  23424. /**
  23425. * Gets or sets a skeleton to apply skining transformations
  23426. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23427. */
  23428. skeleton: Nullable<Skeleton>;
  23429. /**
  23430. * An event triggered when the mesh is rebuilt.
  23431. */
  23432. onRebuildObservable: Observable<AbstractMesh>;
  23433. /**
  23434. * Creates a new AbstractMesh
  23435. * @param name defines the name of the mesh
  23436. * @param scene defines the hosting scene
  23437. */
  23438. constructor(name: string, scene?: Nullable<Scene>);
  23439. /**
  23440. * Returns the string "AbstractMesh"
  23441. * @returns "AbstractMesh"
  23442. */
  23443. getClassName(): string;
  23444. /**
  23445. * Gets a string representation of the current mesh
  23446. * @param fullDetails defines a boolean indicating if full details must be included
  23447. * @returns a string representation of the current mesh
  23448. */
  23449. toString(fullDetails?: boolean): string;
  23450. /** @hidden */
  23451. _rebuild(): void;
  23452. /** @hidden */
  23453. _resyncLightSources(): void;
  23454. /** @hidden */
  23455. _resyncLighSource(light: Light): void;
  23456. /** @hidden */
  23457. _unBindEffect(): void;
  23458. /** @hidden */
  23459. _removeLightSource(light: Light): void;
  23460. private _markSubMeshesAsDirty;
  23461. /** @hidden */
  23462. _markSubMeshesAsLightDirty(): void;
  23463. /** @hidden */
  23464. _markSubMeshesAsAttributesDirty(): void;
  23465. /** @hidden */
  23466. _markSubMeshesAsMiscDirty(): void;
  23467. /**
  23468. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23469. */
  23470. scaling: Vector3;
  23471. /**
  23472. * Returns true if the mesh is blocked. Implemented by child classes
  23473. */
  23474. readonly isBlocked: boolean;
  23475. /**
  23476. * Returns the mesh itself by default. Implemented by child classes
  23477. * @param camera defines the camera to use to pick the right LOD level
  23478. * @returns the currentAbstractMesh
  23479. */
  23480. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23481. /**
  23482. * Returns 0 by default. Implemented by child classes
  23483. * @returns an integer
  23484. */
  23485. getTotalVertices(): number;
  23486. /**
  23487. * Returns null by default. Implemented by child classes
  23488. * @returns null
  23489. */
  23490. getIndices(): Nullable<IndicesArray>;
  23491. /**
  23492. * Returns the array of the requested vertex data kind. Implemented by child classes
  23493. * @param kind defines the vertex data kind to use
  23494. * @returns null
  23495. */
  23496. getVerticesData(kind: string): Nullable<FloatArray>;
  23497. /**
  23498. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23499. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23500. * Note that a new underlying VertexBuffer object is created each call.
  23501. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23502. * @param kind defines vertex data kind:
  23503. * * BABYLON.VertexBuffer.PositionKind
  23504. * * BABYLON.VertexBuffer.UVKind
  23505. * * BABYLON.VertexBuffer.UV2Kind
  23506. * * BABYLON.VertexBuffer.UV3Kind
  23507. * * BABYLON.VertexBuffer.UV4Kind
  23508. * * BABYLON.VertexBuffer.UV5Kind
  23509. * * BABYLON.VertexBuffer.UV6Kind
  23510. * * BABYLON.VertexBuffer.ColorKind
  23511. * * BABYLON.VertexBuffer.MatricesIndicesKind
  23512. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23513. * * BABYLON.VertexBuffer.MatricesWeightsKind
  23514. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23515. * @param data defines the data source
  23516. * @param updatable defines if the data must be flagged as updatable (or static)
  23517. * @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
  23518. * @returns the current mesh
  23519. */
  23520. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23521. /**
  23522. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23523. * If the mesh has no geometry, it is simply returned as it is.
  23524. * @param kind defines vertex data kind:
  23525. * * BABYLON.VertexBuffer.PositionKind
  23526. * * BABYLON.VertexBuffer.UVKind
  23527. * * BABYLON.VertexBuffer.UV2Kind
  23528. * * BABYLON.VertexBuffer.UV3Kind
  23529. * * BABYLON.VertexBuffer.UV4Kind
  23530. * * BABYLON.VertexBuffer.UV5Kind
  23531. * * BABYLON.VertexBuffer.UV6Kind
  23532. * * BABYLON.VertexBuffer.ColorKind
  23533. * * BABYLON.VertexBuffer.MatricesIndicesKind
  23534. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  23535. * * BABYLON.VertexBuffer.MatricesWeightsKind
  23536. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  23537. * @param data defines the data source
  23538. * @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
  23539. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23540. * @returns the current mesh
  23541. */
  23542. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23543. /**
  23544. * Sets the mesh indices,
  23545. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23546. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23547. * @param totalVertices Defines the total number of vertices
  23548. * @returns the current mesh
  23549. */
  23550. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23551. /**
  23552. * Gets a boolean indicating if specific vertex data is present
  23553. * @param kind defines the vertex data kind to use
  23554. * @returns true is data kind is present
  23555. */
  23556. isVerticesDataPresent(kind: string): boolean;
  23557. /**
  23558. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23559. * @returns a BoundingInfo
  23560. */
  23561. getBoundingInfo(): BoundingInfo;
  23562. /**
  23563. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23564. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23565. * @returns the current mesh
  23566. */
  23567. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23568. /**
  23569. * Overwrite the current bounding info
  23570. * @param boundingInfo defines the new bounding info
  23571. * @returns the current mesh
  23572. */
  23573. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23574. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23575. readonly useBones: boolean;
  23576. /** @hidden */
  23577. _preActivate(): void;
  23578. /** @hidden */
  23579. _preActivateForIntermediateRendering(renderId: number): void;
  23580. /** @hidden */
  23581. _activate(renderId: number): void;
  23582. /**
  23583. * Gets the current world matrix
  23584. * @returns a Matrix
  23585. */
  23586. getWorldMatrix(): Matrix;
  23587. /** @hidden */
  23588. _getWorldMatrixDeterminant(): number;
  23589. /**
  23590. * Perform relative position change from the point of view of behind the front of the mesh.
  23591. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23592. * Supports definition of mesh facing forward or backward
  23593. * @param amountRight defines the distance on the right axis
  23594. * @param amountUp defines the distance on the up axis
  23595. * @param amountForward defines the distance on the forward axis
  23596. * @returns the current mesh
  23597. */
  23598. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23599. /**
  23600. * Calculate relative position change from the point of view of behind the front of the mesh.
  23601. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23602. * Supports definition of mesh facing forward or backward
  23603. * @param amountRight defines the distance on the right axis
  23604. * @param amountUp defines the distance on the up axis
  23605. * @param amountForward defines the distance on the forward axis
  23606. * @returns the new displacement vector
  23607. */
  23608. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23609. /**
  23610. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23611. * Supports definition of mesh facing forward or backward
  23612. * @param flipBack defines the flip
  23613. * @param twirlClockwise defines the twirl
  23614. * @param tiltRight defines the tilt
  23615. * @returns the current mesh
  23616. */
  23617. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23618. /**
  23619. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23620. * Supports definition of mesh facing forward or backward.
  23621. * @param flipBack defines the flip
  23622. * @param twirlClockwise defines the twirl
  23623. * @param tiltRight defines the tilt
  23624. * @returns the new rotation vector
  23625. */
  23626. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23627. /**
  23628. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23629. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23630. * @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
  23631. * @returns the new bounding vectors
  23632. */
  23633. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23634. min: Vector3;
  23635. max: Vector3;
  23636. };
  23637. /** @hidden */
  23638. _updateBoundingInfo(): AbstractMesh;
  23639. /** @hidden */
  23640. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  23641. /** @hidden */
  23642. protected _afterComputeWorldMatrix(): void;
  23643. /**
  23644. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23645. * A mesh is in the frustum if its bounding box intersects the frustum
  23646. * @param frustumPlanes defines the frustum to test
  23647. * @returns true if the mesh is in the frustum planes
  23648. */
  23649. isInFrustum(frustumPlanes: Plane[]): boolean;
  23650. /**
  23651. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23652. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23653. * @param frustumPlanes defines the frustum to test
  23654. * @returns true if the mesh is completely in the frustum planes
  23655. */
  23656. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23657. /**
  23658. * True if the mesh intersects another mesh or a SolidParticle object
  23659. * @param mesh defines a target mesh or SolidParticle to test
  23660. * @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)
  23661. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23662. * @returns true if there is an intersection
  23663. */
  23664. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23665. /**
  23666. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23667. * @param point defines the point to test
  23668. * @returns true if there is an intersection
  23669. */
  23670. intersectsPoint(point: Vector3): boolean;
  23671. /**
  23672. * Gets the position of the current mesh in camera space
  23673. * @param camera defines the camera to use
  23674. * @returns a position
  23675. */
  23676. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  23677. /**
  23678. * Returns the distance from the mesh to the active camera
  23679. * @param camera defines the camera to use
  23680. * @returns the distance
  23681. */
  23682. getDistanceToCamera(camera?: Nullable<Camera>): number;
  23683. /**
  23684. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23686. */
  23687. checkCollisions: boolean;
  23688. /**
  23689. * Gets Collider object used to compute collisions (not physics)
  23690. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23691. */
  23692. readonly collider: Collider;
  23693. /**
  23694. * Move the mesh using collision engine
  23695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23696. * @param displacement defines the requested displacement vector
  23697. * @returns the current mesh
  23698. */
  23699. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23700. private _onCollisionPositionChange;
  23701. /** @hidden */
  23702. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23703. /** @hidden */
  23704. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23705. /** @hidden */
  23706. _checkCollision(collider: Collider): AbstractMesh;
  23707. /** @hidden */
  23708. _generatePointsArray(): boolean;
  23709. /**
  23710. * Checks if the passed Ray intersects with the mesh
  23711. * @param ray defines the ray to use
  23712. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23713. * @returns the picking info
  23714. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23715. */
  23716. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23717. /**
  23718. * Clones the current mesh
  23719. * @param name defines the mesh name
  23720. * @param newParent defines the new mesh parent
  23721. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23722. * @returns the new mesh
  23723. */
  23724. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23725. /**
  23726. * Disposes all the submeshes of the current meshnp
  23727. * @returns the current mesh
  23728. */
  23729. releaseSubMeshes(): AbstractMesh;
  23730. /**
  23731. * Releases resources associated with this abstract mesh.
  23732. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23733. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23734. */
  23735. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23736. /**
  23737. * Adds the passed mesh as a child to the current mesh
  23738. * @param mesh defines the child mesh
  23739. * @returns the current mesh
  23740. */
  23741. addChild(mesh: AbstractMesh): AbstractMesh;
  23742. /**
  23743. * Removes the passed mesh from the current mesh children list
  23744. * @param mesh defines the child mesh
  23745. * @returns the current mesh
  23746. */
  23747. removeChild(mesh: AbstractMesh): AbstractMesh;
  23748. /** @hidden */
  23749. private _initFacetData;
  23750. /**
  23751. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23752. * This method can be called within the render loop.
  23753. * 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
  23754. * @returns the current mesh
  23755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23756. */
  23757. updateFacetData(): AbstractMesh;
  23758. /**
  23759. * Returns the facetLocalNormals array.
  23760. * The normals are expressed in the mesh local spac
  23761. * @returns an array of Vector3
  23762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23763. */
  23764. getFacetLocalNormals(): Vector3[];
  23765. /**
  23766. * Returns the facetLocalPositions array.
  23767. * The facet positions are expressed in the mesh local space
  23768. * @returns an array of Vector3
  23769. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23770. */
  23771. getFacetLocalPositions(): Vector3[];
  23772. /**
  23773. * Returns the facetLocalPartioning array
  23774. * @returns an array of array of numbers
  23775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23776. */
  23777. getFacetLocalPartitioning(): number[][];
  23778. /**
  23779. * Returns the i-th facet position in the world system.
  23780. * This method allocates a new Vector3 per call
  23781. * @param i defines the facet index
  23782. * @returns a new Vector3
  23783. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23784. */
  23785. getFacetPosition(i: number): Vector3;
  23786. /**
  23787. * Sets the reference Vector3 with the i-th facet position in the world system
  23788. * @param i defines the facet index
  23789. * @param ref defines the target vector
  23790. * @returns the current mesh
  23791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23792. */
  23793. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23794. /**
  23795. * Returns the i-th facet normal in the world system.
  23796. * This method allocates a new Vector3 per call
  23797. * @param i defines the facet index
  23798. * @returns a new Vector3
  23799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23800. */
  23801. getFacetNormal(i: number): Vector3;
  23802. /**
  23803. * Sets the reference Vector3 with the i-th facet normal in the world system
  23804. * @param i defines the facet index
  23805. * @param ref defines the target vector
  23806. * @returns the current mesh
  23807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23808. */
  23809. getFacetNormalToRef(i: number, ref: Vector3): this;
  23810. /**
  23811. * 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)
  23812. * @param x defines x coordinate
  23813. * @param y defines y coordinate
  23814. * @param z defines z coordinate
  23815. * @returns the array of facet indexes
  23816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23817. */
  23818. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23819. /**
  23820. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23821. * @param projected sets as the (x,y,z) world projection on the facet
  23822. * @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
  23823. * @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
  23824. * @param x defines x coordinate
  23825. * @param y defines y coordinate
  23826. * @param z defines z coordinate
  23827. * @returns the face index if found (or null instead)
  23828. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23829. */
  23830. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23831. /**
  23832. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23833. * @param projected sets as the (x,y,z) local projection on the facet
  23834. * @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
  23835. * @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
  23836. * @param x defines x coordinate
  23837. * @param y defines y coordinate
  23838. * @param z defines z coordinate
  23839. * @returns the face index if found (or null instead)
  23840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23841. */
  23842. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23843. /**
  23844. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23845. * @returns the parameters
  23846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23847. */
  23848. getFacetDataParameters(): any;
  23849. /**
  23850. * Disables the feature FacetData and frees the related memory
  23851. * @returns the current mesh
  23852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23853. */
  23854. disableFacetData(): AbstractMesh;
  23855. /**
  23856. * Updates the AbstractMesh indices array
  23857. * @param indices defines the data source
  23858. * @returns the current mesh
  23859. */
  23860. updateIndices(indices: IndicesArray): AbstractMesh;
  23861. /**
  23862. * Creates new normals data for the mesh
  23863. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23864. * @returns the current mesh
  23865. */
  23866. createNormals(updatable: boolean): AbstractMesh;
  23867. /**
  23868. * Align the mesh with a normal
  23869. * @param normal defines the normal to use
  23870. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23871. * @returns the current mesh
  23872. */
  23873. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23874. /** @hidden */
  23875. _checkOcclusionQuery(): boolean;
  23876. }
  23877. }
  23878. declare module BABYLON {
  23879. /**
  23880. * Class used to store data that will be store in GPU memory
  23881. */
  23882. class Buffer {
  23883. private _engine;
  23884. private _buffer;
  23885. /** @hidden */
  23886. _data: Nullable<DataArray>;
  23887. private _updatable;
  23888. private _instanced;
  23889. /**
  23890. * Gets the byte stride.
  23891. */
  23892. readonly byteStride: number;
  23893. /**
  23894. * Constructor
  23895. * @param engine the engine
  23896. * @param data the data to use for this buffer
  23897. * @param updatable whether the data is updatable
  23898. * @param stride the stride (optional)
  23899. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  23900. * @param instanced whether the buffer is instanced (optional)
  23901. * @param useBytes set to true if the stride in in bytes (optional)
  23902. */
  23903. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  23904. /**
  23905. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  23906. * @param kind defines the vertex buffer kind (position, normal, etc.)
  23907. * @param offset defines offset in the buffer (0 by default)
  23908. * @param size defines the size in floats of attributes (position is 3 for instance)
  23909. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  23910. * @param instanced defines if the vertex buffer contains indexed data
  23911. * @param useBytes defines if the offset and stride are in bytes
  23912. * @returns the new vertex buffer
  23913. */
  23914. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  23915. /**
  23916. * Gets a boolean indicating if the Buffer is updatable?
  23917. * @returns true if the buffer is updatable
  23918. */
  23919. isUpdatable(): boolean;
  23920. /**
  23921. * Gets current buffer's data
  23922. * @returns a DataArray or null
  23923. */
  23924. getData(): Nullable<DataArray>;
  23925. /**
  23926. * Gets underlying native buffer
  23927. * @returns underlying native buffer
  23928. */
  23929. getBuffer(): Nullable<WebGLBuffer>;
  23930. /**
  23931. * Gets the stride in float32 units (i.e. byte stride / 4).
  23932. * May not be an integer if the byte stride is not divisible by 4.
  23933. * DEPRECATED. Use byteStride instead.
  23934. * @returns the stride in float32 units
  23935. */
  23936. getStrideSize(): number;
  23937. /**
  23938. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  23939. * @param data defines the data to store
  23940. */
  23941. create(data?: Nullable<DataArray>): void;
  23942. /** @hidden */
  23943. _rebuild(): void;
  23944. /**
  23945. * Update current buffer data
  23946. * @param data defines the data to store
  23947. */
  23948. update(data: DataArray): void;
  23949. /**
  23950. * Updates the data directly.
  23951. * @param data the new data
  23952. * @param offset the new offset
  23953. * @param vertexCount the vertex count (optional)
  23954. * @param useBytes set to true if the offset is in bytes
  23955. */
  23956. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  23957. /**
  23958. * Release all resources
  23959. */
  23960. dispose(): void;
  23961. }
  23962. }
  23963. declare module BABYLON {
  23964. /**
  23965. * Class for building Constructive Solid Geometry
  23966. */
  23967. class CSG {
  23968. private polygons;
  23969. /**
  23970. * The world matrix
  23971. */
  23972. matrix: Matrix;
  23973. /**
  23974. * Stores the position
  23975. */
  23976. position: Vector3;
  23977. /**
  23978. * Stores the rotation
  23979. */
  23980. rotation: Vector3;
  23981. /**
  23982. * Stores the rotation quaternion
  23983. */
  23984. rotationQuaternion: Nullable<Quaternion>;
  23985. /**
  23986. * Stores the scaling vector
  23987. */
  23988. scaling: Vector3;
  23989. /**
  23990. * Convert the BABYLON.Mesh to BABYLON.CSG
  23991. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  23992. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  23993. */
  23994. static FromMesh(mesh: Mesh): CSG;
  23995. /**
  23996. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  23997. * @param polygons Polygons used to construct a BABYLON.CSG solid
  23998. */
  23999. private static FromPolygons;
  24000. /**
  24001. * Clones, or makes a deep copy, of the BABYLON.CSG
  24002. * @returns A new BABYLON.CSG
  24003. */
  24004. clone(): CSG;
  24005. /**
  24006. * Unions this CSG with another CSG
  24007. * @param csg The CSG to union against this CSG
  24008. * @returns The unioned CSG
  24009. */
  24010. union(csg: CSG): CSG;
  24011. /**
  24012. * Unions this CSG with another CSG in place
  24013. * @param csg The CSG to union against this CSG
  24014. */
  24015. unionInPlace(csg: CSG): void;
  24016. /**
  24017. * Subtracts this CSG with another CSG
  24018. * @param csg The CSG to subtract against this CSG
  24019. * @returns A new BABYLON.CSG
  24020. */
  24021. subtract(csg: CSG): CSG;
  24022. /**
  24023. * Subtracts this CSG with another CSG in place
  24024. * @param csg The CSG to subtact against this CSG
  24025. */
  24026. subtractInPlace(csg: CSG): void;
  24027. /**
  24028. * Intersect this CSG with another CSG
  24029. * @param csg The CSG to intersect against this CSG
  24030. * @returns A new BABYLON.CSG
  24031. */
  24032. intersect(csg: CSG): CSG;
  24033. /**
  24034. * Intersects this CSG with another CSG in place
  24035. * @param csg The CSG to intersect against this CSG
  24036. */
  24037. intersectInPlace(csg: CSG): void;
  24038. /**
  24039. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24040. * not modified.
  24041. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24042. */
  24043. inverse(): CSG;
  24044. /**
  24045. * Inverses the BABYLON.CSG in place
  24046. */
  24047. inverseInPlace(): void;
  24048. /**
  24049. * This is used to keep meshes transformations so they can be restored
  24050. * when we build back a Babylon Mesh
  24051. * NB : All CSG operations are performed in world coordinates
  24052. * @param csg The BABYLON.CSG to copy the transform attributes from
  24053. * @returns This BABYLON.CSG
  24054. */
  24055. copyTransformAttributes(csg: CSG): CSG;
  24056. /**
  24057. * Build Raw mesh from CSG
  24058. * Coordinates here are in world space
  24059. * @param name The name of the mesh geometry
  24060. * @param scene The BABYLON.Scene
  24061. * @param keepSubMeshes Specifies if the submeshes should be kept
  24062. * @returns A new BABYLON.Mesh
  24063. */
  24064. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24065. /**
  24066. * Build Mesh from CSG taking material and transforms into account
  24067. * @param name The name of the BABYLON.Mesh
  24068. * @param material The material of the BABYLON.Mesh
  24069. * @param scene The BABYLON.Scene
  24070. * @param keepSubMeshes Specifies if submeshes should be kept
  24071. * @returns The new BABYLON.Mesh
  24072. */
  24073. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24074. }
  24075. }
  24076. declare module BABYLON {
  24077. /**
  24078. * Class used to store geometry data (vertex buffers + index buffer)
  24079. */
  24080. class Geometry implements IGetSetVerticesData {
  24081. /**
  24082. * Gets or sets the unique ID of the geometry
  24083. */
  24084. id: string;
  24085. /**
  24086. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24087. */
  24088. delayLoadState: number;
  24089. /**
  24090. * Gets the file containing the data to load when running in delay load state
  24091. */
  24092. delayLoadingFile: Nullable<string>;
  24093. /**
  24094. * Callback called when the geometry is updated
  24095. */
  24096. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24097. private _scene;
  24098. private _engine;
  24099. private _meshes;
  24100. private _totalVertices;
  24101. /** @hidden */
  24102. _indices: IndicesArray;
  24103. /** @hidden */
  24104. _vertexBuffers: {
  24105. [key: string]: VertexBuffer;
  24106. };
  24107. private _isDisposed;
  24108. private _extend;
  24109. private _boundingBias;
  24110. /** @hidden */
  24111. _delayInfo: Array<string>;
  24112. private _indexBuffer;
  24113. private _indexBufferIsUpdatable;
  24114. /** @hidden */
  24115. _boundingInfo: Nullable<BoundingInfo>;
  24116. /** @hidden */
  24117. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24118. /** @hidden */
  24119. _softwareSkinningFrameId: number;
  24120. private _vertexArrayObjects;
  24121. private _updatable;
  24122. /** @hidden */
  24123. _positions: Nullable<Vector3[]>;
  24124. /**
  24125. * 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
  24126. */
  24127. /**
  24128. * 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
  24129. */
  24130. boundingBias: Vector2;
  24131. /**
  24132. * Static function used to attach a new empty geometry to a mesh
  24133. * @param mesh defines the mesh to attach the geometry to
  24134. * @returns the new {BABYLON.Geometry}
  24135. */
  24136. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24137. /**
  24138. * Creates a new geometry
  24139. * @param id defines the unique ID
  24140. * @param scene defines the hosting scene
  24141. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  24142. * @param updatable defines if geometry must be updatable (false by default)
  24143. * @param mesh defines the mesh that will be associated with the geometry
  24144. */
  24145. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24146. /**
  24147. * Gets the current extend of the geometry
  24148. */
  24149. readonly extend: {
  24150. minimum: Vector3;
  24151. maximum: Vector3;
  24152. };
  24153. /**
  24154. * Gets the hosting scene
  24155. * @returns the hosting {BABYLON.Scene}
  24156. */
  24157. getScene(): Scene;
  24158. /**
  24159. * Gets the hosting engine
  24160. * @returns the hosting {BABYLON.Engine}
  24161. */
  24162. getEngine(): Engine;
  24163. /**
  24164. * Defines if the geometry is ready to use
  24165. * @returns true if the geometry is ready to be used
  24166. */
  24167. isReady(): boolean;
  24168. /**
  24169. * Gets a value indicating that the geometry should not be serialized
  24170. */
  24171. readonly doNotSerialize: boolean;
  24172. /** @hidden */
  24173. _rebuild(): void;
  24174. /**
  24175. * Affects all geometry data in one call
  24176. * @param vertexData defines the geometry data
  24177. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24178. */
  24179. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24180. /**
  24181. * Set specific vertex data
  24182. * @param kind defines the data kind (Position, normal, etc...)
  24183. * @param data defines the vertex data to use
  24184. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24185. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24186. */
  24187. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24188. /**
  24189. * Removes a specific vertex data
  24190. * @param kind defines the data kind (Position, normal, etc...)
  24191. */
  24192. removeVerticesData(kind: string): void;
  24193. /**
  24194. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24195. * @param buffer defines the vertex buffer to use
  24196. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24197. */
  24198. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24199. /**
  24200. * Update a specific vertex buffer
  24201. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  24202. * It will do nothing if the buffer is not updatable
  24203. * @param kind defines the data kind (Position, normal, etc...)
  24204. * @param data defines the data to use
  24205. * @param offset defines the offset in the target buffer where to store the data
  24206. * @param useBytes set to true if the offset is in bytes
  24207. */
  24208. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24209. /**
  24210. * Update a specific vertex buffer
  24211. * This function will create a new buffer if the current one is not updatable
  24212. * @param kind defines the data kind (Position, normal, etc...)
  24213. * @param data defines the data to use
  24214. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24215. */
  24216. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24217. private _updateBoundingInfo;
  24218. /** @hidden */
  24219. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  24220. /**
  24221. * Gets total number of vertices
  24222. * @returns the total number of vertices
  24223. */
  24224. getTotalVertices(): number;
  24225. /**
  24226. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24227. * @param kind defines the data kind (Position, normal, etc...)
  24228. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24229. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24230. * @returns a float array containing vertex data
  24231. */
  24232. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24233. /**
  24234. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24235. * @param kind defines the data kind (Position, normal, etc...)
  24236. * @returns true if the vertex buffer with the specified kind is updatable
  24237. */
  24238. isVertexBufferUpdatable(kind: string): boolean;
  24239. /**
  24240. * Gets a specific vertex buffer
  24241. * @param kind defines the data kind (Position, normal, etc...)
  24242. * @returns a {BABYLON.VertexBuffer}
  24243. */
  24244. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24245. /**
  24246. * Returns all vertex buffers
  24247. * @return an object holding all vertex buffers indexed by kind
  24248. */
  24249. getVertexBuffers(): Nullable<{
  24250. [key: string]: VertexBuffer;
  24251. }>;
  24252. /**
  24253. * Gets a boolean indicating if specific vertex buffer is present
  24254. * @param kind defines the data kind (Position, normal, etc...)
  24255. * @returns true if data is present
  24256. */
  24257. isVerticesDataPresent(kind: string): boolean;
  24258. /**
  24259. * Gets a list of all attached data kinds (Position, normal, etc...)
  24260. * @returns a list of string containing all kinds
  24261. */
  24262. getVerticesDataKinds(): string[];
  24263. /**
  24264. * Update index buffer
  24265. * @param indices defines the indices to store in the index buffer
  24266. * @param offset defines the offset in the target buffer where to store the data
  24267. */
  24268. updateIndices(indices: IndicesArray, offset?: number): void;
  24269. /**
  24270. * Creates a new index buffer
  24271. * @param indices defines the indices to store in the index buffer
  24272. * @param totalVertices defines the total number of vertices (could be null)
  24273. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24274. */
  24275. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24276. /**
  24277. * Return the total number of indices
  24278. * @returns the total number of indices
  24279. */
  24280. getTotalIndices(): number;
  24281. /**
  24282. * Gets the index buffer array
  24283. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24284. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24285. * @returns the index buffer array
  24286. */
  24287. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24288. /**
  24289. * Gets the index buffer
  24290. * @return the index buffer
  24291. */
  24292. getIndexBuffer(): Nullable<WebGLBuffer>;
  24293. /** @hidden */
  24294. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24295. /**
  24296. * Release the associated resources for a specific mesh
  24297. * @param mesh defines the source mesh
  24298. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24299. */
  24300. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24301. /**
  24302. * Apply current geometry to a given mesh
  24303. * @param mesh defines the mesh to apply geometry to
  24304. */
  24305. applyToMesh(mesh: Mesh): void;
  24306. private _updateExtend;
  24307. private _applyToMesh;
  24308. private notifyUpdate;
  24309. /**
  24310. * Load the geometry if it was flagged as delay loaded
  24311. * @param scene defines the hosting scene
  24312. * @param onLoaded defines a callback called when the geometry is loaded
  24313. */
  24314. load(scene: Scene, onLoaded?: () => void): void;
  24315. private _queueLoad;
  24316. /**
  24317. * Invert the geometry to move from a right handed system to a left handed one.
  24318. */
  24319. toLeftHanded(): void;
  24320. /** @hidden */
  24321. _resetPointsArrayCache(): void;
  24322. /** @hidden */
  24323. _generatePointsArray(): boolean;
  24324. /**
  24325. * Gets a value indicating if the geometry is disposed
  24326. * @returns true if the geometry was disposed
  24327. */
  24328. isDisposed(): boolean;
  24329. private _disposeVertexArrayObjects;
  24330. /**
  24331. * Free all associated resources
  24332. */
  24333. dispose(): void;
  24334. /**
  24335. * Clone the current geometry into a new geometry
  24336. * @param id defines the unique ID of the new geometry
  24337. * @returns a new geometry object
  24338. */
  24339. copy(id: string): Geometry;
  24340. /**
  24341. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24342. * @return a JSON representation of the current geometry data (without the vertices data)
  24343. */
  24344. serialize(): any;
  24345. private toNumberArray;
  24346. /**
  24347. * Serialize all vertices data into a JSON oject
  24348. * @returns a JSON representation of the current geometry data
  24349. */
  24350. serializeVerticeData(): any;
  24351. /**
  24352. * Extracts a clone of a mesh geometry
  24353. * @param mesh defines the source mesh
  24354. * @param id defines the unique ID of the new geometry object
  24355. * @returns the new geometry object
  24356. */
  24357. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24358. /**
  24359. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24360. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24361. * Be aware Math.random() could cause collisions, but:
  24362. * "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"
  24363. * @returns a string containing a new GUID
  24364. */
  24365. static RandomId(): string;
  24366. /** @hidden */
  24367. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24368. private static _CleanMatricesWeights;
  24369. /**
  24370. * Create a new geometry from persisted data (Using .babylon file format)
  24371. * @param parsedVertexData defines the persisted data
  24372. * @param scene defines the hosting scene
  24373. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24374. * @returns the new geometry object
  24375. */
  24376. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24377. }
  24378. /**
  24379. * Abstract class used to provide common services for all typed geometries
  24380. * @hidden
  24381. */
  24382. class _PrimitiveGeometry extends Geometry {
  24383. private _canBeRegenerated;
  24384. private _beingRegenerated;
  24385. /**
  24386. * Creates a new typed geometry
  24387. * @param id defines the unique ID of the geometry
  24388. * @param scene defines the hosting scene
  24389. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24390. * @param mesh defines the hosting mesh (can be null)
  24391. */
  24392. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  24393. /**
  24394. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  24395. * @returns true if the geometry can be regenerated
  24396. */
  24397. canBeRegenerated(): boolean;
  24398. /**
  24399. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  24400. */
  24401. regenerate(): void;
  24402. /**
  24403. * Clone the geometry
  24404. * @param id defines the unique ID of the new geometry
  24405. * @returns the new geometry
  24406. */
  24407. asNewGeometry(id: string): Geometry;
  24408. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24409. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  24410. /** @hidden */
  24411. _regenerateVertexData(): VertexData;
  24412. copy(id: string): Geometry;
  24413. serialize(): any;
  24414. }
  24415. /**
  24416. * Creates a ribbon geometry
  24417. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  24418. */
  24419. class RibbonGeometry extends _PrimitiveGeometry {
  24420. /**
  24421. * Defines the array of paths to use
  24422. */
  24423. pathArray: Vector3[][];
  24424. /**
  24425. * Defines if the last and first points of each path in your pathArray must be joined
  24426. */
  24427. closeArray: boolean;
  24428. /**
  24429. * Defines if the last and first points of each path in your pathArray must be joined
  24430. */
  24431. closePath: boolean;
  24432. /**
  24433. * Defines the offset between points
  24434. */
  24435. offset: number;
  24436. /**
  24437. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24438. */
  24439. side: number;
  24440. /**
  24441. * Creates a ribbon geometry
  24442. * @param id defines the unique ID of the geometry
  24443. * @param scene defines the hosting scene
  24444. * @param pathArray defines the array of paths to use
  24445. * @param closeArray defines if the last path and the first path must be joined
  24446. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  24447. * @param offset defines the offset between points
  24448. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24449. * @param mesh defines the hosting mesh (can be null)
  24450. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24451. */
  24452. constructor(id: string, scene: Scene,
  24453. /**
  24454. * Defines the array of paths to use
  24455. */
  24456. pathArray: Vector3[][],
  24457. /**
  24458. * Defines if the last and first points of each path in your pathArray must be joined
  24459. */
  24460. closeArray: boolean,
  24461. /**
  24462. * Defines if the last and first points of each path in your pathArray must be joined
  24463. */
  24464. closePath: boolean,
  24465. /**
  24466. * Defines the offset between points
  24467. */
  24468. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  24469. /**
  24470. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24471. */
  24472. side?: number);
  24473. /** @hidden */
  24474. _regenerateVertexData(): VertexData;
  24475. copy(id: string): Geometry;
  24476. }
  24477. /**
  24478. * Creates a box geometry
  24479. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  24480. */
  24481. class BoxGeometry extends _PrimitiveGeometry {
  24482. /**
  24483. * Defines the zise of the box (width, height and depth are the same)
  24484. */
  24485. size: number;
  24486. /**
  24487. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24488. */
  24489. side: number;
  24490. /**
  24491. * Creates a box geometry
  24492. * @param id defines the unique ID of the geometry
  24493. * @param scene defines the hosting scene
  24494. * @param size defines the zise of the box (width, height and depth are the same)
  24495. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24496. * @param mesh defines the hosting mesh (can be null)
  24497. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24498. */
  24499. constructor(id: string, scene: Scene,
  24500. /**
  24501. * Defines the zise of the box (width, height and depth are the same)
  24502. */
  24503. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24504. /**
  24505. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24506. */
  24507. side?: number);
  24508. /** @hidden */
  24509. _regenerateVertexData(): VertexData;
  24510. copy(id: string): Geometry;
  24511. serialize(): any;
  24512. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  24513. }
  24514. /**
  24515. * Creates a sphere geometry
  24516. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  24517. */
  24518. class SphereGeometry extends _PrimitiveGeometry {
  24519. /**
  24520. * Defines the number of segments to use to create the sphere
  24521. */
  24522. segments: number;
  24523. /**
  24524. * Defines the diameter of the sphere
  24525. */
  24526. diameter: number;
  24527. /**
  24528. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24529. */
  24530. side: number;
  24531. /**
  24532. * Create a new sphere geometry
  24533. * @param id defines the unique ID of the geometry
  24534. * @param scene defines the hosting scene
  24535. * @param segments defines the number of segments to use to create the sphere
  24536. * @param diameter defines the diameter of the sphere
  24537. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24538. * @param mesh defines the hosting mesh (can be null)
  24539. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24540. */
  24541. constructor(id: string, scene: Scene,
  24542. /**
  24543. * Defines the number of segments to use to create the sphere
  24544. */
  24545. segments: number,
  24546. /**
  24547. * Defines the diameter of the sphere
  24548. */
  24549. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24550. /**
  24551. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24552. */
  24553. side?: number);
  24554. /** @hidden */
  24555. _regenerateVertexData(): VertexData;
  24556. copy(id: string): Geometry;
  24557. serialize(): any;
  24558. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  24559. }
  24560. /**
  24561. * Creates a disc geometry
  24562. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24563. */
  24564. class DiscGeometry extends _PrimitiveGeometry {
  24565. /**
  24566. * Defines the radius of the disc
  24567. */
  24568. radius: number;
  24569. /**
  24570. * Defines the tesselation factor to apply to the disc
  24571. */
  24572. tessellation: number;
  24573. /**
  24574. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24575. */
  24576. side: number;
  24577. /**
  24578. * Creates a new disc geometry
  24579. * @param id defines the unique ID of the geometry
  24580. * @param scene defines the hosting scene
  24581. * @param radius defines the radius of the disc
  24582. * @param tessellation defines the tesselation factor to apply to the disc
  24583. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24584. * @param mesh defines the hosting mesh (can be null)
  24585. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24586. */
  24587. constructor(id: string, scene: Scene,
  24588. /**
  24589. * Defines the radius of the disc
  24590. */
  24591. radius: number,
  24592. /**
  24593. * Defines the tesselation factor to apply to the disc
  24594. */
  24595. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24596. /**
  24597. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24598. */
  24599. side?: number);
  24600. /** @hidden */
  24601. _regenerateVertexData(): VertexData;
  24602. copy(id: string): Geometry;
  24603. }
  24604. /**
  24605. * Creates a new cylinder geometry
  24606. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  24607. */
  24608. class CylinderGeometry extends _PrimitiveGeometry {
  24609. /**
  24610. * Defines the height of the cylinder
  24611. */
  24612. height: number;
  24613. /**
  24614. * Defines the diameter of the cylinder's top cap
  24615. */
  24616. diameterTop: number;
  24617. /**
  24618. * Defines the diameter of the cylinder's bottom cap
  24619. */
  24620. diameterBottom: number;
  24621. /**
  24622. * Defines the tessellation factor to apply to the cylinder
  24623. */
  24624. tessellation: number;
  24625. /**
  24626. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  24627. */
  24628. subdivisions: number;
  24629. /**
  24630. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24631. */
  24632. side: number;
  24633. /**
  24634. * Creates a new cylinder geometry
  24635. * @param id defines the unique ID of the geometry
  24636. * @param scene defines the hosting scene
  24637. * @param height defines the height of the cylinder
  24638. * @param diameterTop defines the diameter of the cylinder's top cap
  24639. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  24640. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  24641. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  24642. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24643. * @param mesh defines the hosting mesh (can be null)
  24644. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24645. */
  24646. constructor(id: string, scene: Scene,
  24647. /**
  24648. * Defines the height of the cylinder
  24649. */
  24650. height: number,
  24651. /**
  24652. * Defines the diameter of the cylinder's top cap
  24653. */
  24654. diameterTop: number,
  24655. /**
  24656. * Defines the diameter of the cylinder's bottom cap
  24657. */
  24658. diameterBottom: number,
  24659. /**
  24660. * Defines the tessellation factor to apply to the cylinder
  24661. */
  24662. tessellation: number,
  24663. /**
  24664. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  24665. */
  24666. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24667. /**
  24668. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24669. */
  24670. side?: number);
  24671. /** @hidden */
  24672. _regenerateVertexData(): VertexData;
  24673. copy(id: string): Geometry;
  24674. serialize(): any;
  24675. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  24676. }
  24677. /**
  24678. * Creates a new torus geometry
  24679. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  24680. */
  24681. class TorusGeometry extends _PrimitiveGeometry {
  24682. /**
  24683. * Defines the diameter of the torus
  24684. */
  24685. diameter: number;
  24686. /**
  24687. * Defines the thickness of the torus (ie. internal diameter)
  24688. */
  24689. thickness: number;
  24690. /**
  24691. * Defines the tesselation factor to apply to the torus
  24692. */
  24693. tessellation: number;
  24694. /**
  24695. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24696. */
  24697. side: number;
  24698. /**
  24699. * Creates a new torus geometry
  24700. * @param id defines the unique ID of the geometry
  24701. * @param scene defines the hosting scene
  24702. * @param diameter defines the diameter of the torus
  24703. * @param thickness defines the thickness of the torus (ie. internal diameter)
  24704. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  24705. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24706. * @param mesh defines the hosting mesh (can be null)
  24707. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24708. */
  24709. constructor(id: string, scene: Scene,
  24710. /**
  24711. * Defines the diameter of the torus
  24712. */
  24713. diameter: number,
  24714. /**
  24715. * Defines the thickness of the torus (ie. internal diameter)
  24716. */
  24717. thickness: number,
  24718. /**
  24719. * Defines the tesselation factor to apply to the torus
  24720. */
  24721. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24722. /**
  24723. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24724. */
  24725. side?: number);
  24726. /** @hidden */
  24727. _regenerateVertexData(): VertexData;
  24728. copy(id: string): Geometry;
  24729. serialize(): any;
  24730. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  24731. }
  24732. /**
  24733. * Creates a new ground geometry
  24734. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  24735. */
  24736. class GroundGeometry extends _PrimitiveGeometry {
  24737. /**
  24738. * Defines the width of the ground
  24739. */
  24740. width: number;
  24741. /**
  24742. * Defines the height of the ground
  24743. */
  24744. height: number;
  24745. /**
  24746. * Defines the subdivisions to apply to the ground
  24747. */
  24748. subdivisions: number;
  24749. /**
  24750. * Creates a new ground geometry
  24751. * @param id defines the unique ID of the geometry
  24752. * @param scene defines the hosting scene
  24753. * @param width defines the width of the ground
  24754. * @param height defines the height of the ground
  24755. * @param subdivisions defines the subdivisions to apply to the ground
  24756. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24757. * @param mesh defines the hosting mesh (can be null)
  24758. */
  24759. constructor(id: string, scene: Scene,
  24760. /**
  24761. * Defines the width of the ground
  24762. */
  24763. width: number,
  24764. /**
  24765. * Defines the height of the ground
  24766. */
  24767. height: number,
  24768. /**
  24769. * Defines the subdivisions to apply to the ground
  24770. */
  24771. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  24772. /** @hidden */
  24773. _regenerateVertexData(): VertexData;
  24774. copy(id: string): Geometry;
  24775. serialize(): any;
  24776. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  24777. }
  24778. /**
  24779. * Creates a tiled ground geometry
  24780. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  24781. */
  24782. class TiledGroundGeometry extends _PrimitiveGeometry {
  24783. /**
  24784. * Defines the minimum value on X axis
  24785. */
  24786. xmin: number;
  24787. /**
  24788. * Defines the minimum value on Z axis
  24789. */
  24790. zmin: number;
  24791. /**
  24792. * Defines the maximum value on X axis
  24793. */
  24794. xmax: number;
  24795. /**
  24796. * Defines the maximum value on Z axis
  24797. */
  24798. zmax: number;
  24799. /**
  24800. * Defines the subdivisions to apply to the ground
  24801. */
  24802. subdivisions: {
  24803. w: number;
  24804. h: number;
  24805. };
  24806. /**
  24807. * Defines the precision to use when computing the tiles
  24808. */
  24809. precision: {
  24810. w: number;
  24811. h: number;
  24812. };
  24813. /**
  24814. * Creates a tiled ground geometry
  24815. * @param id defines the unique ID of the geometry
  24816. * @param scene defines the hosting scene
  24817. * @param xmin defines the minimum value on X axis
  24818. * @param zmin defines the minimum value on Z axis
  24819. * @param xmax defines the maximum value on X axis
  24820. * @param zmax defines the maximum value on Z axis
  24821. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  24822. * @param precision defines the precision to use when computing the tiles
  24823. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24824. * @param mesh defines the hosting mesh (can be null)
  24825. */
  24826. constructor(id: string, scene: Scene,
  24827. /**
  24828. * Defines the minimum value on X axis
  24829. */
  24830. xmin: number,
  24831. /**
  24832. * Defines the minimum value on Z axis
  24833. */
  24834. zmin: number,
  24835. /**
  24836. * Defines the maximum value on X axis
  24837. */
  24838. xmax: number,
  24839. /**
  24840. * Defines the maximum value on Z axis
  24841. */
  24842. zmax: number,
  24843. /**
  24844. * Defines the subdivisions to apply to the ground
  24845. */
  24846. subdivisions: {
  24847. w: number;
  24848. h: number;
  24849. },
  24850. /**
  24851. * Defines the precision to use when computing the tiles
  24852. */
  24853. precision: {
  24854. w: number;
  24855. h: number;
  24856. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  24857. /** @hidden */
  24858. _regenerateVertexData(): VertexData;
  24859. copy(id: string): Geometry;
  24860. }
  24861. /**
  24862. * Creates a plane geometry
  24863. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  24864. */
  24865. class PlaneGeometry extends _PrimitiveGeometry {
  24866. /**
  24867. * Defines the size of the plane (width === height)
  24868. */
  24869. size: number;
  24870. /**
  24871. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24872. */
  24873. side: number;
  24874. /**
  24875. * Creates a plane geometry
  24876. * @param id defines the unique ID of the geometry
  24877. * @param scene defines the hosting scene
  24878. * @param size defines the size of the plane (width === height)
  24879. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24880. * @param mesh defines the hosting mesh (can be null)
  24881. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24882. */
  24883. constructor(id: string, scene: Scene,
  24884. /**
  24885. * Defines the size of the plane (width === height)
  24886. */
  24887. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24888. /**
  24889. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24890. */
  24891. side?: number);
  24892. /** @hidden */
  24893. _regenerateVertexData(): VertexData;
  24894. copy(id: string): Geometry;
  24895. serialize(): any;
  24896. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  24897. }
  24898. /**
  24899. * Creates a torus knot geometry
  24900. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  24901. */
  24902. class TorusKnotGeometry extends _PrimitiveGeometry {
  24903. /**
  24904. * Defines the radius of the torus knot
  24905. */
  24906. radius: number;
  24907. /**
  24908. * Defines the thickness of the torus knot tube
  24909. */
  24910. tube: number;
  24911. /**
  24912. * Defines the number of radial segments
  24913. */
  24914. radialSegments: number;
  24915. /**
  24916. * Defines the number of tubular segments
  24917. */
  24918. tubularSegments: number;
  24919. /**
  24920. * Defines the first number of windings
  24921. */
  24922. p: number;
  24923. /**
  24924. * Defines the second number of windings
  24925. */
  24926. q: number;
  24927. /**
  24928. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24929. */
  24930. side: number;
  24931. /**
  24932. * Creates a torus knot geometry
  24933. * @param id defines the unique ID of the geometry
  24934. * @param scene defines the hosting scene
  24935. * @param radius defines the radius of the torus knot
  24936. * @param tube defines the thickness of the torus knot tube
  24937. * @param radialSegments defines the number of radial segments
  24938. * @param tubularSegments defines the number of tubular segments
  24939. * @param p defines the first number of windings
  24940. * @param q defines the second number of windings
  24941. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  24942. * @param mesh defines the hosting mesh (can be null)
  24943. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24944. */
  24945. constructor(id: string, scene: Scene,
  24946. /**
  24947. * Defines the radius of the torus knot
  24948. */
  24949. radius: number,
  24950. /**
  24951. * Defines the thickness of the torus knot tube
  24952. */
  24953. tube: number,
  24954. /**
  24955. * Defines the number of radial segments
  24956. */
  24957. radialSegments: number,
  24958. /**
  24959. * Defines the number of tubular segments
  24960. */
  24961. tubularSegments: number,
  24962. /**
  24963. * Defines the first number of windings
  24964. */
  24965. p: number,
  24966. /**
  24967. * Defines the second number of windings
  24968. */
  24969. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  24970. /**
  24971. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  24972. */
  24973. side?: number);
  24974. /** @hidden */
  24975. _regenerateVertexData(): VertexData;
  24976. copy(id: string): Geometry;
  24977. serialize(): any;
  24978. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  24979. }
  24980. }
  24981. declare module BABYLON {
  24982. class GroundMesh extends Mesh {
  24983. generateOctree: boolean;
  24984. private _heightQuads;
  24985. /** @hidden */
  24986. _subdivisionsX: number;
  24987. /** @hidden */
  24988. _subdivisionsY: number;
  24989. /** @hidden */
  24990. _width: number;
  24991. /** @hidden */
  24992. _height: number;
  24993. /** @hidden */
  24994. _minX: number;
  24995. /** @hidden */
  24996. _maxX: number;
  24997. /** @hidden */
  24998. _minZ: number;
  24999. /** @hidden */
  25000. _maxZ: number;
  25001. constructor(name: string, scene: Scene);
  25002. getClassName(): string;
  25003. readonly subdivisions: number;
  25004. readonly subdivisionsX: number;
  25005. readonly subdivisionsY: number;
  25006. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25007. /**
  25008. * Returns a height (y) value in the Worl system :
  25009. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25010. * Returns the ground y position if (x, z) are outside the ground surface.
  25011. */
  25012. getHeightAtCoordinates(x: number, z: number): number;
  25013. /**
  25014. * Returns a normalized vector (Vector3) orthogonal to the ground
  25015. * at the ground coordinates (x, z) expressed in the World system.
  25016. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25017. */
  25018. getNormalAtCoordinates(x: number, z: number): Vector3;
  25019. /**
  25020. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25021. * at the ground coordinates (x, z) expressed in the World system.
  25022. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25023. * Returns the GroundMesh.
  25024. */
  25025. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25026. /**
  25027. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25028. * if the ground has been updated.
  25029. * This can be used in the render loop.
  25030. * Returns the GroundMesh.
  25031. */
  25032. updateCoordinateHeights(): GroundMesh;
  25033. private _getFacetAt;
  25034. private _initHeightQuads;
  25035. private _computeHeightQuads;
  25036. serialize(serializationObject: any): void;
  25037. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25038. }
  25039. }
  25040. declare module BABYLON {
  25041. /**
  25042. * Creates an instance based on a source mesh.
  25043. */
  25044. class InstancedMesh extends AbstractMesh {
  25045. private _sourceMesh;
  25046. private _currentLOD;
  25047. constructor(name: string, source: Mesh);
  25048. /**
  25049. * Returns the string "InstancedMesh".
  25050. */
  25051. getClassName(): string;
  25052. readonly receiveShadows: boolean;
  25053. readonly material: Nullable<Material>;
  25054. readonly visibility: number;
  25055. readonly skeleton: Nullable<Skeleton>;
  25056. renderingGroupId: number;
  25057. /**
  25058. * Returns the total number of vertices (integer).
  25059. */
  25060. getTotalVertices(): number;
  25061. readonly sourceMesh: Mesh;
  25062. /**
  25063. * Is this node ready to be used/rendered
  25064. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25065. * @return {boolean} is it ready
  25066. */
  25067. isReady(completeCheck?: boolean): boolean;
  25068. /**
  25069. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25070. */
  25071. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  25072. /**
  25073. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25074. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25075. * The `data` are either a numeric array either a Float32Array.
  25076. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  25077. * 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).
  25078. * Note that a new underlying VertexBuffer object is created each call.
  25079. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25080. *
  25081. * Possible `kind` values :
  25082. * - BABYLON.VertexBuffer.PositionKind
  25083. * - BABYLON.VertexBuffer.UVKind
  25084. * - BABYLON.VertexBuffer.UV2Kind
  25085. * - BABYLON.VertexBuffer.UV3Kind
  25086. * - BABYLON.VertexBuffer.UV4Kind
  25087. * - BABYLON.VertexBuffer.UV5Kind
  25088. * - BABYLON.VertexBuffer.UV6Kind
  25089. * - BABYLON.VertexBuffer.ColorKind
  25090. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25091. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25092. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25093. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25094. *
  25095. * Returns the Mesh.
  25096. */
  25097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25098. /**
  25099. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25100. * If the mesh has no geometry, it is simply returned as it is.
  25101. * The `data` are either a numeric array either a Float32Array.
  25102. * No new underlying VertexBuffer object is created.
  25103. * 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.
  25104. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  25105. *
  25106. * Possible `kind` values :
  25107. * - BABYLON.VertexBuffer.PositionKind
  25108. * - BABYLON.VertexBuffer.UVKind
  25109. * - BABYLON.VertexBuffer.UV2Kind
  25110. * - BABYLON.VertexBuffer.UV3Kind
  25111. * - BABYLON.VertexBuffer.UV4Kind
  25112. * - BABYLON.VertexBuffer.UV5Kind
  25113. * - BABYLON.VertexBuffer.UV6Kind
  25114. * - BABYLON.VertexBuffer.ColorKind
  25115. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25116. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25117. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25118. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25119. *
  25120. * Returns the Mesh.
  25121. */
  25122. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  25123. /**
  25124. * Sets the mesh indices.
  25125. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  25126. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25127. * This method creates a new index buffer each call.
  25128. * Returns the Mesh.
  25129. */
  25130. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  25131. /**
  25132. * Boolean : True if the mesh owns the requested kind of data.
  25133. */
  25134. isVerticesDataPresent(kind: string): boolean;
  25135. /**
  25136. * Returns an array of indices (IndicesArray).
  25137. */
  25138. getIndices(): Nullable<IndicesArray>;
  25139. readonly _positions: Nullable<Vector3[]>;
  25140. /**
  25141. * Sets a new updated BoundingInfo to the mesh.
  25142. * Returns the mesh.
  25143. */
  25144. refreshBoundingInfo(): InstancedMesh;
  25145. /** @hidden */
  25146. _preActivate(): InstancedMesh;
  25147. /** @hidden */
  25148. _activate(renderId: number): InstancedMesh;
  25149. /**
  25150. * Returns the current associated LOD AbstractMesh.
  25151. */
  25152. getLOD(camera: Camera): AbstractMesh;
  25153. /** @hidden */
  25154. _syncSubMeshes(): InstancedMesh;
  25155. /** @hidden */
  25156. _generatePointsArray(): boolean;
  25157. /**
  25158. * Creates a new InstancedMesh from the current mesh.
  25159. * - name (string) : the cloned mesh name
  25160. * - newParent (optional Node) : the optional Node to parent the clone to.
  25161. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  25162. *
  25163. * Returns the clone.
  25164. */
  25165. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  25166. /**
  25167. * Disposes the InstancedMesh.
  25168. * Returns nothing.
  25169. */
  25170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25171. }
  25172. }
  25173. declare module BABYLON {
  25174. class LinesMesh extends Mesh {
  25175. useVertexColor?: boolean | undefined;
  25176. useVertexAlpha?: boolean | undefined;
  25177. color: Color3;
  25178. alpha: number;
  25179. /**
  25180. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25181. * This margin is expressed in world space coordinates, so its value may vary.
  25182. * Default value is 0.1
  25183. * @returns the intersection Threshold value.
  25184. */
  25185. /**
  25186. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25187. * This margin is expressed in world space coordinates, so its value may vary.
  25188. * @param value the new threshold to apply
  25189. */
  25190. intersectionThreshold: number;
  25191. private _intersectionThreshold;
  25192. private _colorShader;
  25193. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  25194. /**
  25195. * Returns the string "LineMesh"
  25196. */
  25197. getClassName(): string;
  25198. /**
  25199. * @hidden
  25200. */
  25201. /**
  25202. * @hidden
  25203. */
  25204. material: Material;
  25205. /**
  25206. * @hidden
  25207. */
  25208. readonly checkCollisions: boolean;
  25209. /** @hidden */
  25210. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  25211. /** @hidden */
  25212. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  25213. dispose(doNotRecurse?: boolean): void;
  25214. /**
  25215. * Returns a new LineMesh object cloned from the current one.
  25216. */
  25217. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  25218. }
  25219. }
  25220. declare module BABYLON {
  25221. /**
  25222. * @hidden
  25223. **/
  25224. class _CreationDataStorage {
  25225. closePath?: boolean;
  25226. closeArray?: boolean;
  25227. idx: number[];
  25228. dashSize: number;
  25229. gapSize: number;
  25230. path3D: Path3D;
  25231. pathArray: Vector3[][];
  25232. arc: number;
  25233. radius: number;
  25234. cap: number;
  25235. tessellation: number;
  25236. }
  25237. /**
  25238. * @hidden
  25239. **/
  25240. class _InstanceDataStorage {
  25241. visibleInstances: any;
  25242. renderIdForInstances: number[];
  25243. batchCache: _InstancesBatch;
  25244. instancesBufferSize: number;
  25245. instancesBuffer: Nullable<Buffer>;
  25246. instancesData: Float32Array;
  25247. overridenInstanceCount: number;
  25248. }
  25249. /**
  25250. * @hidden
  25251. **/
  25252. class _InstancesBatch {
  25253. mustReturn: boolean;
  25254. visibleInstances: Nullable<InstancedMesh[]>[];
  25255. renderSelf: boolean[];
  25256. }
  25257. /**
  25258. * Class used to represent renderable models
  25259. */
  25260. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25261. /**
  25262. * Mesh side orientation : usually the external or front surface
  25263. */
  25264. static readonly FRONTSIDE: number;
  25265. /**
  25266. * Mesh side orientation : usually the internal or back surface
  25267. */
  25268. static readonly BACKSIDE: number;
  25269. /**
  25270. * Mesh side orientation : both internal and external or front and back surfaces
  25271. */
  25272. static readonly DOUBLESIDE: number;
  25273. /**
  25274. * Mesh side orientation : by default, `FRONTSIDE`
  25275. */
  25276. static readonly DEFAULTSIDE: number;
  25277. /**
  25278. * Mesh cap setting : no cap
  25279. */
  25280. static readonly NO_CAP: number;
  25281. /**
  25282. * Mesh cap setting : one cap at the beginning of the mesh
  25283. */
  25284. static readonly CAP_START: number;
  25285. /**
  25286. * Mesh cap setting : one cap at the end of the mesh
  25287. */
  25288. static readonly CAP_END: number;
  25289. /**
  25290. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25291. */
  25292. static readonly CAP_ALL: number;
  25293. private _onBeforeRenderObservable;
  25294. private _onAfterRenderObservable;
  25295. private _onBeforeDrawObservable;
  25296. /**
  25297. * An event triggered before rendering the mesh
  25298. */
  25299. readonly onBeforeRenderObservable: Observable<Mesh>;
  25300. /**
  25301. * An event triggered after rendering the mesh
  25302. */
  25303. readonly onAfterRenderObservable: Observable<Mesh>;
  25304. /**
  25305. * An event triggered before drawing the mesh
  25306. */
  25307. readonly onBeforeDrawObservable: Observable<Mesh>;
  25308. private _onBeforeDrawObserver;
  25309. /**
  25310. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25311. */
  25312. onBeforeDraw: () => void;
  25313. /**
  25314. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25315. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25316. */
  25317. delayLoadState: number;
  25318. /**
  25319. * Gets the list of instances created from this mesh
  25320. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25321. */
  25322. instances: InstancedMesh[];
  25323. /**
  25324. * Gets the file containing delay loading data for this mesh
  25325. */
  25326. delayLoadingFile: string;
  25327. /** @hidden */
  25328. _binaryInfo: any;
  25329. private _LODLevels;
  25330. /**
  25331. * User defined function used to change how LOD level selection is done
  25332. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25333. */
  25334. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25335. private _morphTargetManager;
  25336. /**
  25337. * Gets or sets the morph target manager
  25338. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25339. */
  25340. morphTargetManager: Nullable<MorphTargetManager>;
  25341. /** @hidden */
  25342. _creationDataStorage: Nullable<_CreationDataStorage>;
  25343. /** @hidden */
  25344. _geometry: Nullable<Geometry>;
  25345. /** @hidden */
  25346. _delayInfo: Array<string>;
  25347. /** @hidden */
  25348. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25349. /** @hidden */
  25350. _instanceDataStorage: _InstanceDataStorage;
  25351. private _effectiveMaterial;
  25352. /** @hidden */
  25353. _shouldGenerateFlatShading: boolean;
  25354. private _preActivateId;
  25355. /** @hidden */
  25356. _originalBuilderSideOrientation: number;
  25357. /**
  25358. * Use this property to change the original side orientation defined at construction time
  25359. */
  25360. overrideMaterialSideOrientation: Nullable<number>;
  25361. private _areNormalsFrozen;
  25362. private _sourcePositions;
  25363. private _sourceNormals;
  25364. private _source;
  25365. /**
  25366. * Gets the source mesh (the one used to clone this one from)
  25367. */
  25368. readonly source: Nullable<Mesh>;
  25369. /**
  25370. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25371. */
  25372. isUnIndexed: boolean;
  25373. /**
  25374. * @constructor
  25375. * @param name The value used by scene.getMeshByName() to do a lookup.
  25376. * @param scene The scene to add this mesh to.
  25377. * @param parent The parent of this mesh, if it has one
  25378. * @param source An optional Mesh from which geometry is shared, cloned.
  25379. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25380. * When false, achieved by calling a clone(), also passing False.
  25381. * This will make creation of children, recursive.
  25382. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25383. */
  25384. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25385. /**
  25386. * Gets the class name
  25387. * @returns the string "Mesh".
  25388. */
  25389. getClassName(): string;
  25390. /**
  25391. * Returns a description of this mesh
  25392. * @param fullDetails define if full details about this mesh must be used
  25393. * @returns a descriptive string representing this mesh
  25394. */
  25395. toString(fullDetails?: boolean): string;
  25396. /** @hidden */
  25397. _unBindEffect(): void;
  25398. /**
  25399. * Gets a boolean indicating if this mesh has LOD
  25400. */
  25401. readonly hasLODLevels: boolean;
  25402. /**
  25403. * Gets the list of MeshLODLevel associated with the current mesh
  25404. * @returns an array of MeshLODLevel
  25405. */
  25406. getLODLevels(): MeshLODLevel[];
  25407. private _sortLODLevels;
  25408. /**
  25409. * Add a mesh as LOD level triggered at the given distance.
  25410. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25411. * @param distance The distance from the center of the object to show this level
  25412. * @param mesh The mesh to be added as LOD level (can be null)
  25413. * @return This mesh (for chaining)
  25414. */
  25415. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25416. /**
  25417. * Returns the LOD level mesh at the passed distance or null if not found.
  25418. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25419. * @param distance The distance from the center of the object to show this level
  25420. * @returns a Mesh or `null`
  25421. */
  25422. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25423. /**
  25424. * Remove a mesh from the LOD array
  25425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25426. * @param mesh defines the mesh to be removed
  25427. * @return This mesh (for chaining)
  25428. */
  25429. removeLODLevel(mesh: Mesh): Mesh;
  25430. /**
  25431. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25432. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25433. * @param camera defines the camera to use to compute distance
  25434. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25435. * @return This mesh (for chaining)
  25436. */
  25437. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25438. /**
  25439. * Gets the mesh internal Geometry object
  25440. */
  25441. readonly geometry: Nullable<Geometry>;
  25442. /**
  25443. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25444. * @returns the total number of vertices
  25445. */
  25446. getTotalVertices(): number;
  25447. /**
  25448. * Returns the content of an associated vertex buffer
  25449. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25450. * - BABYLON.VertexBuffer.PositionKind
  25451. * - BABYLON.VertexBuffer.UVKind
  25452. * - BABYLON.VertexBuffer.UV2Kind
  25453. * - BABYLON.VertexBuffer.UV3Kind
  25454. * - BABYLON.VertexBuffer.UV4Kind
  25455. * - BABYLON.VertexBuffer.UV5Kind
  25456. * - BABYLON.VertexBuffer.UV6Kind
  25457. * - BABYLON.VertexBuffer.ColorKind
  25458. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25459. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25460. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25461. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25462. * @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
  25463. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25464. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25465. */
  25466. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25467. /**
  25468. * Returns the mesh VertexBuffer object from the requested `kind`
  25469. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25470. * - BABYLON.VertexBuffer.PositionKind
  25471. * - BABYLON.VertexBuffer.UVKind
  25472. * - BABYLON.VertexBuffer.UV2Kind
  25473. * - BABYLON.VertexBuffer.UV3Kind
  25474. * - BABYLON.VertexBuffer.UV4Kind
  25475. * - BABYLON.VertexBuffer.UV5Kind
  25476. * - BABYLON.VertexBuffer.UV6Kind
  25477. * - BABYLON.VertexBuffer.ColorKind
  25478. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25479. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25480. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25481. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25482. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25483. */
  25484. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25485. /**
  25486. * Tests if a specific vertex buffer is associated with this mesh
  25487. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25488. * - BABYLON.VertexBuffer.PositionKind
  25489. * - BABYLON.VertexBuffer.UVKind
  25490. * - BABYLON.VertexBuffer.UV2Kind
  25491. * - BABYLON.VertexBuffer.UV3Kind
  25492. * - BABYLON.VertexBuffer.UV4Kind
  25493. * - BABYLON.VertexBuffer.UV5Kind
  25494. * - BABYLON.VertexBuffer.UV6Kind
  25495. * - BABYLON.VertexBuffer.ColorKind
  25496. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25497. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25498. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25499. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25500. * @returns a boolean
  25501. */
  25502. isVerticesDataPresent(kind: string): boolean;
  25503. /**
  25504. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25505. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25506. * - BABYLON.VertexBuffer.PositionKind
  25507. * - BABYLON.VertexBuffer.UVKind
  25508. * - BABYLON.VertexBuffer.UV2Kind
  25509. * - BABYLON.VertexBuffer.UV3Kind
  25510. * - BABYLON.VertexBuffer.UV4Kind
  25511. * - BABYLON.VertexBuffer.UV5Kind
  25512. * - BABYLON.VertexBuffer.UV6Kind
  25513. * - BABYLON.VertexBuffer.ColorKind
  25514. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25515. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25516. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25517. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25518. * @returns a boolean
  25519. */
  25520. isVertexBufferUpdatable(kind: string): boolean;
  25521. /**
  25522. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25523. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25524. * - BABYLON.VertexBuffer.PositionKind
  25525. * - BABYLON.VertexBuffer.UVKind
  25526. * - BABYLON.VertexBuffer.UV2Kind
  25527. * - BABYLON.VertexBuffer.UV3Kind
  25528. * - BABYLON.VertexBuffer.UV4Kind
  25529. * - BABYLON.VertexBuffer.UV5Kind
  25530. * - BABYLON.VertexBuffer.UV6Kind
  25531. * - BABYLON.VertexBuffer.ColorKind
  25532. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25533. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25534. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25535. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25536. * @returns an array of strings
  25537. */
  25538. getVerticesDataKinds(): string[];
  25539. /**
  25540. * Returns a positive integer : the total number of indices in this mesh geometry.
  25541. * @returns the numner of indices or zero if the mesh has no geometry.
  25542. */
  25543. getTotalIndices(): number;
  25544. /**
  25545. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25546. * @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.
  25547. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25548. * @returns the indices array or an empty array if the mesh has no geometry
  25549. */
  25550. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25551. readonly isBlocked: boolean;
  25552. /**
  25553. * Determine if the current mesh is ready to be rendered
  25554. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25555. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25556. * @returns true if all associated assets are ready (material, textures, shaders)
  25557. */
  25558. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25559. /**
  25560. * 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.
  25561. */
  25562. readonly areNormalsFrozen: boolean;
  25563. /**
  25564. * 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.
  25565. * @returns the current mesh
  25566. */
  25567. freezeNormals(): Mesh;
  25568. /**
  25569. * 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
  25570. * @returns the current mesh
  25571. */
  25572. unfreezeNormals(): Mesh;
  25573. /**
  25574. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25575. */
  25576. overridenInstanceCount: number;
  25577. /** @hidden */
  25578. _preActivate(): Mesh;
  25579. /** @hidden */
  25580. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25581. /** @hidden */
  25582. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25583. /**
  25584. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25585. * This means the mesh underlying bounding box and sphere are recomputed.
  25586. * @returns the current mesh
  25587. */
  25588. refreshBoundingInfo(): Mesh;
  25589. /** @hidden */
  25590. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  25591. private _getPositionData;
  25592. /** @hidden */
  25593. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25594. /**
  25595. * This function will subdivide the mesh into multiple submeshes
  25596. * @param count defines the expected number of submeshes
  25597. */
  25598. subdivide(count: number): void;
  25599. /**
  25600. * Copy a FloatArray into a specific associated vertex buffer
  25601. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25602. * - BABYLON.VertexBuffer.PositionKind
  25603. * - BABYLON.VertexBuffer.UVKind
  25604. * - BABYLON.VertexBuffer.UV2Kind
  25605. * - BABYLON.VertexBuffer.UV3Kind
  25606. * - BABYLON.VertexBuffer.UV4Kind
  25607. * - BABYLON.VertexBuffer.UV5Kind
  25608. * - BABYLON.VertexBuffer.UV6Kind
  25609. * - BABYLON.VertexBuffer.ColorKind
  25610. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25611. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25612. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25613. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25614. * @param data defines the data source
  25615. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25616. * @param stride defines the data stride size (can be null)
  25617. * @returns the current mesh
  25618. */
  25619. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25620. /**
  25621. * Flags an associated vertex buffer as updatable
  25622. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25623. * - BABYLON.VertexBuffer.PositionKind
  25624. * - BABYLON.VertexBuffer.UVKind
  25625. * - BABYLON.VertexBuffer.UV2Kind
  25626. * - BABYLON.VertexBuffer.UV3Kind
  25627. * - BABYLON.VertexBuffer.UV4Kind
  25628. * - BABYLON.VertexBuffer.UV5Kind
  25629. * - BABYLON.VertexBuffer.UV6Kind
  25630. * - BABYLON.VertexBuffer.ColorKind
  25631. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25632. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25633. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25634. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25635. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25636. */
  25637. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25638. /**
  25639. * Sets the mesh global Vertex Buffer
  25640. * @param buffer defines the buffer to use
  25641. * @returns the current mesh
  25642. */
  25643. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25644. /**
  25645. * Update a specific associated vertex buffer
  25646. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25647. * - BABYLON.VertexBuffer.PositionKind
  25648. * - BABYLON.VertexBuffer.UVKind
  25649. * - BABYLON.VertexBuffer.UV2Kind
  25650. * - BABYLON.VertexBuffer.UV3Kind
  25651. * - BABYLON.VertexBuffer.UV4Kind
  25652. * - BABYLON.VertexBuffer.UV5Kind
  25653. * - BABYLON.VertexBuffer.UV6Kind
  25654. * - BABYLON.VertexBuffer.ColorKind
  25655. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25656. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25657. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25658. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25659. * @param data defines the data source
  25660. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25661. * @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)
  25662. * @returns the current mesh
  25663. */
  25664. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  25665. /**
  25666. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25667. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25668. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25669. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25670. * @returns the current mesh
  25671. */
  25672. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25673. /**
  25674. * Creates a un-shared specific occurence of the geometry for the mesh.
  25675. * @returns the current mesh
  25676. */
  25677. makeGeometryUnique(): Mesh;
  25678. /**
  25679. * Set the index buffer of this mesh
  25680. * @param indices defines the source data
  25681. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25682. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25683. * @returns the current mesh
  25684. */
  25685. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  25686. /**
  25687. * Update the current index buffer
  25688. * @param indices defines the source data
  25689. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25690. * @returns the current mesh
  25691. */
  25692. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  25693. /**
  25694. * Invert the geometry to move from a right handed system to a left handed one.
  25695. * @returns the current mesh
  25696. */
  25697. toLeftHanded(): Mesh;
  25698. /** @hidden */
  25699. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25700. /** @hidden */
  25701. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  25702. /**
  25703. * Registers for this mesh a javascript function called just before the rendering process
  25704. * @param func defines the function to call before rendering this mesh
  25705. * @returns the current mesh
  25706. */
  25707. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25708. /**
  25709. * Disposes a previously registered javascript function called before the rendering
  25710. * @param func defines the function to remove
  25711. * @returns the current mesh
  25712. */
  25713. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25714. /**
  25715. * Registers for this mesh a javascript function called just after the rendering is complete
  25716. * @param func defines the function to call after rendering this mesh
  25717. * @returns the current mesh
  25718. */
  25719. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25720. /**
  25721. * Disposes a previously registered javascript function called after the rendering.
  25722. * @param func defines the function to remove
  25723. * @returns the current mesh
  25724. */
  25725. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25726. /** @hidden */
  25727. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  25728. /** @hidden */
  25729. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25730. /** @hidden */
  25731. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25732. /**
  25733. * 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
  25734. * @param subMesh defines the subMesh to render
  25735. * @param enableAlphaMode defines if alpha mode can be changed
  25736. * @returns the current mesh
  25737. */
  25738. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  25739. private _onBeforeDraw;
  25740. /**
  25741. * Normalize matrix weights so that all vertices have a total weight set to 1
  25742. */
  25743. cleanMatrixWeights(): void;
  25744. /** @hidden */
  25745. _checkDelayState(): Mesh;
  25746. private _queueLoad;
  25747. /**
  25748. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25749. * A mesh is in the frustum if its bounding box intersects the frustum
  25750. * @param frustumPlanes defines the frustum to test
  25751. * @returns true if the mesh is in the frustum planes
  25752. */
  25753. isInFrustum(frustumPlanes: Plane[]): boolean;
  25754. /**
  25755. * Sets the mesh material by the material or multiMaterial `id` property
  25756. * @param id is a string identifying the material or the multiMaterial
  25757. * @returns the current mesh
  25758. */
  25759. setMaterialByID(id: string): Mesh;
  25760. /**
  25761. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25762. * @returns an array of IAnimatable
  25763. */
  25764. getAnimatables(): IAnimatable[];
  25765. /**
  25766. * Modifies the mesh geometry according to the passed transformation matrix.
  25767. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25768. * The mesh normals are modified using the same transformation.
  25769. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25770. * @param transform defines the transform matrix to use
  25771. * @see http://doc.babylonjs.com/resources/baking_transformations
  25772. * @returns the current mesh
  25773. */
  25774. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25775. /**
  25776. * Modifies the mesh geometry according to its own current World Matrix.
  25777. * The mesh World Matrix is then reset.
  25778. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25779. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25780. * @see http://doc.babylonjs.com/resources/baking_transformations
  25781. * @returns the current mesh
  25782. */
  25783. bakeCurrentTransformIntoVertices(): Mesh;
  25784. /** @hidden */
  25785. readonly _positions: Nullable<Vector3[]>;
  25786. /** @hidden */
  25787. _resetPointsArrayCache(): Mesh;
  25788. /** @hidden */
  25789. _generatePointsArray(): boolean;
  25790. /**
  25791. * Returns a new Mesh object generated from the current mesh properties.
  25792. * This method must not get confused with createInstance()
  25793. * @param name is a string, the name given to the new mesh
  25794. * @param newParent can be any Node object (default `null`)
  25795. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25796. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25797. * @returns a new mesh
  25798. */
  25799. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25800. /**
  25801. * Releases resources associated with this mesh.
  25802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25804. */
  25805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25806. /**
  25807. * Modifies the mesh geometry according to a displacement map.
  25808. * 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.
  25809. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25810. * @param url is a string, the URL from the image file is to be downloaded.
  25811. * @param minHeight is the lower limit of the displacement.
  25812. * @param maxHeight is the upper limit of the displacement.
  25813. * @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.
  25814. * @param uvOffset is an optional vector2 used to offset UV.
  25815. * @param uvScale is an optional vector2 used to scale UV.
  25816. * @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.
  25817. * @returns the Mesh.
  25818. */
  25819. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25820. /**
  25821. * Modifies the mesh geometry according to a displacementMap buffer.
  25822. * 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.
  25823. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25824. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25825. * @param heightMapWidth is the width of the buffer image.
  25826. * @param heightMapHeight is the height of the buffer image.
  25827. * @param minHeight is the lower limit of the displacement.
  25828. * @param maxHeight is the upper limit of the displacement.
  25829. * @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.
  25830. * @param uvOffset is an optional vector2 used to offset UV.
  25831. * @param uvScale is an optional vector2 used to scale UV.
  25832. * @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.
  25833. * @returns the Mesh.
  25834. */
  25835. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25836. /**
  25837. * Modify the mesh to get a flat shading rendering.
  25838. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25839. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25840. * @returns current mesh
  25841. */
  25842. convertToFlatShadedMesh(): Mesh;
  25843. /**
  25844. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25845. * In other words, more vertices, no more indices and a single bigger VBO.
  25846. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25847. * @returns current mesh
  25848. */
  25849. convertToUnIndexedMesh(): Mesh;
  25850. /**
  25851. * Inverses facet orientations.
  25852. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25853. * @param flipNormals will also inverts the normals
  25854. * @returns current mesh
  25855. */
  25856. flipFaces(flipNormals?: boolean): Mesh;
  25857. /**
  25858. * Creates a new InstancedMesh object from the mesh model.
  25859. * Warning : this method is not supported for Line mesh and LineSystem
  25860. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25861. * @param name defines the name of the new instance
  25862. * @returns a new InstancedMesh
  25863. */
  25864. createInstance(name: string): InstancedMesh;
  25865. /**
  25866. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25867. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25868. * @returns the current mesh
  25869. */
  25870. synchronizeInstances(): Mesh;
  25871. /**
  25872. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25873. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25874. * This should be used together with the simplification to avoid disappearing triangles.
  25875. * @param successCallback an optional success callback to be called after the optimization finished.
  25876. * @returns the current mesh
  25877. */
  25878. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25879. /**
  25880. * Serialize current mesh
  25881. * @param serializationObject defines the object which will receive the serialization data
  25882. */
  25883. serialize(serializationObject: any): void;
  25884. /** @hidden */
  25885. _syncGeometryWithMorphTargetManager(): void;
  25886. /**
  25887. * Returns a new Mesh object parsed from the source provided.
  25888. * @param parsedMesh is the source
  25889. * @param scene defines the hosting scene
  25890. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25891. * @returns a new Mesh
  25892. */
  25893. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25894. /**
  25895. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25896. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25897. * @param name defines the name of the mesh to create
  25898. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25899. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25900. * @param closePath creates a seam between the first and the last points of each path of the path array
  25901. * @param offset is taken in account only if the `pathArray` is containing a single path
  25902. * @param scene defines the hosting scene
  25903. * @param updatable defines if the mesh must be flagged as updatable
  25904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25905. * @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)
  25906. * @returns a new Mesh
  25907. */
  25908. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25909. /**
  25910. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25911. * @param name defines the name of the mesh to create
  25912. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25913. * @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
  25914. * @param scene defines the hosting scene
  25915. * @param updatable defines if the mesh must be flagged as updatable
  25916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25917. * @returns a new Mesh
  25918. */
  25919. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25920. /**
  25921. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25922. * @param name defines the name of the mesh to create
  25923. * @param size sets the size (float) of each box side (default 1)
  25924. * @param scene defines the hosting scene
  25925. * @param updatable defines if the mesh must be flagged as updatable
  25926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25927. * @returns a new Mesh
  25928. */
  25929. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25930. /**
  25931. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25932. * @param name defines the name of the mesh to create
  25933. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25934. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25935. * @param scene defines the hosting scene
  25936. * @param updatable defines if the mesh must be flagged as updatable
  25937. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25938. * @returns a new Mesh
  25939. */
  25940. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25941. /**
  25942. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25943. * @param name defines the name of the mesh to create
  25944. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25945. * @param diameterTop set the top cap diameter (floats, default 1)
  25946. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25947. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25948. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25949. * @param scene defines the hosting scene
  25950. * @param updatable defines if the mesh must be flagged as updatable
  25951. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25952. * @returns a new Mesh
  25953. */
  25954. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25955. /**
  25956. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25957. * @param name defines the name of the mesh to create
  25958. * @param diameter sets the diameter size (float) of the torus (default 1)
  25959. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25960. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25961. * @param scene defines the hosting scene
  25962. * @param updatable defines if the mesh must be flagged as updatable
  25963. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25964. * @returns a new Mesh
  25965. */
  25966. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25967. /**
  25968. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25969. * @param name defines the name of the mesh to create
  25970. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25971. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25972. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25973. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25974. * @param p the number of windings on X axis (positive integers, default 2)
  25975. * @param q the number of windings on Y axis (positive integers, default 3)
  25976. * @param scene defines the hosting scene
  25977. * @param updatable defines if the mesh must be flagged as updatable
  25978. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25979. * @returns a new Mesh
  25980. */
  25981. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25982. /**
  25983. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25984. * @param name defines the name of the mesh to create
  25985. * @param points is an array successive Vector3
  25986. * @param scene defines the hosting scene
  25987. * @param updatable defines if the mesh must be flagged as updatable
  25988. * @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).
  25989. * @returns a new Mesh
  25990. */
  25991. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25992. /**
  25993. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25994. * @param name defines the name of the mesh to create
  25995. * @param points is an array successive Vector3
  25996. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25997. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25998. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25999. * @param scene defines the hosting scene
  26000. * @param updatable defines if the mesh must be flagged as updatable
  26001. * @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)
  26002. * @returns a new Mesh
  26003. */
  26004. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26005. /**
  26006. * Creates a polygon mesh.
  26007. * Please consider using the same method from the MeshBuilder class instead.
  26008. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26009. * 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.
  26010. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26011. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26012. * Remember you can only change the shape positions, not their number when updating a polygon.
  26013. */
  26014. /**
  26015. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26016. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26017. * @param name defines the name of the mesh to create
  26018. * @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
  26019. * @param scene defines the hosting scene
  26020. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26021. * @param updatable defines if the mesh must be flagged as updatable
  26022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26023. * @returns a new Mesh
  26024. */
  26025. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26026. /**
  26027. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26028. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26029. * @param name defines the name of the mesh to create
  26030. * @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
  26031. * @param depth defines the height of extrusion
  26032. * @param scene defines the hosting scene
  26033. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26034. * @param updatable defines if the mesh must be flagged as updatable
  26035. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26036. * @returns a new Mesh
  26037. */
  26038. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26039. /**
  26040. * Creates an extruded shape mesh.
  26041. * 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
  26042. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26043. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26044. * @param name defines the name of the mesh to create
  26045. * @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
  26046. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26047. * @param scale is the value to scale the shape
  26048. * @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
  26049. * @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
  26050. * @param scene defines the hosting scene
  26051. * @param updatable defines if the mesh must be flagged as updatable
  26052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26053. * @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)
  26054. * @returns a new Mesh
  26055. */
  26056. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26057. /**
  26058. * Creates an custom extruded shape mesh.
  26059. * The custom extrusion is a parametric shape.
  26060. * It has no predefined shape. Its final shape will depend on the input parameters.
  26061. * Please consider using the same method from the MeshBuilder class instead
  26062. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26063. * @param name defines the name of the mesh to create
  26064. * @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
  26065. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26066. * @param scaleFunction is a custom Javascript function called on each path point
  26067. * @param rotationFunction is a custom Javascript function called on each path point
  26068. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26069. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26070. * @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
  26071. * @param scene defines the hosting scene
  26072. * @param updatable defines if the mesh must be flagged as updatable
  26073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26074. * @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)
  26075. * @returns a new Mesh
  26076. */
  26077. 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;
  26078. /**
  26079. * Creates lathe mesh.
  26080. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26081. * Please consider using the same method from the MeshBuilder class instead
  26082. * @param name defines the name of the mesh to create
  26083. * @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
  26084. * @param radius is the radius value of the lathe
  26085. * @param tessellation is the side number of the lathe.
  26086. * @param scene defines the hosting scene
  26087. * @param updatable defines if the mesh must be flagged as updatable
  26088. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26089. * @returns a new Mesh
  26090. */
  26091. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26092. /**
  26093. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26094. * @param name defines the name of the mesh to create
  26095. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26096. * @param scene defines the hosting scene
  26097. * @param updatable defines if the mesh must be flagged as updatable
  26098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26099. * @returns a new Mesh
  26100. */
  26101. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26102. /**
  26103. * Creates a ground mesh.
  26104. * Please consider using the same method from the MeshBuilder class instead
  26105. * @param name defines the name of the mesh to create
  26106. * @param width set the width of the ground
  26107. * @param height set the height of the ground
  26108. * @param subdivisions sets the number of subdivisions per side
  26109. * @param scene defines the hosting scene
  26110. * @param updatable defines if the mesh must be flagged as updatable
  26111. * @returns a new Mesh
  26112. */
  26113. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26114. /**
  26115. * Creates a tiled ground mesh.
  26116. * Please consider using the same method from the MeshBuilder class instead
  26117. * @param name defines the name of the mesh to create
  26118. * @param xmin set the ground minimum X coordinate
  26119. * @param zmin set the ground minimum Y coordinate
  26120. * @param xmax set the ground maximum X coordinate
  26121. * @param zmax set the ground maximum Z coordinate
  26122. * @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
  26123. * @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
  26124. * @param scene defines the hosting scene
  26125. * @param updatable defines if the mesh must be flagged as updatable
  26126. * @returns a new Mesh
  26127. */
  26128. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26129. w: number;
  26130. h: number;
  26131. }, precision: {
  26132. w: number;
  26133. h: number;
  26134. }, scene: Scene, updatable?: boolean): Mesh;
  26135. /**
  26136. * Creates a ground mesh from a height map.
  26137. * Please consider using the same method from the MeshBuilder class instead
  26138. * @see http://doc.babylonjs.com/babylon101/height_map
  26139. * @param name defines the name of the mesh to create
  26140. * @param url sets the URL of the height map image resource
  26141. * @param width set the ground width size
  26142. * @param height set the ground height size
  26143. * @param subdivisions sets the number of subdivision per side
  26144. * @param minHeight is the minimum altitude on the ground
  26145. * @param maxHeight is the maximum altitude on the ground
  26146. * @param scene defines the hosting scene
  26147. * @param updatable defines if the mesh must be flagged as updatable
  26148. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26149. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26150. * @returns a new Mesh
  26151. */
  26152. 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;
  26153. /**
  26154. * Creates a tube mesh.
  26155. * The tube is a parametric shape.
  26156. * It has no predefined shape. Its final shape will depend on the input parameters.
  26157. * Please consider using the same method from the MeshBuilder class instead
  26158. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26159. * @param name defines the name of the mesh to create
  26160. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26161. * @param radius sets the tube radius size
  26162. * @param tessellation is the number of sides on the tubular surface
  26163. * @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
  26164. * @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
  26165. * @param scene defines the hosting scene
  26166. * @param updatable defines if the mesh must be flagged as updatable
  26167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26168. * @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)
  26169. * @returns a new Mesh
  26170. */
  26171. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26172. (i: number, distance: number): number;
  26173. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26174. /**
  26175. * Creates a polyhedron mesh.
  26176. * Please consider using the same method from the MeshBuilder class instead.
  26177. * * 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
  26178. * * The parameter `size` (positive float, default 1) sets the polygon size
  26179. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26180. * * 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`
  26181. * * 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
  26182. * * 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)`)
  26183. * * 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
  26184. * * 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
  26185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26186. * * 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
  26187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26188. * @param name defines the name of the mesh to create
  26189. * @param options defines the options used to create the mesh
  26190. * @param scene defines the hosting scene
  26191. * @returns a new Mesh
  26192. */
  26193. static CreatePolyhedron(name: string, options: {
  26194. type?: number;
  26195. size?: number;
  26196. sizeX?: number;
  26197. sizeY?: number;
  26198. sizeZ?: number;
  26199. custom?: any;
  26200. faceUV?: Vector4[];
  26201. faceColors?: Color4[];
  26202. updatable?: boolean;
  26203. sideOrientation?: number;
  26204. }, scene: Scene): Mesh;
  26205. /**
  26206. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26207. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26208. * * 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`)
  26209. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26210. * * 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
  26211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26212. * * 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
  26213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26214. * @param name defines the name of the mesh
  26215. * @param options defines the options used to create the mesh
  26216. * @param scene defines the hosting scene
  26217. * @returns a new Mesh
  26218. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26219. */
  26220. static CreateIcoSphere(name: string, options: {
  26221. radius?: number;
  26222. flat?: boolean;
  26223. subdivisions?: number;
  26224. sideOrientation?: number;
  26225. updatable?: boolean;
  26226. }, scene: Scene): Mesh;
  26227. /**
  26228. * Creates a decal mesh.
  26229. * Please consider using the same method from the MeshBuilder class instead.
  26230. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26231. * @param name defines the name of the mesh
  26232. * @param sourceMesh defines the mesh receiving the decal
  26233. * @param position sets the position of the decal in world coordinates
  26234. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26235. * @param size sets the decal scaling
  26236. * @param angle sets the angle to rotate the decal
  26237. * @returns a new Mesh
  26238. */
  26239. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26240. /**
  26241. * Prepare internal position array for software CPU skinning
  26242. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26243. */
  26244. setPositionsForCPUSkinning(): Float32Array;
  26245. /**
  26246. * Prepare internal normal array for software CPU skinning
  26247. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26248. */
  26249. setNormalsForCPUSkinning(): Float32Array;
  26250. /**
  26251. * Updates the vertex buffer by applying transformation from the bones
  26252. * @param skeleton defines the skeleton to apply to current mesh
  26253. * @returns the current mesh
  26254. */
  26255. applySkeleton(skeleton: Skeleton): Mesh;
  26256. /**
  26257. * 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
  26258. * @param meshes defines the list of meshes to scan
  26259. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26260. */
  26261. static MinMax(meshes: AbstractMesh[]): {
  26262. min: Vector3;
  26263. max: Vector3;
  26264. };
  26265. /**
  26266. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26267. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26268. * @returns a vector3
  26269. */
  26270. static Center(meshesOrMinMaxVector: {
  26271. min: Vector3;
  26272. max: Vector3;
  26273. } | AbstractMesh[]): Vector3;
  26274. /**
  26275. * Merge the array of meshes into a single mesh for performance reasons.
  26276. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26277. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26278. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26279. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26280. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26281. * @returns a new mesh
  26282. */
  26283. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  26284. }
  26285. }
  26286. declare module BABYLON {
  26287. /**
  26288. * Define an interface for all classes that will get and set the data on vertices
  26289. */
  26290. interface IGetSetVerticesData {
  26291. /**
  26292. * Gets a boolean indicating if specific vertex data is present
  26293. * @param kind defines the vertex data kind to use
  26294. * @returns true is data kind is present
  26295. */
  26296. isVerticesDataPresent(kind: string): boolean;
  26297. /**
  26298. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26299. * @param kind defines the data kind (Position, normal, etc...)
  26300. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26302. * @returns a float array containing vertex data
  26303. */
  26304. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26305. /**
  26306. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26307. * @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.
  26308. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26309. * @returns the indices array or an empty array if the mesh has no geometry
  26310. */
  26311. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26312. /**
  26313. * Set specific vertex data
  26314. * @param kind defines the data kind (Position, normal, etc...)
  26315. * @param data defines the vertex data to use
  26316. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26317. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26318. */
  26319. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26320. /**
  26321. * Update a specific associated vertex buffer
  26322. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26323. * - BABYLON.VertexBuffer.PositionKind
  26324. * - BABYLON.VertexBuffer.UVKind
  26325. * - BABYLON.VertexBuffer.UV2Kind
  26326. * - BABYLON.VertexBuffer.UV3Kind
  26327. * - BABYLON.VertexBuffer.UV4Kind
  26328. * - BABYLON.VertexBuffer.UV5Kind
  26329. * - BABYLON.VertexBuffer.UV6Kind
  26330. * - BABYLON.VertexBuffer.ColorKind
  26331. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26332. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26333. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26334. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26335. * @param data defines the data source
  26336. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26337. * @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)
  26338. */
  26339. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26340. /**
  26341. * Creates a new index buffer
  26342. * @param indices defines the indices to store in the index buffer
  26343. * @param totalVertices defines the total number of vertices (could be null)
  26344. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26345. */
  26346. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26347. }
  26348. /**
  26349. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26350. */
  26351. class VertexData {
  26352. /**
  26353. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26354. */
  26355. positions: Nullable<FloatArray>;
  26356. /**
  26357. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26358. */
  26359. normals: Nullable<FloatArray>;
  26360. /**
  26361. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26362. */
  26363. tangents: Nullable<FloatArray>;
  26364. /**
  26365. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26366. */
  26367. uvs: Nullable<FloatArray>;
  26368. /**
  26369. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26370. */
  26371. uvs2: Nullable<FloatArray>;
  26372. /**
  26373. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26374. */
  26375. uvs3: Nullable<FloatArray>;
  26376. /**
  26377. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26378. */
  26379. uvs4: Nullable<FloatArray>;
  26380. /**
  26381. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26382. */
  26383. uvs5: Nullable<FloatArray>;
  26384. /**
  26385. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26386. */
  26387. uvs6: Nullable<FloatArray>;
  26388. /**
  26389. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26390. */
  26391. colors: Nullable<FloatArray>;
  26392. /**
  26393. * 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).
  26394. */
  26395. matricesIndices: Nullable<FloatArray>;
  26396. /**
  26397. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26398. */
  26399. matricesWeights: Nullable<FloatArray>;
  26400. /**
  26401. * An array extending the number of possible indices
  26402. */
  26403. matricesIndicesExtra: Nullable<FloatArray>;
  26404. /**
  26405. * An array extending the number of possible weights when the number of indices is extended
  26406. */
  26407. matricesWeightsExtra: Nullable<FloatArray>;
  26408. /**
  26409. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26410. */
  26411. indices: Nullable<IndicesArray>;
  26412. /**
  26413. * Uses the passed data array to set the set the values for the specified kind of data
  26414. * @param data a linear array of floating numbers
  26415. * @param kind the type of data that is being set, eg positions, colors etc
  26416. */
  26417. set(data: FloatArray, kind: string): void;
  26418. /**
  26419. * Associates the vertexData to the passed Mesh.
  26420. * Sets it as updatable or not (default `false`)
  26421. * @param mesh the mesh the vertexData is applied to
  26422. * @param updatable when used and having the value true allows new data to update the vertexData
  26423. * @returns the VertexData
  26424. */
  26425. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26426. /**
  26427. * Associates the vertexData to the passed Geometry.
  26428. * Sets it as updatable or not (default `false`)
  26429. * @param geometry the geometry the vertexData is applied to
  26430. * @param updatable when used and having the value true allows new data to update the vertexData
  26431. * @returns VertexData
  26432. */
  26433. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26434. /**
  26435. * Updates the associated mesh
  26436. * @param mesh the mesh to be updated
  26437. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26438. * @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
  26439. * @returns VertexData
  26440. */
  26441. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  26442. /**
  26443. * Updates the associated geometry
  26444. * @param geometry the geometry to be updated
  26445. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26446. * @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
  26447. * @returns VertexData.
  26448. */
  26449. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  26450. private _applyTo;
  26451. private _update;
  26452. /**
  26453. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26454. * @param matrix the transforming matrix
  26455. * @returns the VertexData
  26456. */
  26457. transform(matrix: Matrix): VertexData;
  26458. /**
  26459. * Merges the passed VertexData into the current one
  26460. * @param other the VertexData to be merged into the current one
  26461. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26462. * @returns the modified VertexData
  26463. */
  26464. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26465. private _mergeElement;
  26466. private _validate;
  26467. /**
  26468. * Serializes the VertexData
  26469. * @returns a serialized object
  26470. */
  26471. serialize(): any;
  26472. /**
  26473. * Extracts the vertexData from a mesh
  26474. * @param mesh the mesh from which to extract the VertexData
  26475. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26476. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26477. * @returns the object VertexData associated to the passed mesh
  26478. */
  26479. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26480. /**
  26481. * Extracts the vertexData from the geometry
  26482. * @param geometry the geometry from which to extract the VertexData
  26483. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26484. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26485. * @returns the object VertexData associated to the passed mesh
  26486. */
  26487. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26488. private static _ExtractFrom;
  26489. /**
  26490. * Creates the VertexData for a Ribbon
  26491. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26492. * * pathArray array of paths, each of which an array of successive Vector3
  26493. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26494. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26495. * * 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
  26496. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26497. * * 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)
  26498. * * 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)
  26499. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26500. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26501. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26502. * @returns the VertexData of the ribbon
  26503. */
  26504. static CreateRibbon(options: {
  26505. pathArray: Vector3[][];
  26506. closeArray?: boolean;
  26507. closePath?: boolean;
  26508. offset?: number;
  26509. sideOrientation?: number;
  26510. frontUVs?: Vector4;
  26511. backUVs?: Vector4;
  26512. invertUV?: boolean;
  26513. uvs?: Vector2[];
  26514. colors?: Color4[];
  26515. }): VertexData;
  26516. /**
  26517. * Creates the VertexData for a box
  26518. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26519. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26520. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26521. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26522. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26523. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26524. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26525. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26526. * * 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)
  26527. * * 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)
  26528. * @returns the VertexData of the box
  26529. */
  26530. static CreateBox(options: {
  26531. size?: number;
  26532. width?: number;
  26533. height?: number;
  26534. depth?: number;
  26535. faceUV?: Vector4[];
  26536. faceColors?: Color4[];
  26537. sideOrientation?: number;
  26538. frontUVs?: Vector4;
  26539. backUVs?: Vector4;
  26540. }): VertexData;
  26541. /**
  26542. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26544. * * segments sets the number of horizontal strips optional, default 32
  26545. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26546. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26547. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26548. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26549. * * 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
  26550. * * 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
  26551. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26552. * * 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)
  26553. * * 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)
  26554. * @returns the VertexData of the ellipsoid
  26555. */
  26556. static CreateSphere(options: {
  26557. segments?: number;
  26558. diameter?: number;
  26559. diameterX?: number;
  26560. diameterY?: number;
  26561. diameterZ?: number;
  26562. arc?: number;
  26563. slice?: number;
  26564. sideOrientation?: number;
  26565. frontUVs?: Vector4;
  26566. backUVs?: Vector4;
  26567. }): VertexData;
  26568. /**
  26569. * Creates the VertexData for a cylinder, cone or prism
  26570. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26571. * * height sets the height (y direction) of the cylinder, optional, default 2
  26572. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26573. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26574. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26575. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26576. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26577. * * 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
  26578. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26579. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26580. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26581. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26582. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26583. * * 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)
  26584. * * 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)
  26585. * @returns the VertexData of the cylinder, cone or prism
  26586. */
  26587. static CreateCylinder(options: {
  26588. height?: number;
  26589. diameterTop?: number;
  26590. diameterBottom?: number;
  26591. diameter?: number;
  26592. tessellation?: number;
  26593. subdivisions?: number;
  26594. arc?: number;
  26595. faceColors?: Color4[];
  26596. faceUV?: Vector4[];
  26597. hasRings?: boolean;
  26598. enclose?: boolean;
  26599. sideOrientation?: number;
  26600. frontUVs?: Vector4;
  26601. backUVs?: Vector4;
  26602. }): VertexData;
  26603. /**
  26604. * Creates the VertexData for a torus
  26605. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26606. * * diameter the diameter of the torus, optional default 1
  26607. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26608. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26609. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26610. * * 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)
  26611. * * 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)
  26612. * @returns the VertexData of the torus
  26613. */
  26614. static CreateTorus(options: {
  26615. diameter?: number;
  26616. thickness?: number;
  26617. tessellation?: number;
  26618. sideOrientation?: number;
  26619. frontUVs?: Vector4;
  26620. backUVs?: Vector4;
  26621. }): VertexData;
  26622. /**
  26623. * Creates the VertexData of the LineSystem
  26624. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26625. * - lines an array of lines, each line being an array of successive Vector3
  26626. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26627. * @returns the VertexData of the LineSystem
  26628. */
  26629. static CreateLineSystem(options: {
  26630. lines: Vector3[][];
  26631. colors?: Nullable<Color4[][]>;
  26632. }): VertexData;
  26633. /**
  26634. * Create the VertexData for a DashedLines
  26635. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26636. * - points an array successive Vector3
  26637. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26638. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26639. * - dashNb the intended total number of dashes, optional, default 200
  26640. * @returns the VertexData for the DashedLines
  26641. */
  26642. static CreateDashedLines(options: {
  26643. points: Vector3[];
  26644. dashSize?: number;
  26645. gapSize?: number;
  26646. dashNb?: number;
  26647. }): VertexData;
  26648. /**
  26649. * Creates the VertexData for a Ground
  26650. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26651. * - width the width (x direction) of the ground, optional, default 1
  26652. * - height the height (z direction) of the ground, optional, default 1
  26653. * - subdivisions the number of subdivisions per side, optional, default 1
  26654. * @returns the VertexData of the Ground
  26655. */
  26656. static CreateGround(options: {
  26657. width?: number;
  26658. height?: number;
  26659. subdivisions?: number;
  26660. subdivisionsX?: number;
  26661. subdivisionsY?: number;
  26662. }): VertexData;
  26663. /**
  26664. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26665. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26666. * * xmin the ground minimum X coordinate, optional, default -1
  26667. * * zmin the ground minimum Z coordinate, optional, default -1
  26668. * * xmax the ground maximum X coordinate, optional, default 1
  26669. * * zmax the ground maximum Z coordinate, optional, default 1
  26670. * * 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}
  26671. * * 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}
  26672. * @returns the VertexData of the TiledGround
  26673. */
  26674. static CreateTiledGround(options: {
  26675. xmin: number;
  26676. zmin: number;
  26677. xmax: number;
  26678. zmax: number;
  26679. subdivisions?: {
  26680. w: number;
  26681. h: number;
  26682. };
  26683. precision?: {
  26684. w: number;
  26685. h: number;
  26686. };
  26687. }): VertexData;
  26688. /**
  26689. * Creates the VertexData of the Ground designed from a heightmap
  26690. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26691. * * width the width (x direction) of the ground
  26692. * * height the height (z direction) of the ground
  26693. * * subdivisions the number of subdivisions per side
  26694. * * minHeight the minimum altitude on the ground, optional, default 0
  26695. * * maxHeight the maximum altitude on the ground, optional default 1
  26696. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26697. * * buffer the array holding the image color data
  26698. * * bufferWidth the width of image
  26699. * * bufferHeight the height of image
  26700. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26701. * @returns the VertexData of the Ground designed from a heightmap
  26702. */
  26703. static CreateGroundFromHeightMap(options: {
  26704. width: number;
  26705. height: number;
  26706. subdivisions: number;
  26707. minHeight: number;
  26708. maxHeight: number;
  26709. colorFilter: Color3;
  26710. buffer: Uint8Array;
  26711. bufferWidth: number;
  26712. bufferHeight: number;
  26713. alphaFilter: number;
  26714. }): VertexData;
  26715. /**
  26716. * Creates the VertexData for a Plane
  26717. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26718. * * size sets the width and height of the plane to the value of size, optional default 1
  26719. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26720. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26721. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26722. * * 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)
  26723. * * 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)
  26724. * @returns the VertexData of the box
  26725. */
  26726. static CreatePlane(options: {
  26727. size?: number;
  26728. width?: number;
  26729. height?: number;
  26730. sideOrientation?: number;
  26731. frontUVs?: Vector4;
  26732. backUVs?: Vector4;
  26733. }): VertexData;
  26734. /**
  26735. * Creates the VertexData of the Disc or regular Polygon
  26736. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26737. * * radius the radius of the disc, optional default 0.5
  26738. * * tessellation the number of polygon sides, optional, default 64
  26739. * * 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
  26740. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26741. * * 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)
  26742. * * 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)
  26743. * @returns the VertexData of the box
  26744. */
  26745. static CreateDisc(options: {
  26746. radius?: number;
  26747. tessellation?: number;
  26748. arc?: number;
  26749. sideOrientation?: number;
  26750. frontUVs?: Vector4;
  26751. backUVs?: Vector4;
  26752. }): VertexData;
  26753. /**
  26754. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26755. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26756. * @param polygon a mesh built from polygonTriangulation.build()
  26757. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26758. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26759. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26760. * @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)
  26761. * @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)
  26762. * @returns the VertexData of the Polygon
  26763. */
  26764. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  26765. /**
  26766. * Creates the VertexData of the IcoSphere
  26767. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26768. * * radius the radius of the IcoSphere, optional default 1
  26769. * * radiusX allows stretching in the x direction, optional, default radius
  26770. * * radiusY allows stretching in the y direction, optional, default radius
  26771. * * radiusZ allows stretching in the z direction, optional, default radius
  26772. * * flat when true creates a flat shaded mesh, optional, default true
  26773. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26774. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26775. * * 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)
  26776. * * 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)
  26777. * @returns the VertexData of the IcoSphere
  26778. */
  26779. static CreateIcoSphere(options: {
  26780. radius?: number;
  26781. radiusX?: number;
  26782. radiusY?: number;
  26783. radiusZ?: number;
  26784. flat?: boolean;
  26785. subdivisions?: number;
  26786. sideOrientation?: number;
  26787. frontUVs?: Vector4;
  26788. backUVs?: Vector4;
  26789. }): VertexData;
  26790. /**
  26791. * Creates the VertexData for a Polyhedron
  26792. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26793. * * type provided types are:
  26794. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26795. * * 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)
  26796. * * size the size of the IcoSphere, optional default 1
  26797. * * sizeX allows stretching in the x direction, optional, default size
  26798. * * sizeY allows stretching in the y direction, optional, default size
  26799. * * sizeZ allows stretching in the z direction, optional, default size
  26800. * * 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
  26801. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26802. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26803. * * flat when true creates a flat shaded mesh, optional, default true
  26804. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26805. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26806. * * 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)
  26807. * * 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)
  26808. * @returns the VertexData of the Polyhedron
  26809. */
  26810. static CreatePolyhedron(options: {
  26811. type?: number;
  26812. size?: number;
  26813. sizeX?: number;
  26814. sizeY?: number;
  26815. sizeZ?: number;
  26816. custom?: any;
  26817. faceUV?: Vector4[];
  26818. faceColors?: Color4[];
  26819. flat?: boolean;
  26820. sideOrientation?: number;
  26821. frontUVs?: Vector4;
  26822. backUVs?: Vector4;
  26823. }): VertexData;
  26824. /**
  26825. * Creates the VertexData for a TorusKnot
  26826. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26827. * * radius the radius of the torus knot, optional, default 2
  26828. * * tube the thickness of the tube, optional, default 0.5
  26829. * * radialSegments the number of sides on each tube segments, optional, default 32
  26830. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26831. * * p the number of windings around the z axis, optional, default 2
  26832. * * q the number of windings around the x axis, optional, default 3
  26833. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26834. * * 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)
  26835. * * 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)
  26836. * @returns the VertexData of the Torus Knot
  26837. */
  26838. static CreateTorusKnot(options: {
  26839. radius?: number;
  26840. tube?: number;
  26841. radialSegments?: number;
  26842. tubularSegments?: number;
  26843. p?: number;
  26844. q?: number;
  26845. sideOrientation?: number;
  26846. frontUVs?: Vector4;
  26847. backUVs?: Vector4;
  26848. }): VertexData;
  26849. /**
  26850. * Compute normals for given positions and indices
  26851. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26852. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26853. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26854. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26855. * * facetNormals : optional array of facet normals (vector3)
  26856. * * facetPositions : optional array of facet positions (vector3)
  26857. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26858. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26859. * * bInfo : optional bounding info, required for facetPartitioning computation
  26860. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26861. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26862. * * useRightHandedSystem: optional boolean to for right handed system computation
  26863. * * depthSort : optional boolean to enable the facet depth sort computation
  26864. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26865. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26866. */
  26867. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26868. facetNormals?: any;
  26869. facetPositions?: any;
  26870. facetPartitioning?: any;
  26871. ratio?: number;
  26872. bInfo?: any;
  26873. bbSize?: Vector3;
  26874. subDiv?: any;
  26875. useRightHandedSystem?: boolean;
  26876. depthSort?: boolean;
  26877. distanceTo?: Vector3;
  26878. depthSortedFacets?: any;
  26879. }): void;
  26880. private static _ComputeSides;
  26881. /**
  26882. * Applies VertexData created from the imported parameters to the geometry
  26883. * @param parsedVertexData the parsed data from an imported file
  26884. * @param geometry the geometry to apply the VertexData to
  26885. */
  26886. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26887. }
  26888. }
  26889. declare module BABYLON {
  26890. /**
  26891. * Class containing static functions to help procedurally build meshes
  26892. */
  26893. class MeshBuilder {
  26894. private static updateSideOrientation;
  26895. /**
  26896. * Creates a box mesh
  26897. * * The parameter `size` sets the size (float) of each box side (default 1)
  26898. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  26899. * * 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)
  26900. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  26901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26902. * * 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
  26903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26904. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  26905. * @param name defines the name of the mesh
  26906. * @param options defines the options used to create the mesh
  26907. * @param scene defines the hosting scene
  26908. * @returns the box mesh
  26909. */
  26910. static CreateBox(name: string, options: {
  26911. size?: number;
  26912. width?: number;
  26913. height?: number;
  26914. depth?: number;
  26915. faceUV?: Vector4[];
  26916. faceColors?: Color4[];
  26917. sideOrientation?: number;
  26918. frontUVs?: Vector4;
  26919. backUVs?: Vector4;
  26920. updatable?: boolean;
  26921. }, scene?: Nullable<Scene>): Mesh;
  26922. /**
  26923. * Creates a sphere mesh
  26924. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  26925. * * 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`)
  26926. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  26927. * * 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
  26928. * * 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)
  26929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26930. * * 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
  26931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26932. * @param name defines the name of the mesh
  26933. * @param options defines the options used to create the mesh
  26934. * @param scene defines the hosting scene
  26935. * @returns the sphere mesh
  26936. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  26937. */
  26938. static CreateSphere(name: string, options: {
  26939. segments?: number;
  26940. diameter?: number;
  26941. diameterX?: number;
  26942. diameterY?: number;
  26943. diameterZ?: number;
  26944. arc?: number;
  26945. slice?: number;
  26946. sideOrientation?: number;
  26947. frontUVs?: Vector4;
  26948. backUVs?: Vector4;
  26949. updatable?: boolean;
  26950. }, scene: any): Mesh;
  26951. /**
  26952. * Creates a plane polygonal mesh. By default, this is a disc
  26953. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26954. * * 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
  26955. * * 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
  26956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26957. * * 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
  26958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26959. * @param name defines the name of the mesh
  26960. * @param options defines the options used to create the mesh
  26961. * @param scene defines the hosting scene
  26962. * @returns the plane polygonal mesh
  26963. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26964. */
  26965. static CreateDisc(name: string, options: {
  26966. radius?: number;
  26967. tessellation?: number;
  26968. arc?: number;
  26969. updatable?: boolean;
  26970. sideOrientation?: number;
  26971. frontUVs?: Vector4;
  26972. backUVs?: Vector4;
  26973. }, scene?: Nullable<Scene>): Mesh;
  26974. /**
  26975. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26976. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26977. * * 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`)
  26978. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26979. * * 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
  26980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26981. * * 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
  26982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26983. * @param name defines the name of the mesh
  26984. * @param options defines the options used to create the mesh
  26985. * @param scene defines the hosting scene
  26986. * @returns the icosahedron mesh
  26987. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26988. */
  26989. static CreateIcoSphere(name: string, options: {
  26990. radius?: number;
  26991. radiusX?: number;
  26992. radiusY?: number;
  26993. radiusZ?: number;
  26994. flat?: boolean;
  26995. subdivisions?: number;
  26996. sideOrientation?: number;
  26997. frontUVs?: Vector4;
  26998. backUVs?: Vector4;
  26999. updatable?: boolean;
  27000. }, scene: Scene): Mesh;
  27001. /**
  27002. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27003. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  27004. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  27005. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  27006. * * 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
  27007. * * 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
  27008. * * 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
  27009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27010. * * 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
  27011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27012. * * 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
  27013. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  27014. * * 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
  27015. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  27016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27017. * @param name defines the name of the mesh
  27018. * @param options defines the options used to create the mesh
  27019. * @param scene defines the hosting scene
  27020. * @returns the ribbon mesh
  27021. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  27022. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27023. */
  27024. static CreateRibbon(name: string, options: {
  27025. pathArray: Vector3[][];
  27026. closeArray?: boolean;
  27027. closePath?: boolean;
  27028. offset?: number;
  27029. updatable?: boolean;
  27030. sideOrientation?: number;
  27031. frontUVs?: Vector4;
  27032. backUVs?: Vector4;
  27033. instance?: Mesh;
  27034. invertUV?: boolean;
  27035. uvs?: Vector2[];
  27036. colors?: Color4[];
  27037. }, scene?: Nullable<Scene>): Mesh;
  27038. /**
  27039. * Creates a cylinder or a cone mesh
  27040. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  27041. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  27042. * * 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.
  27043. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  27044. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  27045. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  27046. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  27047. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  27048. * * 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).
  27049. * * 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
  27050. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  27051. * * 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
  27052. * * 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.
  27053. * * If `enclose` is false, a ring surface is one element.
  27054. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  27055. * * 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
  27056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27057. * * 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
  27058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27059. * @param name defines the name of the mesh
  27060. * @param options defines the options used to create the mesh
  27061. * @param scene defines the hosting scene
  27062. * @returns the cylinder mesh
  27063. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  27064. */
  27065. static CreateCylinder(name: string, options: {
  27066. height?: number;
  27067. diameterTop?: number;
  27068. diameterBottom?: number;
  27069. diameter?: number;
  27070. tessellation?: number;
  27071. subdivisions?: number;
  27072. arc?: number;
  27073. faceColors?: Color4[];
  27074. faceUV?: Vector4[];
  27075. updatable?: boolean;
  27076. hasRings?: boolean;
  27077. enclose?: boolean;
  27078. sideOrientation?: number;
  27079. frontUVs?: Vector4;
  27080. backUVs?: Vector4;
  27081. }, scene: any): Mesh;
  27082. /**
  27083. * Creates a torus mesh
  27084. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  27085. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  27086. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  27087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27088. * * 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
  27089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27090. * @param name defines the name of the mesh
  27091. * @param options defines the options used to create the mesh
  27092. * @param scene defines the hosting scene
  27093. * @returns the torus mesh
  27094. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  27095. */
  27096. static CreateTorus(name: string, options: {
  27097. diameter?: number;
  27098. thickness?: number;
  27099. tessellation?: number;
  27100. updatable?: boolean;
  27101. sideOrientation?: number;
  27102. frontUVs?: Vector4;
  27103. backUVs?: Vector4;
  27104. }, scene: any): Mesh;
  27105. /**
  27106. * Creates a torus knot mesh
  27107. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  27108. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  27109. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  27110. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  27111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27112. * * 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
  27113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27114. * @param name defines the name of the mesh
  27115. * @param options defines the options used to create the mesh
  27116. * @param scene defines the hosting scene
  27117. * @returns the torus knot mesh
  27118. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  27119. */
  27120. static CreateTorusKnot(name: string, options: {
  27121. radius?: number;
  27122. tube?: number;
  27123. radialSegments?: number;
  27124. tubularSegments?: number;
  27125. p?: number;
  27126. q?: number;
  27127. updatable?: boolean;
  27128. sideOrientation?: number;
  27129. frontUVs?: Vector4;
  27130. backUVs?: Vector4;
  27131. }, scene: any): Mesh;
  27132. /**
  27133. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  27134. * * 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
  27135. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  27136. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  27137. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  27138. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  27139. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  27140. * * 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
  27141. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  27142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27143. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  27144. * @param name defines the name of the new line system
  27145. * @param options defines the options used to create the line system
  27146. * @param scene defines the hosting scene
  27147. * @returns a new line system mesh
  27148. */
  27149. static CreateLineSystem(name: string, options: {
  27150. lines: Vector3[][];
  27151. updatable?: boolean;
  27152. instance?: Nullable<LinesMesh>;
  27153. colors?: Nullable<Color4[][]>;
  27154. useVertexAlpha?: boolean;
  27155. }, scene: Nullable<Scene>): LinesMesh;
  27156. /**
  27157. * Creates a line mesh
  27158. * 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
  27159. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27160. * * The parameter `points` is an array successive Vector3
  27161. * * 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
  27162. * * The optional parameter `colors` is an array of successive Color4, one per line point
  27163. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  27164. * * When updating an instance, remember that only point positions can change, not the number of points
  27165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27166. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  27167. * @param name defines the name of the new line system
  27168. * @param options defines the options used to create the line system
  27169. * @param scene defines the hosting scene
  27170. * @returns a new line mesh
  27171. */
  27172. static CreateLines(name: string, options: {
  27173. points: Vector3[];
  27174. updatable?: boolean;
  27175. instance?: Nullable<LinesMesh>;
  27176. colors?: Color4[];
  27177. useVertexAlpha?: boolean;
  27178. }, scene?: Nullable<Scene>): LinesMesh;
  27179. /**
  27180. * Creates a dashed line mesh
  27181. * * 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
  27182. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  27183. * * The parameter `points` is an array successive Vector3
  27184. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  27185. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  27186. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27187. * * 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
  27188. * * When updating an instance, remember that only point positions can change, not the number of points
  27189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27190. * @param name defines the name of the mesh
  27191. * @param options defines the options used to create the mesh
  27192. * @param scene defines the hosting scene
  27193. * @returns the dashed line mesh
  27194. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  27195. */
  27196. static CreateDashedLines(name: string, options: {
  27197. points: Vector3[];
  27198. dashSize?: number;
  27199. gapSize?: number;
  27200. dashNb?: number;
  27201. updatable?: boolean;
  27202. instance?: LinesMesh;
  27203. }, scene?: Nullable<Scene>): LinesMesh;
  27204. /**
  27205. * 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.
  27206. * * 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.
  27207. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27208. * * 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.
  27209. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  27210. * * 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
  27211. * * 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
  27212. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  27213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27214. * * 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
  27215. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  27216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27217. * @param name defines the name of the mesh
  27218. * @param options defines the options used to create the mesh
  27219. * @param scene defines the hosting scene
  27220. * @returns the extruded shape mesh
  27221. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27222. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27223. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27224. */
  27225. static ExtrudeShape(name: string, options: {
  27226. shape: Vector3[];
  27227. path: Vector3[];
  27228. scale?: number;
  27229. rotation?: number;
  27230. cap?: number;
  27231. updatable?: boolean;
  27232. sideOrientation?: number;
  27233. frontUVs?: Vector4;
  27234. backUVs?: Vector4;
  27235. instance?: Mesh;
  27236. invertUV?: boolean;
  27237. }, scene?: Nullable<Scene>): Mesh;
  27238. /**
  27239. * Creates an custom extruded shape mesh.
  27240. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  27241. * * 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.
  27242. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  27243. * * 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
  27244. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  27245. * * 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
  27246. * * It must returns a float value that will be the scale value applied to the shape on each path point
  27247. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27248. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  27249. * * 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
  27250. * * 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
  27251. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  27252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27253. * * 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
  27254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27256. * @param name defines the name of the mesh
  27257. * @param options defines the options used to create the mesh
  27258. * @param scene defines the hosting scene
  27259. * @returns the custom extruded shape mesh
  27260. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  27261. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27262. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27263. */
  27264. static ExtrudeShapeCustom(name: string, options: {
  27265. shape: Vector3[];
  27266. path: Vector3[];
  27267. scaleFunction?: any;
  27268. rotationFunction?: any;
  27269. ribbonCloseArray?: boolean;
  27270. ribbonClosePath?: boolean;
  27271. cap?: number;
  27272. updatable?: boolean;
  27273. sideOrientation?: number;
  27274. frontUVs?: Vector4;
  27275. backUVs?: Vector4;
  27276. instance?: Mesh;
  27277. invertUV?: boolean;
  27278. }, scene: Scene): Mesh;
  27279. /**
  27280. * Creates lathe mesh.
  27281. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  27282. * * 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
  27283. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  27284. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  27285. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  27286. * * 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
  27287. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  27288. * * 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
  27289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27290. * * 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
  27291. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27293. * @param name defines the name of the mesh
  27294. * @param options defines the options used to create the mesh
  27295. * @param scene defines the hosting scene
  27296. * @returns the lathe mesh
  27297. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  27298. */
  27299. static CreateLathe(name: string, options: {
  27300. shape: Vector3[];
  27301. radius?: number;
  27302. tessellation?: number;
  27303. clip?: number;
  27304. arc?: number;
  27305. closed?: boolean;
  27306. updatable?: boolean;
  27307. sideOrientation?: number;
  27308. frontUVs?: Vector4;
  27309. backUVs?: Vector4;
  27310. cap?: number;
  27311. invertUV?: boolean;
  27312. }, scene: Scene): Mesh;
  27313. /**
  27314. * Creates a plane mesh
  27315. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  27316. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  27317. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  27318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27319. * * 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
  27320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27321. * @param name defines the name of the mesh
  27322. * @param options defines the options used to create the mesh
  27323. * @param scene defines the hosting scene
  27324. * @returns the plane mesh
  27325. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  27326. */
  27327. static CreatePlane(name: string, options: {
  27328. size?: number;
  27329. width?: number;
  27330. height?: number;
  27331. sideOrientation?: number;
  27332. frontUVs?: Vector4;
  27333. backUVs?: Vector4;
  27334. updatable?: boolean;
  27335. sourcePlane?: Plane;
  27336. }, scene: Scene): Mesh;
  27337. /**
  27338. * Creates a ground mesh
  27339. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  27340. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  27341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27342. * @param name defines the name of the mesh
  27343. * @param options defines the options used to create the mesh
  27344. * @param scene defines the hosting scene
  27345. * @returns the ground mesh
  27346. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  27347. */
  27348. static CreateGround(name: string, options: {
  27349. width?: number;
  27350. height?: number;
  27351. subdivisions?: number;
  27352. subdivisionsX?: number;
  27353. subdivisionsY?: number;
  27354. updatable?: boolean;
  27355. }, scene: any): Mesh;
  27356. /**
  27357. * Creates a tiled ground mesh
  27358. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  27359. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  27360. * * 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
  27361. * * 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
  27362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27363. * @param name defines the name of the mesh
  27364. * @param options defines the options used to create the mesh
  27365. * @param scene defines the hosting scene
  27366. * @returns the tiled ground mesh
  27367. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  27368. */
  27369. static CreateTiledGround(name: string, options: {
  27370. xmin: number;
  27371. zmin: number;
  27372. xmax: number;
  27373. zmax: number;
  27374. subdivisions?: {
  27375. w: number;
  27376. h: number;
  27377. };
  27378. precision?: {
  27379. w: number;
  27380. h: number;
  27381. };
  27382. updatable?: boolean;
  27383. }, scene: Scene): Mesh;
  27384. /**
  27385. * Creates a ground mesh from a height map
  27386. * * The parameter `url` sets the URL of the height map image resource.
  27387. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  27388. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  27389. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  27390. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  27391. * * 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.
  27392. * * 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).
  27393. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27395. * @param name defines the name of the mesh
  27396. * @param url defines the url to the height map
  27397. * @param options defines the options used to create the mesh
  27398. * @param scene defines the hosting scene
  27399. * @returns the ground mesh
  27400. * @see http://doc.babylonjs.com/babylon101/height_map
  27401. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  27402. */
  27403. static CreateGroundFromHeightMap(name: string, url: string, options: {
  27404. width?: number;
  27405. height?: number;
  27406. subdivisions?: number;
  27407. minHeight?: number;
  27408. maxHeight?: number;
  27409. colorFilter?: Color3;
  27410. alphaFilter?: number;
  27411. updatable?: boolean;
  27412. onReady?: (mesh: GroundMesh) => void;
  27413. }, scene: Scene): GroundMesh;
  27414. /**
  27415. * Creates a polygon mesh
  27416. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  27417. * * 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
  27418. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27420. * * 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)
  27421. * * Remember you can only change the shape positions, not their number when updating a polygon
  27422. * @param name defines the name of the mesh
  27423. * @param options defines the options used to create the mesh
  27424. * @param scene defines the hosting scene
  27425. * @returns the polygon mesh
  27426. */
  27427. static CreatePolygon(name: string, options: {
  27428. shape: Vector3[];
  27429. holes?: Vector3[][];
  27430. depth?: number;
  27431. faceUV?: Vector4[];
  27432. faceColors?: Color4[];
  27433. updatable?: boolean;
  27434. sideOrientation?: number;
  27435. frontUVs?: Vector4;
  27436. backUVs?: Vector4;
  27437. }, scene: Scene): Mesh;
  27438. /**
  27439. * Creates an extruded polygon mesh, with depth in the Y direction.
  27440. * * 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)
  27441. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27442. * @param name defines the name of the mesh
  27443. * @param options defines the options used to create the mesh
  27444. * @param scene defines the hosting scene
  27445. * @returns the polygon mesh
  27446. */
  27447. static ExtrudePolygon(name: string, options: {
  27448. shape: Vector3[];
  27449. holes?: Vector3[][];
  27450. depth?: number;
  27451. faceUV?: Vector4[];
  27452. faceColors?: Color4[];
  27453. updatable?: boolean;
  27454. sideOrientation?: number;
  27455. frontUVs?: Vector4;
  27456. backUVs?: Vector4;
  27457. }, scene: Scene): Mesh;
  27458. /**
  27459. * Creates a tube mesh.
  27460. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27461. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  27462. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  27463. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  27464. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  27465. * * 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)
  27466. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  27467. * * 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
  27468. * * 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
  27469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27470. * * 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
  27471. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27473. * @param name defines the name of the mesh
  27474. * @param options defines the options used to create the mesh
  27475. * @param scene defines the hosting scene
  27476. * @returns the tube mesh
  27477. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27478. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  27479. */
  27480. static CreateTube(name: string, options: {
  27481. path: Vector3[];
  27482. radius?: number;
  27483. tessellation?: number;
  27484. radiusFunction?: {
  27485. (i: number, distance: number): number;
  27486. };
  27487. cap?: number;
  27488. arc?: number;
  27489. updatable?: boolean;
  27490. sideOrientation?: number;
  27491. frontUVs?: Vector4;
  27492. backUVs?: Vector4;
  27493. instance?: Mesh;
  27494. invertUV?: boolean;
  27495. }, scene: Scene): Mesh;
  27496. /**
  27497. * Creates a polyhedron mesh
  27498. * * 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
  27499. * * The parameter `size` (positive float, default 1) sets the polygon size
  27500. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27501. * * 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`
  27502. * * 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
  27503. * * 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)`)
  27504. * * 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
  27505. * * 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
  27506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27507. * * 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
  27508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27509. * @param name defines the name of the mesh
  27510. * @param options defines the options used to create the mesh
  27511. * @param scene defines the hosting scene
  27512. * @returns the polyhedron mesh
  27513. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  27514. */
  27515. static CreatePolyhedron(name: string, options: {
  27516. type?: number;
  27517. size?: number;
  27518. sizeX?: number;
  27519. sizeY?: number;
  27520. sizeZ?: number;
  27521. custom?: any;
  27522. faceUV?: Vector4[];
  27523. faceColors?: Color4[];
  27524. flat?: boolean;
  27525. updatable?: boolean;
  27526. sideOrientation?: number;
  27527. frontUVs?: Vector4;
  27528. backUVs?: Vector4;
  27529. }, scene: Scene): Mesh;
  27530. /**
  27531. * Creates a decal mesh.
  27532. * 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
  27533. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  27534. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  27535. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  27536. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  27537. * @param name defines the name of the mesh
  27538. * @param sourceMesh defines the mesh where the decal must be applied
  27539. * @param options defines the options used to create the mesh
  27540. * @param scene defines the hosting scene
  27541. * @returns the decal mesh
  27542. * @see http://doc.babylonjs.com/how_to/decals
  27543. */
  27544. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  27545. position?: Vector3;
  27546. normal?: Vector3;
  27547. size?: Vector3;
  27548. angle?: number;
  27549. }): Mesh;
  27550. private static _ExtrudeShapeGeneric;
  27551. }
  27552. }
  27553. declare module BABYLON {
  27554. /**
  27555. * Class used to represent a specific level of detail of a mesh
  27556. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27557. */
  27558. class MeshLODLevel {
  27559. /** Defines the distance where this level should star being displayed */
  27560. distance: number;
  27561. /** Defines the mesh to use to render this level */
  27562. mesh: Nullable<Mesh>;
  27563. /**
  27564. * Creates a new LOD level
  27565. * @param distance defines the distance where this level should star being displayed
  27566. * @param mesh defines the mesh to use to render this level
  27567. */
  27568. constructor(
  27569. /** Defines the distance where this level should star being displayed */
  27570. distance: number,
  27571. /** Defines the mesh to use to render this level */
  27572. mesh: Nullable<Mesh>);
  27573. }
  27574. }
  27575. declare module BABYLON {
  27576. /**
  27577. * A simplifier interface for future simplification implementations
  27578. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27579. */
  27580. interface ISimplifier {
  27581. /**
  27582. * Simplification of a given mesh according to the given settings.
  27583. * Since this requires computation, it is assumed that the function runs async.
  27584. * @param settings The settings of the simplification, including quality and distance
  27585. * @param successCallback A callback that will be called after the mesh was simplified.
  27586. * @param errorCallback in case of an error, this callback will be called. optional.
  27587. */
  27588. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  27589. }
  27590. /**
  27591. * Expected simplification settings.
  27592. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  27593. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27594. */
  27595. interface ISimplificationSettings {
  27596. /**
  27597. * Gets or sets the expected quality
  27598. */
  27599. quality: number;
  27600. /**
  27601. * Gets or sets the distance when this optimized version should be used
  27602. */
  27603. distance: number;
  27604. /**
  27605. * Gets an already optimized mesh
  27606. */
  27607. optimizeMesh?: boolean;
  27608. }
  27609. /**
  27610. * Class used to specify simplification options
  27611. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27612. */
  27613. class SimplificationSettings implements ISimplificationSettings {
  27614. /** expected quality */
  27615. quality: number;
  27616. /** distance when this optimized version should be used */
  27617. distance: number;
  27618. /** already optimized mesh */
  27619. optimizeMesh?: boolean | undefined;
  27620. /**
  27621. * Creates a SimplificationSettings
  27622. * @param quality expected quality
  27623. * @param distance distance when this optimized version should be used
  27624. * @param optimizeMesh already optimized mesh
  27625. */
  27626. constructor(
  27627. /** expected quality */
  27628. quality: number,
  27629. /** distance when this optimized version should be used */
  27630. distance: number,
  27631. /** already optimized mesh */
  27632. optimizeMesh?: boolean | undefined);
  27633. }
  27634. /**
  27635. * Interface used to define a simplification task
  27636. */
  27637. interface ISimplificationTask {
  27638. /**
  27639. * Array of settings
  27640. */
  27641. settings: Array<ISimplificationSettings>;
  27642. /**
  27643. * Simplification type
  27644. */
  27645. simplificationType: SimplificationType;
  27646. /**
  27647. * Mesh to simplify
  27648. */
  27649. mesh: Mesh;
  27650. /**
  27651. * Callback called on success
  27652. */
  27653. successCallback?: () => void;
  27654. /**
  27655. * Defines if parallel processing can be used
  27656. */
  27657. parallelProcessing: boolean;
  27658. }
  27659. /**
  27660. * Queue used to order the simplification tasks
  27661. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27662. */
  27663. class SimplificationQueue {
  27664. private _simplificationArray;
  27665. /**
  27666. * Gets a boolean indicating that the process is still running
  27667. */
  27668. running: boolean;
  27669. /**
  27670. * Creates a new queue
  27671. */
  27672. constructor();
  27673. /**
  27674. * Adds a new simplification task
  27675. * @param task defines a task to add
  27676. */
  27677. addTask(task: ISimplificationTask): void;
  27678. /**
  27679. * Execute next task
  27680. */
  27681. executeNext(): void;
  27682. /**
  27683. * Execute a simplification task
  27684. * @param task defines the task to run
  27685. */
  27686. runSimplification(task: ISimplificationTask): void;
  27687. private getSimplifier;
  27688. }
  27689. /**
  27690. * The implemented types of simplification
  27691. * At the moment only Quadratic Error Decimation is implemented
  27692. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27693. */
  27694. enum SimplificationType {
  27695. /** Quadratic error decimation */
  27696. QUADRATIC = 0
  27697. }
  27698. }
  27699. declare module BABYLON {
  27700. interface Scene {
  27701. /** @hidden (Backing field) */
  27702. _simplificationQueue: SimplificationQueue;
  27703. /**
  27704. * Gets or sets the simplification queue attached to the scene
  27705. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  27706. */
  27707. simplificationQueue: SimplificationQueue;
  27708. }
  27709. interface Mesh {
  27710. /**
  27711. * Simplify the mesh according to the given array of settings.
  27712. * Function will return immediately and will simplify async
  27713. * @param settings a collection of simplification settings
  27714. * @param parallelProcessing should all levels calculate parallel or one after the other
  27715. * @param simplificationType the type of simplification to run
  27716. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  27717. * @returns the current mesh
  27718. */
  27719. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  27720. }
  27721. /**
  27722. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  27723. * created in a scene
  27724. */
  27725. class SimplicationQueueSceneComponent implements ISceneComponent {
  27726. /**
  27727. * The component name helpfull to identify the component in the list of scene components.
  27728. */
  27729. readonly name: string;
  27730. /**
  27731. * The scene the component belongs to.
  27732. */
  27733. scene: Scene;
  27734. /**
  27735. * Creates a new instance of the component for the given scene
  27736. * @param scene Defines the scene to register the component in
  27737. */
  27738. constructor(scene: Scene);
  27739. /**
  27740. * Registers the component in a given scene
  27741. */
  27742. register(): void;
  27743. /**
  27744. * Rebuilds the elements related to this component in case of
  27745. * context lost for instance.
  27746. */
  27747. rebuild(): void;
  27748. /**
  27749. * Disposes the component and the associated ressources
  27750. */
  27751. dispose(): void;
  27752. private _beforeCameraUpdate;
  27753. }
  27754. }
  27755. declare module BABYLON {
  27756. class Polygon {
  27757. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  27758. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  27759. static Parse(input: string): Vector2[];
  27760. static StartingAt(x: number, y: number): Path2;
  27761. }
  27762. class PolygonMeshBuilder {
  27763. private _points;
  27764. private _outlinepoints;
  27765. private _holes;
  27766. private _name;
  27767. private _scene;
  27768. private _epoints;
  27769. private _eholes;
  27770. private _addToepoint;
  27771. constructor(name: string, contours: Path2, scene: Scene);
  27772. constructor(name: string, contours: Vector2[], scene: Scene);
  27773. addHole(hole: Vector2[]): PolygonMeshBuilder;
  27774. build(updatable?: boolean, depth?: number): Mesh;
  27775. private addSide;
  27776. }
  27777. }
  27778. declare module BABYLON {
  27779. /**
  27780. * Base class for submeshes
  27781. */
  27782. class BaseSubMesh {
  27783. /** @hidden */
  27784. _materialDefines: Nullable<MaterialDefines>;
  27785. /** @hidden */
  27786. _materialEffect: Nullable<Effect>;
  27787. /**
  27788. * Gets associated effect
  27789. */
  27790. readonly effect: Nullable<Effect>;
  27791. /**
  27792. * Sets associated effect (effect used to render this submesh)
  27793. * @param effect defines the effect to associate with
  27794. * @param defines defines the set of defines used to compile this effect
  27795. */
  27796. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  27797. }
  27798. /**
  27799. * Defines a subdivision inside a mesh
  27800. */
  27801. class SubMesh extends BaseSubMesh implements ICullable {
  27802. /** the material index to use */
  27803. materialIndex: number;
  27804. /** vertex index start */
  27805. verticesStart: number;
  27806. /** vertices count */
  27807. verticesCount: number;
  27808. /** index start */
  27809. indexStart: number;
  27810. /** indices count */
  27811. indexCount: number;
  27812. /** @hidden */
  27813. _linesIndexCount: number;
  27814. private _mesh;
  27815. private _renderingMesh;
  27816. private _boundingInfo;
  27817. private _linesIndexBuffer;
  27818. /** @hidden */
  27819. _lastColliderWorldVertices: Nullable<Vector3[]>;
  27820. /** @hidden */
  27821. _trianglePlanes: Plane[];
  27822. /** @hidden */
  27823. _lastColliderTransformMatrix: Matrix;
  27824. /** @hidden */
  27825. _renderId: number;
  27826. /** @hidden */
  27827. _alphaIndex: number;
  27828. /** @hidden */
  27829. _distanceToCamera: number;
  27830. /** @hidden */
  27831. _id: number;
  27832. private _currentMaterial;
  27833. /**
  27834. * Add a new submesh to a mesh
  27835. * @param materialIndex defines the material index to use
  27836. * @param verticesStart defines vertex index start
  27837. * @param verticesCount defines vertices count
  27838. * @param indexStart defines index start
  27839. * @param indexCount defines indices count
  27840. * @param mesh defines the parent mesh
  27841. * @param renderingMesh defines an optional rendering mesh
  27842. * @param createBoundingBox defines if bounding box should be created for this submesh
  27843. * @returns the new submesh
  27844. */
  27845. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  27846. /**
  27847. * Creates a new submesh
  27848. * @param materialIndex defines the material index to use
  27849. * @param verticesStart defines vertex index start
  27850. * @param verticesCount defines vertices count
  27851. * @param indexStart defines index start
  27852. * @param indexCount defines indices count
  27853. * @param mesh defines the parent mesh
  27854. * @param renderingMesh defines an optional rendering mesh
  27855. * @param createBoundingBox defines if bounding box should be created for this submesh
  27856. */
  27857. constructor(
  27858. /** the material index to use */
  27859. materialIndex: number,
  27860. /** vertex index start */
  27861. verticesStart: number,
  27862. /** vertices count */
  27863. verticesCount: number,
  27864. /** index start */
  27865. indexStart: number,
  27866. /** indices count */
  27867. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  27868. /**
  27869. * Returns true if this submesh covers the entire parent mesh
  27870. * @ignorenaming
  27871. */
  27872. readonly IsGlobal: boolean;
  27873. /**
  27874. * Returns the submesh BoudingInfo object
  27875. * @returns current bounding info (or mesh's one if the submesh is global)
  27876. */
  27877. getBoundingInfo(): BoundingInfo;
  27878. /**
  27879. * Sets the submesh BoundingInfo
  27880. * @param boundingInfo defines the new bounding info to use
  27881. * @returns the SubMesh
  27882. */
  27883. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  27884. /**
  27885. * Returns the mesh of the current submesh
  27886. * @return the parent mesh
  27887. */
  27888. getMesh(): AbstractMesh;
  27889. /**
  27890. * Returns the rendering mesh of the submesh
  27891. * @returns the rendering mesh (could be different from parent mesh)
  27892. */
  27893. getRenderingMesh(): Mesh;
  27894. /**
  27895. * Returns the submesh material
  27896. * @returns null or the current material
  27897. */
  27898. getMaterial(): Nullable<Material>;
  27899. /**
  27900. * Sets a new updated BoundingInfo object to the submesh
  27901. * @returns the SubMesh
  27902. */
  27903. refreshBoundingInfo(): SubMesh;
  27904. /** @hidden */
  27905. _checkCollision(collider: Collider): boolean;
  27906. /**
  27907. * Updates the submesh BoundingInfo
  27908. * @param world defines the world matrix to use to update the bounding info
  27909. * @returns the submesh
  27910. */
  27911. updateBoundingInfo(world: Matrix): SubMesh;
  27912. /**
  27913. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  27914. * @param frustumPlanes defines the frustum planes
  27915. * @returns true if the submesh is intersecting with the frustum
  27916. */
  27917. isInFrustum(frustumPlanes: Plane[]): boolean;
  27918. /**
  27919. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  27920. * @param frustumPlanes defines the frustum planes
  27921. * @returns true if the submesh is inside the frustum
  27922. */
  27923. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27924. /**
  27925. * Renders the submesh
  27926. * @param enableAlphaMode defines if alpha needs to be used
  27927. * @returns the submesh
  27928. */
  27929. render(enableAlphaMode: boolean): SubMesh;
  27930. /**
  27931. * @hidden
  27932. */
  27933. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  27934. /**
  27935. * Checks if the submesh intersects with a ray
  27936. * @param ray defines the ray to test
  27937. * @returns true is the passed ray intersects the submesh bounding box
  27938. */
  27939. canIntersects(ray: Ray): boolean;
  27940. /**
  27941. * Intersects current submesh with a ray
  27942. * @param ray defines the ray to test
  27943. * @param positions defines mesh's positions array
  27944. * @param indices defines mesh's indices array
  27945. * @param fastCheck defines if only bounding info should be used
  27946. * @returns intersection info or null if no intersection
  27947. */
  27948. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  27949. /** @hidden */
  27950. _rebuild(): void;
  27951. /**
  27952. * Creates a new submesh from the passed mesh
  27953. * @param newMesh defines the new hosting mesh
  27954. * @param newRenderingMesh defines an optional rendering mesh
  27955. * @returns the new submesh
  27956. */
  27957. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  27958. /**
  27959. * Release associated resources
  27960. */
  27961. dispose(): void;
  27962. /**
  27963. * Creates a new submesh from indices data
  27964. * @param materialIndex the index of the main mesh material
  27965. * @param startIndex the index where to start the copy in the mesh indices array
  27966. * @param indexCount the number of indices to copy then from the startIndex
  27967. * @param mesh the main mesh to create the submesh from
  27968. * @param renderingMesh the optional rendering mesh
  27969. * @returns a new submesh
  27970. */
  27971. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  27972. }
  27973. }
  27974. declare module BABYLON {
  27975. class TransformNode extends Node {
  27976. static BILLBOARDMODE_NONE: number;
  27977. static BILLBOARDMODE_X: number;
  27978. static BILLBOARDMODE_Y: number;
  27979. static BILLBOARDMODE_Z: number;
  27980. static BILLBOARDMODE_ALL: number;
  27981. private _forward;
  27982. private _forwardInverted;
  27983. private _up;
  27984. private _right;
  27985. private _rightInverted;
  27986. private _position;
  27987. private _rotation;
  27988. private _rotationQuaternion;
  27989. protected _scaling: Vector3;
  27990. protected _isDirty: boolean;
  27991. private _transformToBoneReferal;
  27992. /**
  27993. * Set the billboard mode. Default is 0.
  27994. *
  27995. * | Value | Type | Description |
  27996. * | --- | --- | --- |
  27997. * | 0 | BILLBOARDMODE_NONE | |
  27998. * | 1 | BILLBOARDMODE_X | |
  27999. * | 2 | BILLBOARDMODE_Y | |
  28000. * | 4 | BILLBOARDMODE_Z | |
  28001. * | 7 | BILLBOARDMODE_ALL | |
  28002. *
  28003. */
  28004. billboardMode: number;
  28005. scalingDeterminant: number;
  28006. infiniteDistance: boolean;
  28007. /**
  28008. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  28009. * By default the system will update normals to compensate
  28010. */
  28011. ignoreNonUniformScaling: boolean;
  28012. /** @hidden */
  28013. _poseMatrix: Matrix;
  28014. private _localWorld;
  28015. private _absolutePosition;
  28016. private _pivotMatrix;
  28017. private _pivotMatrixInverse;
  28018. private _postMultiplyPivotMatrix;
  28019. protected _isWorldMatrixFrozen: boolean;
  28020. /**
  28021. * An event triggered after the world matrix is updated
  28022. */
  28023. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  28024. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  28025. /**
  28026. * Gets a string identifying the name of the class
  28027. * @returns "TransformNode" string
  28028. */
  28029. getClassName(): string;
  28030. /**
  28031. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  28032. */
  28033. position: Vector3;
  28034. /**
  28035. * 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)).
  28036. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  28037. */
  28038. rotation: Vector3;
  28039. /**
  28040. * 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)).
  28041. */
  28042. scaling: Vector3;
  28043. /**
  28044. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  28045. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  28046. */
  28047. rotationQuaternion: Nullable<Quaternion>;
  28048. /**
  28049. * The forward direction of that transform in world space.
  28050. */
  28051. readonly forward: Vector3;
  28052. /**
  28053. * The up direction of that transform in world space.
  28054. */
  28055. readonly up: Vector3;
  28056. /**
  28057. * The right direction of that transform in world space.
  28058. */
  28059. readonly right: Vector3;
  28060. /**
  28061. * Copies the parameter passed Matrix into the mesh Pose matrix.
  28062. * Returns the TransformNode.
  28063. */
  28064. updatePoseMatrix(matrix: Matrix): TransformNode;
  28065. /**
  28066. * Returns the mesh Pose matrix.
  28067. * Returned object : Matrix
  28068. */
  28069. getPoseMatrix(): Matrix;
  28070. /** @hidden */
  28071. _isSynchronized(): boolean;
  28072. /** @hidden */
  28073. _initCache(): void;
  28074. markAsDirty(property: string): TransformNode;
  28075. /**
  28076. * Returns the current mesh absolute position.
  28077. * Returns a Vector3.
  28078. */
  28079. readonly absolutePosition: Vector3;
  28080. /**
  28081. * Sets a new matrix to apply before all other transformation
  28082. * @param matrix defines the transform matrix
  28083. * @returns the current TransformNode
  28084. */
  28085. setPreTransformMatrix(matrix: Matrix): TransformNode;
  28086. /**
  28087. * Sets a new pivot matrix to the current node
  28088. * @param matrix defines the new pivot matrix to use
  28089. * @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
  28090. * @returns the current TransformNode
  28091. */
  28092. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  28093. /**
  28094. * Returns the mesh pivot matrix.
  28095. * Default : Identity.
  28096. * A Matrix is returned.
  28097. */
  28098. getPivotMatrix(): Matrix;
  28099. /**
  28100. * Prevents the World matrix to be computed any longer.
  28101. * Returns the TransformNode.
  28102. */
  28103. freezeWorldMatrix(): TransformNode;
  28104. /**
  28105. * Allows back the World matrix computation.
  28106. * Returns the TransformNode.
  28107. */
  28108. unfreezeWorldMatrix(): this;
  28109. /**
  28110. * True if the World matrix has been frozen.
  28111. * Returns a boolean.
  28112. */
  28113. readonly isWorldMatrixFrozen: boolean;
  28114. /**
  28115. * Retuns the mesh absolute position in the World.
  28116. * Returns a Vector3.
  28117. */
  28118. getAbsolutePosition(): Vector3;
  28119. /**
  28120. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  28121. * Returns the TransformNode.
  28122. */
  28123. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28124. /**
  28125. * Sets the mesh position in its local space.
  28126. * Returns the TransformNode.
  28127. */
  28128. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  28129. /**
  28130. * Returns the mesh position in the local space from the current World matrix values.
  28131. * Returns a new Vector3.
  28132. */
  28133. getPositionExpressedInLocalSpace(): Vector3;
  28134. /**
  28135. * Translates the mesh along the passed Vector3 in its local space.
  28136. * Returns the TransformNode.
  28137. */
  28138. locallyTranslate(vector3: Vector3): TransformNode;
  28139. private static _lookAtVectorCache;
  28140. /**
  28141. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  28142. * @param targetPoint the position (must be in same space as current mesh) to look at
  28143. * @param yawCor optional yaw (y-axis) correction in radians
  28144. * @param pitchCor optional pitch (x-axis) correction in radians
  28145. * @param rollCor optional roll (z-axis) correction in radians
  28146. * @param space the choosen space of the target
  28147. * @returns the TransformNode.
  28148. */
  28149. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  28150. /**
  28151. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  28152. * This Vector3 is expressed in the World space.
  28153. */
  28154. getDirection(localAxis: Vector3): Vector3;
  28155. /**
  28156. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  28157. * localAxis is expressed in the mesh local space.
  28158. * result is computed in the Wordl space from the mesh World matrix.
  28159. * Returns the TransformNode.
  28160. */
  28161. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  28162. /**
  28163. * Sets a new pivot point to the current node
  28164. * @param point defines the new pivot point to use
  28165. * @param space defines if the point is in world or local space (local by default)
  28166. * @returns the current TransformNode
  28167. */
  28168. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  28169. /**
  28170. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  28171. */
  28172. getPivotPoint(): Vector3;
  28173. /**
  28174. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  28175. * Returns the TransformNode.
  28176. */
  28177. getPivotPointToRef(result: Vector3): TransformNode;
  28178. /**
  28179. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  28180. */
  28181. getAbsolutePivotPoint(): Vector3;
  28182. /**
  28183. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  28184. * Returns the TransformNode.
  28185. */
  28186. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  28187. /**
  28188. * Defines the passed node as the parent of the current node.
  28189. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  28190. * Returns the TransformNode.
  28191. */
  28192. setParent(node: Nullable<Node>): TransformNode;
  28193. private _nonUniformScaling;
  28194. readonly nonUniformScaling: boolean;
  28195. /** @hidden */
  28196. _updateNonUniformScalingState(value: boolean): boolean;
  28197. /**
  28198. * Attach the current TransformNode to another TransformNode associated with a bone
  28199. * @param bone Bone affecting the TransformNode
  28200. * @param affectedTransformNode TransformNode associated with the bone
  28201. */
  28202. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  28203. detachFromBone(): TransformNode;
  28204. private static _rotationAxisCache;
  28205. /**
  28206. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  28207. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  28208. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28209. * The passed axis is also normalized.
  28210. * Returns the TransformNode.
  28211. */
  28212. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28213. /**
  28214. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  28215. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  28216. * The passed axis is also normalized.
  28217. * Returns the TransformNode.
  28218. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  28219. */
  28220. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  28221. /**
  28222. * Translates the mesh along the axis vector for the passed distance in the given space.
  28223. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  28224. * Returns the TransformNode.
  28225. */
  28226. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28227. /**
  28228. * Adds a rotation step to the mesh current rotation.
  28229. * x, y, z are Euler angles expressed in radians.
  28230. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  28231. * This means this rotation is made in the mesh local space only.
  28232. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  28233. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  28234. * ```javascript
  28235. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  28236. * ```
  28237. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  28238. * 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.
  28239. * Returns the TransformNode.
  28240. */
  28241. addRotation(x: number, y: number, z: number): TransformNode;
  28242. /**
  28243. * Computes the world matrix of the node
  28244. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28245. * @returns the world matrix
  28246. */
  28247. computeWorldMatrix(force?: boolean): Matrix;
  28248. protected _afterComputeWorldMatrix(): void;
  28249. /**
  28250. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  28251. * @param func: callback function to add
  28252. *
  28253. * Returns the TransformNode.
  28254. */
  28255. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28256. /**
  28257. * Removes a registered callback function.
  28258. * Returns the TransformNode.
  28259. */
  28260. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  28261. /**
  28262. * Clone the current transform node
  28263. * Returns the new transform node
  28264. * @param name Name of the new clone
  28265. * @param newParent New parent for the clone
  28266. * @param doNotCloneChildren Do not clone children hierarchy
  28267. */
  28268. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  28269. serialize(currentSerializationObject?: any): any;
  28270. /**
  28271. * Returns a new TransformNode object parsed from the source provided.
  28272. * The parameter `parsedMesh` is the source.
  28273. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  28274. */
  28275. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  28276. /**
  28277. * Releases resources associated with this transform node.
  28278. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28279. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28280. */
  28281. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28282. }
  28283. }
  28284. declare module BABYLON {
  28285. /**
  28286. * Specialized buffer used to store vertex data
  28287. */
  28288. class VertexBuffer {
  28289. /** @hidden */
  28290. _buffer: Buffer;
  28291. private _kind;
  28292. private _size;
  28293. private _ownsBuffer;
  28294. private _instanced;
  28295. private _instanceDivisor;
  28296. /**
  28297. * The byte type.
  28298. */
  28299. static readonly BYTE: number;
  28300. /**
  28301. * The unsigned byte type.
  28302. */
  28303. static readonly UNSIGNED_BYTE: number;
  28304. /**
  28305. * The short type.
  28306. */
  28307. static readonly SHORT: number;
  28308. /**
  28309. * The unsigned short type.
  28310. */
  28311. static readonly UNSIGNED_SHORT: number;
  28312. /**
  28313. * The integer type.
  28314. */
  28315. static readonly INT: number;
  28316. /**
  28317. * The unsigned integer type.
  28318. */
  28319. static readonly UNSIGNED_INT: number;
  28320. /**
  28321. * The float type.
  28322. */
  28323. static readonly FLOAT: number;
  28324. /**
  28325. * Gets or sets the instance divisor when in instanced mode
  28326. */
  28327. instanceDivisor: number;
  28328. /**
  28329. * Gets the byte stride.
  28330. */
  28331. readonly byteStride: number;
  28332. /**
  28333. * Gets the byte offset.
  28334. */
  28335. readonly byteOffset: number;
  28336. /**
  28337. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  28338. */
  28339. readonly normalized: boolean;
  28340. /**
  28341. * Gets the data type of each component in the array.
  28342. */
  28343. readonly type: number;
  28344. /**
  28345. * Constructor
  28346. * @param engine the engine
  28347. * @param data the data to use for this vertex buffer
  28348. * @param kind the vertex buffer kind
  28349. * @param updatable whether the data is updatable
  28350. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  28351. * @param stride the stride (optional)
  28352. * @param instanced whether the buffer is instanced (optional)
  28353. * @param offset the offset of the data (optional)
  28354. * @param size the number of components (optional)
  28355. * @param type the type of the component (optional)
  28356. * @param normalized whether the data contains normalized data (optional)
  28357. * @param useBytes set to true if stride and offset are in bytes (optional)
  28358. */
  28359. 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);
  28360. /** @hidden */
  28361. _rebuild(): void;
  28362. /**
  28363. * Returns the kind of the VertexBuffer (string)
  28364. * @returns a string
  28365. */
  28366. getKind(): string;
  28367. /**
  28368. * Gets a boolean indicating if the VertexBuffer is updatable?
  28369. * @returns true if the buffer is updatable
  28370. */
  28371. isUpdatable(): boolean;
  28372. /**
  28373. * Gets current buffer's data
  28374. * @returns a DataArray or null
  28375. */
  28376. getData(): Nullable<DataArray>;
  28377. /**
  28378. * Gets underlying native buffer
  28379. * @returns underlying native buffer
  28380. */
  28381. getBuffer(): Nullable<WebGLBuffer>;
  28382. /**
  28383. * Gets the stride in float32 units (i.e. byte stride / 4).
  28384. * May not be an integer if the byte stride is not divisible by 4.
  28385. * DEPRECATED. Use byteStride instead.
  28386. * @returns the stride in float32 units
  28387. */
  28388. getStrideSize(): number;
  28389. /**
  28390. * Returns the offset as a multiple of the type byte length.
  28391. * DEPRECATED. Use byteOffset instead.
  28392. * @returns the offset in bytes
  28393. */
  28394. getOffset(): number;
  28395. /**
  28396. * Returns the number of components per vertex attribute (integer)
  28397. * @returns the size in float
  28398. */
  28399. getSize(): number;
  28400. /**
  28401. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  28402. * @returns true if this buffer is instanced
  28403. */
  28404. getIsInstanced(): boolean;
  28405. /**
  28406. * Returns the instancing divisor, zero for non-instanced (integer).
  28407. * @returns a number
  28408. */
  28409. getInstanceDivisor(): number;
  28410. /**
  28411. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  28412. * @param data defines the data to store
  28413. */
  28414. create(data?: DataArray): void;
  28415. /**
  28416. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  28417. * This function will create a new buffer if the current one is not updatable
  28418. * @param data defines the data to store
  28419. */
  28420. update(data: DataArray): void;
  28421. /**
  28422. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  28423. * Returns the directly updated WebGLBuffer.
  28424. * @param data the new data
  28425. * @param offset the new offset
  28426. * @param useBytes set to true if the offset is in bytes
  28427. */
  28428. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  28429. /**
  28430. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  28431. */
  28432. dispose(): void;
  28433. /**
  28434. * Enumerates each value of this vertex buffer as numbers.
  28435. * @param count the number of values to enumerate
  28436. * @param callback the callback function called for each value
  28437. */
  28438. forEach(count: number, callback: (value: number, index: number) => void): void;
  28439. /**
  28440. * Positions
  28441. */
  28442. static readonly PositionKind: string;
  28443. /**
  28444. * Normals
  28445. */
  28446. static readonly NormalKind: string;
  28447. /**
  28448. * Tangents
  28449. */
  28450. static readonly TangentKind: string;
  28451. /**
  28452. * Texture coordinates
  28453. */
  28454. static readonly UVKind: string;
  28455. /**
  28456. * Texture coordinates 2
  28457. */
  28458. static readonly UV2Kind: string;
  28459. /**
  28460. * Texture coordinates 3
  28461. */
  28462. static readonly UV3Kind: string;
  28463. /**
  28464. * Texture coordinates 4
  28465. */
  28466. static readonly UV4Kind: string;
  28467. /**
  28468. * Texture coordinates 5
  28469. */
  28470. static readonly UV5Kind: string;
  28471. /**
  28472. * Texture coordinates 6
  28473. */
  28474. static readonly UV6Kind: string;
  28475. /**
  28476. * Colors
  28477. */
  28478. static readonly ColorKind: string;
  28479. /**
  28480. * Matrix indices (for bones)
  28481. */
  28482. static readonly MatricesIndicesKind: string;
  28483. /**
  28484. * Matrix weights (for bones)
  28485. */
  28486. static readonly MatricesWeightsKind: string;
  28487. /**
  28488. * Additional matrix indices (for bones)
  28489. */
  28490. static readonly MatricesIndicesExtraKind: string;
  28491. /**
  28492. * Additional matrix weights (for bones)
  28493. */
  28494. static readonly MatricesWeightsExtraKind: string;
  28495. /**
  28496. * Deduces the stride given a kind.
  28497. * @param kind The kind string to deduce
  28498. * @returns The deduced stride
  28499. */
  28500. static DeduceStride(kind: string): number;
  28501. /**
  28502. * Gets the byte length of the given type.
  28503. * @param type the type
  28504. * @returns the number of bytes
  28505. */
  28506. static GetTypeByteLength(type: number): number;
  28507. /**
  28508. * Enumerates each value of the given parameters as numbers.
  28509. * @param data the data to enumerate
  28510. * @param byteOffset the byte offset of the data
  28511. * @param byteStride the byte stride of the data
  28512. * @param componentCount the number of components per element
  28513. * @param componentType the type of the component
  28514. * @param count the total number of components
  28515. * @param normalized whether the data is normalized
  28516. * @param callback the callback function called for each value
  28517. */
  28518. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  28519. private static _GetFloatValue;
  28520. }
  28521. }
  28522. declare module BABYLON {
  28523. /**
  28524. * Defines a target to use with MorphTargetManager
  28525. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28526. */
  28527. class MorphTarget implements IAnimatable {
  28528. /** defines the name of the target */
  28529. name: string;
  28530. /**
  28531. * Gets or sets the list of animations
  28532. */
  28533. animations: Animation[];
  28534. private _scene;
  28535. private _positions;
  28536. private _normals;
  28537. private _tangents;
  28538. private _influence;
  28539. /**
  28540. * Observable raised when the influence changes
  28541. */
  28542. onInfluenceChanged: Observable<boolean>;
  28543. /**
  28544. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  28545. */
  28546. influence: number;
  28547. private _animationPropertiesOverride;
  28548. /**
  28549. * Gets or sets the animation properties override
  28550. */
  28551. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28552. /**
  28553. * Creates a new MorphTarget
  28554. * @param name defines the name of the target
  28555. * @param influence defines the influence to use
  28556. */
  28557. constructor(
  28558. /** defines the name of the target */
  28559. name: string, influence?: number, scene?: Nullable<Scene>);
  28560. /**
  28561. * Gets a boolean defining if the target contains position data
  28562. */
  28563. readonly hasPositions: boolean;
  28564. /**
  28565. * Gets a boolean defining if the target contains normal data
  28566. */
  28567. readonly hasNormals: boolean;
  28568. /**
  28569. * Gets a boolean defining if the target contains tangent data
  28570. */
  28571. readonly hasTangents: boolean;
  28572. /**
  28573. * Affects position data to this target
  28574. * @param data defines the position data to use
  28575. */
  28576. setPositions(data: Nullable<FloatArray>): void;
  28577. /**
  28578. * Gets the position data stored in this target
  28579. * @returns a FloatArray containing the position data (or null if not present)
  28580. */
  28581. getPositions(): Nullable<FloatArray>;
  28582. /**
  28583. * Affects normal data to this target
  28584. * @param data defines the normal data to use
  28585. */
  28586. setNormals(data: Nullable<FloatArray>): void;
  28587. /**
  28588. * Gets the normal data stored in this target
  28589. * @returns a FloatArray containing the normal data (or null if not present)
  28590. */
  28591. getNormals(): Nullable<FloatArray>;
  28592. /**
  28593. * Affects tangent data to this target
  28594. * @param data defines the tangent data to use
  28595. */
  28596. setTangents(data: Nullable<FloatArray>): void;
  28597. /**
  28598. * Gets the tangent data stored in this target
  28599. * @returns a FloatArray containing the tangent data (or null if not present)
  28600. */
  28601. getTangents(): Nullable<FloatArray>;
  28602. /**
  28603. * Serializes the current target into a Serialization object
  28604. * @returns the serialized object
  28605. */
  28606. serialize(): any;
  28607. /**
  28608. * Creates a new target from serialized data
  28609. * @param serializationObject defines the serialized data to use
  28610. * @returns a new MorphTarget
  28611. */
  28612. static Parse(serializationObject: any): MorphTarget;
  28613. /**
  28614. * Creates a MorphTarget from mesh data
  28615. * @param mesh defines the source mesh
  28616. * @param name defines the name to use for the new target
  28617. * @param influence defines the influence to attach to the target
  28618. * @returns a new MorphTarget
  28619. */
  28620. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  28621. }
  28622. }
  28623. declare module BABYLON {
  28624. /**
  28625. * This class is used to deform meshes using morphing between different targets
  28626. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28627. */
  28628. class MorphTargetManager {
  28629. private _targets;
  28630. private _targetObservable;
  28631. private _activeTargets;
  28632. private _scene;
  28633. private _influences;
  28634. private _supportsNormals;
  28635. private _supportsTangents;
  28636. private _vertexCount;
  28637. private _uniqueId;
  28638. private _tempInfluences;
  28639. /**
  28640. * Creates a new MorphTargetManager
  28641. * @param scene defines the current scene
  28642. */
  28643. constructor(scene?: Nullable<Scene>);
  28644. /**
  28645. * Gets the unique ID of this manager
  28646. */
  28647. readonly uniqueId: number;
  28648. /**
  28649. * Gets the number of vertices handled by this manager
  28650. */
  28651. readonly vertexCount: number;
  28652. /**
  28653. * Gets a boolean indicating if this manager supports morphing of normals
  28654. */
  28655. readonly supportsNormals: boolean;
  28656. /**
  28657. * Gets a boolean indicating if this manager supports morphing of tangents
  28658. */
  28659. readonly supportsTangents: boolean;
  28660. /**
  28661. * Gets the number of targets stored in this manager
  28662. */
  28663. readonly numTargets: number;
  28664. /**
  28665. * Gets the number of influencers (ie. the number of targets with influences > 0)
  28666. */
  28667. readonly numInfluencers: number;
  28668. /**
  28669. * Gets the list of influences (one per target)
  28670. */
  28671. readonly influences: Float32Array;
  28672. /**
  28673. * Gets the active target at specified index. An active target is a target with an influence > 0
  28674. * @param index defines the index to check
  28675. * @returns the requested target
  28676. */
  28677. getActiveTarget(index: number): MorphTarget;
  28678. /**
  28679. * Gets the target at specified index
  28680. * @param index defines the index to check
  28681. * @returns the requested target
  28682. */
  28683. getTarget(index: number): MorphTarget;
  28684. /**
  28685. * Add a new target to this manager
  28686. * @param target defines the target to add
  28687. */
  28688. addTarget(target: MorphTarget): void;
  28689. /**
  28690. * Removes a target from the manager
  28691. * @param target defines the target to remove
  28692. */
  28693. removeTarget(target: MorphTarget): void;
  28694. /**
  28695. * Serializes the current manager into a Serialization object
  28696. * @returns the serialized object
  28697. */
  28698. serialize(): any;
  28699. private _syncActiveTargets;
  28700. /**
  28701. * Syncrhonize the targets with all the meshes using this morph target manager
  28702. */
  28703. synchronize(): void;
  28704. /**
  28705. * Creates a new MorphTargetManager from serialized data
  28706. * @param serializationObject defines the serialized data
  28707. * @param scene defines the hosting scene
  28708. * @returns the new MorphTargetManager
  28709. */
  28710. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  28711. }
  28712. }
  28713. declare module BABYLON {
  28714. /**
  28715. * This represents the base class for particle system in Babylon.
  28716. * 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.
  28717. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  28718. * @example https://doc.babylonjs.com/babylon101/particles
  28719. */
  28720. class BaseParticleSystem {
  28721. /**
  28722. * Source color is added to the destination color without alpha affecting the result
  28723. */
  28724. static BLENDMODE_ONEONE: number;
  28725. /**
  28726. * Blend current color and particle color using particle’s alpha
  28727. */
  28728. static BLENDMODE_STANDARD: number;
  28729. /**
  28730. * Add current color and particle color multiplied by particle’s alpha
  28731. */
  28732. static BLENDMODE_ADD: number;
  28733. /**
  28734. * Multiply current color with particle color
  28735. */
  28736. static BLENDMODE_MULTIPLY: number;
  28737. /**
  28738. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  28739. */
  28740. static BLENDMODE_MULTIPLYADD: number;
  28741. /**
  28742. * List of animations used by the particle system.
  28743. */
  28744. animations: Animation[];
  28745. /**
  28746. * The id of the Particle system.
  28747. */
  28748. id: string;
  28749. /**
  28750. * The friendly name of the Particle system.
  28751. */
  28752. name: string;
  28753. /**
  28754. * The rendering group used by the Particle system to chose when to render.
  28755. */
  28756. renderingGroupId: number;
  28757. /**
  28758. * The emitter represents the Mesh or position we are attaching the particle system to.
  28759. */
  28760. emitter: Nullable<AbstractMesh | Vector3>;
  28761. /**
  28762. * The maximum number of particles to emit per frame
  28763. */
  28764. emitRate: number;
  28765. /**
  28766. * If you want to launch only a few particles at once, that can be done, as well.
  28767. */
  28768. manualEmitCount: number;
  28769. /**
  28770. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  28771. */
  28772. updateSpeed: number;
  28773. /**
  28774. * The amount of time the particle system is running (depends of the overall update speed).
  28775. */
  28776. targetStopDuration: number;
  28777. /**
  28778. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  28779. */
  28780. disposeOnStop: boolean;
  28781. /**
  28782. * Minimum power of emitting particles.
  28783. */
  28784. minEmitPower: number;
  28785. /**
  28786. * Maximum power of emitting particles.
  28787. */
  28788. maxEmitPower: number;
  28789. /**
  28790. * Minimum life time of emitting particles.
  28791. */
  28792. minLifeTime: number;
  28793. /**
  28794. * Maximum life time of emitting particles.
  28795. */
  28796. maxLifeTime: number;
  28797. /**
  28798. * Minimum Size of emitting particles.
  28799. */
  28800. minSize: number;
  28801. /**
  28802. * Maximum Size of emitting particles.
  28803. */
  28804. maxSize: number;
  28805. /**
  28806. * Minimum scale of emitting particles on X axis.
  28807. */
  28808. minScaleX: number;
  28809. /**
  28810. * Maximum scale of emitting particles on X axis.
  28811. */
  28812. maxScaleX: number;
  28813. /**
  28814. * Minimum scale of emitting particles on Y axis.
  28815. */
  28816. minScaleY: number;
  28817. /**
  28818. * Maximum scale of emitting particles on Y axis.
  28819. */
  28820. maxScaleY: number;
  28821. /**
  28822. * Gets or sets the minimal initial rotation in radians.
  28823. */
  28824. minInitialRotation: number;
  28825. /**
  28826. * Gets or sets the maximal initial rotation in radians.
  28827. */
  28828. maxInitialRotation: number;
  28829. /**
  28830. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  28831. */
  28832. minAngularSpeed: number;
  28833. /**
  28834. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  28835. */
  28836. maxAngularSpeed: number;
  28837. /**
  28838. * The texture used to render each particle. (this can be a spritesheet)
  28839. */
  28840. particleTexture: Nullable<Texture>;
  28841. /**
  28842. * The layer mask we are rendering the particles through.
  28843. */
  28844. layerMask: number;
  28845. /**
  28846. * This can help using your own shader to render the particle system.
  28847. * The according effect will be created
  28848. */
  28849. customShader: any;
  28850. /**
  28851. * By default particle system starts as soon as they are created. This prevents the
  28852. * automatic start to happen and let you decide when to start emitting particles.
  28853. */
  28854. preventAutoStart: boolean;
  28855. /**
  28856. * Gets or sets a texture used to add random noise to particle positions
  28857. */
  28858. noiseTexture: Nullable<ProceduralTexture>;
  28859. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  28860. noiseStrength: Vector3;
  28861. /**
  28862. * Callback triggered when the particle animation is ending.
  28863. */
  28864. onAnimationEnd: Nullable<() => void>;
  28865. /**
  28866. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  28867. */
  28868. blendMode: number;
  28869. /**
  28870. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  28871. * to override the particles.
  28872. */
  28873. forceDepthWrite: boolean;
  28874. /** 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 */
  28875. preWarmCycles: number;
  28876. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  28877. preWarmStepOffset: number;
  28878. /**
  28879. * 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)
  28880. */
  28881. spriteCellChangeSpeed: number;
  28882. /**
  28883. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  28884. */
  28885. startSpriteCellID: number;
  28886. /**
  28887. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  28888. */
  28889. endSpriteCellID: number;
  28890. /**
  28891. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  28892. */
  28893. spriteCellWidth: number;
  28894. /**
  28895. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  28896. */
  28897. spriteCellHeight: number;
  28898. /**
  28899. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  28900. */
  28901. spriteRandomStartCell: boolean;
  28902. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  28903. translationPivot: Vector2;
  28904. /** @hidden */
  28905. protected _isAnimationSheetEnabled: boolean;
  28906. /**
  28907. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  28908. */
  28909. beginAnimationOnStart: boolean;
  28910. /**
  28911. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  28912. */
  28913. beginAnimationFrom: number;
  28914. /**
  28915. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  28916. */
  28917. beginAnimationTo: number;
  28918. /**
  28919. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  28920. */
  28921. beginAnimationLoop: boolean;
  28922. /**
  28923. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  28924. */
  28925. isAnimationSheetEnabled: boolean;
  28926. /**
  28927. * Get hosting scene
  28928. * @returns the scene
  28929. */
  28930. getScene(): Scene;
  28931. /**
  28932. * You can use gravity if you want to give an orientation to your particles.
  28933. */
  28934. gravity: Vector3;
  28935. protected _colorGradients: Nullable<Array<ColorGradient>>;
  28936. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  28937. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  28938. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  28939. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  28940. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  28941. protected _dragGradients: Nullable<Array<FactorGradient>>;
  28942. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  28943. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  28944. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  28945. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  28946. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  28947. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  28948. /**
  28949. * Defines the delay in milliseconds before starting the system (0 by default)
  28950. */
  28951. startDelay: number;
  28952. /**
  28953. * Gets the current list of drag gradients.
  28954. * You must use addDragGradient and removeDragGradient to udpate this list
  28955. * @returns the list of drag gradients
  28956. */
  28957. getDragGradients(): Nullable<Array<FactorGradient>>;
  28958. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  28959. limitVelocityDamping: number;
  28960. /**
  28961. * Gets the current list of limit velocity gradients.
  28962. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  28963. * @returns the list of limit velocity gradients
  28964. */
  28965. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  28966. /**
  28967. * Gets the current list of color gradients.
  28968. * You must use addColorGradient and removeColorGradient to udpate this list
  28969. * @returns the list of color gradients
  28970. */
  28971. getColorGradients(): Nullable<Array<ColorGradient>>;
  28972. /**
  28973. * Gets the current list of size gradients.
  28974. * You must use addSizeGradient and removeSizeGradient to udpate this list
  28975. * @returns the list of size gradients
  28976. */
  28977. getSizeGradients(): Nullable<Array<FactorGradient>>;
  28978. /**
  28979. * Gets the current list of color remap gradients.
  28980. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  28981. * @returns the list of color remap gradients
  28982. */
  28983. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  28984. /**
  28985. * Gets the current list of alpha remap gradients.
  28986. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  28987. * @returns the list of alpha remap gradients
  28988. */
  28989. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  28990. /**
  28991. * Gets the current list of life time gradients.
  28992. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  28993. * @returns the list of life time gradients
  28994. */
  28995. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  28996. /**
  28997. * Gets the current list of angular speed gradients.
  28998. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  28999. * @returns the list of angular speed gradients
  29000. */
  29001. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  29002. /**
  29003. * Gets the current list of velocity gradients.
  29004. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  29005. * @returns the list of velocity gradients
  29006. */
  29007. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  29008. /**
  29009. * Gets the current list of start size gradients.
  29010. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  29011. * @returns the list of start size gradients
  29012. */
  29013. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  29014. /**
  29015. * Gets the current list of emit rate gradients.
  29016. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  29017. * @returns the list of emit rate gradients
  29018. */
  29019. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  29020. /**
  29021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29022. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29023. */
  29024. direction1: Vector3;
  29025. /**
  29026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  29027. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29028. */
  29029. direction2: Vector3;
  29030. /**
  29031. * 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.
  29032. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29033. */
  29034. minEmitBox: Vector3;
  29035. /**
  29036. * 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.
  29037. * This only works when particleEmitterTyps is a BoxParticleEmitter
  29038. */
  29039. maxEmitBox: Vector3;
  29040. /**
  29041. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  29042. */
  29043. color1: Color4;
  29044. /**
  29045. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  29046. */
  29047. color2: Color4;
  29048. /**
  29049. * Color the particle will have at the end of its lifetime
  29050. */
  29051. colorDead: Color4;
  29052. /**
  29053. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  29054. */
  29055. textureMask: Color4;
  29056. /**
  29057. * The particle emitter type defines the emitter used by the particle system.
  29058. * It can be for example box, sphere, or cone...
  29059. */
  29060. particleEmitterType: IParticleEmitterType;
  29061. /** @hidden */
  29062. _isSubEmitter: boolean;
  29063. /**
  29064. * Gets or sets the billboard mode to use when isBillboardBased = true.
  29065. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  29066. */
  29067. billboardMode: number;
  29068. protected _isBillboardBased: boolean;
  29069. /**
  29070. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  29071. */
  29072. isBillboardBased: boolean;
  29073. /**
  29074. * The scene the particle system belongs to.
  29075. */
  29076. protected _scene: Scene;
  29077. /**
  29078. * Local cache of defines for image processing.
  29079. */
  29080. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  29081. /**
  29082. * Default configuration related to image processing available in the standard Material.
  29083. */
  29084. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29085. /**
  29086. * Gets the image processing configuration used either in this material.
  29087. */
  29088. /**
  29089. * Sets the Default image processing configuration used either in the this material.
  29090. *
  29091. * If sets to null, the scene one is in use.
  29092. */
  29093. imageProcessingConfiguration: ImageProcessingConfiguration;
  29094. /**
  29095. * Attaches a new image processing configuration to the Standard Material.
  29096. * @param configuration
  29097. */
  29098. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29099. /** @hidden */
  29100. protected _reset(): void;
  29101. /** @hidden */
  29102. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  29103. /**
  29104. * Instantiates a particle system.
  29105. * 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.
  29106. * @param name The name of the particle system
  29107. */
  29108. constructor(name: string);
  29109. /**
  29110. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  29111. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  29112. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  29113. * @returns the emitter
  29114. */
  29115. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  29116. /**
  29117. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  29118. * @param radius The radius of the hemisphere to emit from
  29119. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  29120. * @returns the emitter
  29121. */
  29122. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  29123. /**
  29124. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  29125. * @param radius The radius of the sphere to emit from
  29126. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  29127. * @returns the emitter
  29128. */
  29129. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  29130. /**
  29131. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  29132. * @param radius The radius of the sphere to emit from
  29133. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  29134. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  29135. * @returns the emitter
  29136. */
  29137. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  29138. /**
  29139. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  29140. * @param radius The radius of the emission cylinder
  29141. * @param height The height of the emission cylinder
  29142. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  29143. * @param directionRandomizer How much to randomize the particle direction [0-1]
  29144. * @returns the emitter
  29145. */
  29146. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  29147. /**
  29148. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  29149. * @param radius The radius of the cylinder to emit from
  29150. * @param height The height of the emission cylinder
  29151. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  29152. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  29153. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  29154. * @returns the emitter
  29155. */
  29156. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  29157. /**
  29158. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  29159. * @param radius The radius of the cone to emit from
  29160. * @param angle The base angle of the cone
  29161. * @returns the emitter
  29162. */
  29163. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  29164. /**
  29165. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  29166. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  29167. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  29168. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  29169. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  29170. * @returns the emitter
  29171. */
  29172. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  29173. }
  29174. }
  29175. declare module BABYLON {
  29176. /**
  29177. * This represents a GPU particle system in Babylon
  29178. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  29179. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  29180. */
  29181. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  29182. /**
  29183. * The layer mask we are rendering the particles through.
  29184. */
  29185. layerMask: number;
  29186. private _capacity;
  29187. private _activeCount;
  29188. private _currentActiveCount;
  29189. private _accumulatedCount;
  29190. private _renderEffect;
  29191. private _updateEffect;
  29192. private _buffer0;
  29193. private _buffer1;
  29194. private _spriteBuffer;
  29195. private _updateVAO;
  29196. private _renderVAO;
  29197. private _targetIndex;
  29198. private _sourceBuffer;
  29199. private _targetBuffer;
  29200. private _engine;
  29201. private _currentRenderId;
  29202. private _started;
  29203. private _stopped;
  29204. private _timeDelta;
  29205. private _randomTexture;
  29206. private _randomTexture2;
  29207. private _attributesStrideSize;
  29208. private _updateEffectOptions;
  29209. private _randomTextureSize;
  29210. private _actualFrame;
  29211. private readonly _rawTextureWidth;
  29212. /**
  29213. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  29214. */
  29215. static readonly IsSupported: boolean;
  29216. /**
  29217. * An event triggered when the system is disposed.
  29218. */
  29219. onDisposeObservable: Observable<GPUParticleSystem>;
  29220. /**
  29221. * Gets the maximum number of particles active at the same time.
  29222. * @returns The max number of active particles.
  29223. */
  29224. getCapacity(): number;
  29225. /**
  29226. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29227. * to override the particles.
  29228. */
  29229. forceDepthWrite: boolean;
  29230. /**
  29231. * Gets or set the number of active particles
  29232. */
  29233. activeParticleCount: number;
  29234. private _preWarmDone;
  29235. /**
  29236. * Is this system ready to be used/rendered
  29237. * @return true if the system is ready
  29238. */
  29239. isReady(): boolean;
  29240. /**
  29241. * Gets if the system has been started. (Note: this will still be true after stop is called)
  29242. * @returns True if it has been started, otherwise false.
  29243. */
  29244. isStarted(): boolean;
  29245. /**
  29246. * Starts the particle system and begins to emit
  29247. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  29248. */
  29249. start(delay?: number): void;
  29250. /**
  29251. * Stops the particle system.
  29252. */
  29253. stop(): void;
  29254. /**
  29255. * Remove all active particles
  29256. */
  29257. reset(): void;
  29258. /**
  29259. * Returns the string "GPUParticleSystem"
  29260. * @returns a string containing the class name
  29261. */
  29262. getClassName(): string;
  29263. private _colorGradientsTexture;
  29264. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  29265. /**
  29266. * Adds a new color gradient
  29267. * @param gradient defines the gradient to use (between 0 and 1)
  29268. * @param color1 defines the color to affect to the specified gradient
  29269. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  29270. * @returns the current particle system
  29271. */
  29272. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  29273. /**
  29274. * Remove a specific color gradient
  29275. * @param gradient defines the gradient to remove
  29276. * @returns the current particle system
  29277. */
  29278. removeColorGradient(gradient: number): GPUParticleSystem;
  29279. private _angularSpeedGradientsTexture;
  29280. private _sizeGradientsTexture;
  29281. private _velocityGradientsTexture;
  29282. private _limitVelocityGradientsTexture;
  29283. private _dragGradientsTexture;
  29284. private _addFactorGradient;
  29285. /**
  29286. * Adds a new size gradient
  29287. * @param gradient defines the gradient to use (between 0 and 1)
  29288. * @param factor defines the size factor to affect to the specified gradient
  29289. * @returns the current particle system
  29290. */
  29291. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  29292. /**
  29293. * Remove a specific size gradient
  29294. * @param gradient defines the gradient to remove
  29295. * @returns the current particle system
  29296. */
  29297. removeSizeGradient(gradient: number): GPUParticleSystem;
  29298. /**
  29299. * Adds a new angular speed gradient
  29300. * @param gradient defines the gradient to use (between 0 and 1)
  29301. * @param factor defines the angular speed to affect to the specified gradient
  29302. * @returns the current particle system
  29303. */
  29304. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  29305. /**
  29306. * Remove a specific angular speed gradient
  29307. * @param gradient defines the gradient to remove
  29308. * @returns the current particle system
  29309. */
  29310. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  29311. /**
  29312. * Adds a new velocity gradient
  29313. * @param gradient defines the gradient to use (between 0 and 1)
  29314. * @param factor defines the velocity to affect to the specified gradient
  29315. * @returns the current particle system
  29316. */
  29317. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  29318. /**
  29319. * Remove a specific velocity gradient
  29320. * @param gradient defines the gradient to remove
  29321. * @returns the current particle system
  29322. */
  29323. removeVelocityGradient(gradient: number): GPUParticleSystem;
  29324. /**
  29325. * Adds a new limit velocity gradient
  29326. * @param gradient defines the gradient to use (between 0 and 1)
  29327. * @param factor defines the limit velocity value to affect to the specified gradient
  29328. * @returns the current particle system
  29329. */
  29330. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  29331. /**
  29332. * Remove a specific limit velocity gradient
  29333. * @param gradient defines the gradient to remove
  29334. * @returns the current particle system
  29335. */
  29336. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  29337. /**
  29338. * Adds a new drag gradient
  29339. * @param gradient defines the gradient to use (between 0 and 1)
  29340. * @param factor defines the drag value to affect to the specified gradient
  29341. * @returns the current particle system
  29342. */
  29343. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  29344. /**
  29345. * Remove a specific drag gradient
  29346. * @param gradient defines the gradient to remove
  29347. * @returns the current particle system
  29348. */
  29349. removeDragGradient(gradient: number): GPUParticleSystem;
  29350. /**
  29351. * Not supported by GPUParticleSystem
  29352. * @param gradient defines the gradient to use (between 0 and 1)
  29353. * @param factor defines the emit rate value to affect to the specified gradient
  29354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29355. * @returns the current particle system
  29356. */
  29357. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29358. /**
  29359. * Not supported by GPUParticleSystem
  29360. * @param gradient defines the gradient to remove
  29361. * @returns the current particle system
  29362. */
  29363. removeEmitRateGradient(gradient: number): IParticleSystem;
  29364. /**
  29365. * Not supported by GPUParticleSystem
  29366. * @param gradient defines the gradient to use (between 0 and 1)
  29367. * @param factor defines the start size value to affect to the specified gradient
  29368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29369. * @returns the current particle system
  29370. */
  29371. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29372. /**
  29373. * Not supported by GPUParticleSystem
  29374. * @param gradient defines the gradient to remove
  29375. * @returns the current particle system
  29376. */
  29377. removeStartSizeGradient(gradient: number): IParticleSystem;
  29378. /**
  29379. * Not supported by GPUParticleSystem
  29380. * @param gradient defines the gradient to use (between 0 and 1)
  29381. * @param min defines the color remap minimal range
  29382. * @param max defines the color remap maximal range
  29383. * @returns the current particle system
  29384. */
  29385. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29386. /**
  29387. * Not supported by GPUParticleSystem
  29388. * @param gradient defines the gradient to remove
  29389. * @returns the current particle system
  29390. */
  29391. removeColorRemapGradient(gradient: number): IParticleSystem;
  29392. /**
  29393. * Not supported by GPUParticleSystem
  29394. * @param gradient defines the gradient to use (between 0 and 1)
  29395. * @param min defines the alpha remap minimal range
  29396. * @param max defines the alpha remap maximal range
  29397. * @returns the current particle system
  29398. */
  29399. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29400. /**
  29401. * Not supported by GPUParticleSystem
  29402. * @param gradient defines the gradient to remove
  29403. * @returns the current particle system
  29404. */
  29405. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  29406. /**
  29407. * Not supported by GPUParticleSystem
  29408. * @param gradient defines the gradient to use (between 0 and 1)
  29409. * @param color defines the color to affect to the specified gradient
  29410. * @returns the current particle system
  29411. */
  29412. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  29413. /**
  29414. * Not supported by GPUParticleSystem
  29415. * @param gradient defines the gradient to remove
  29416. * @returns the current particle system
  29417. */
  29418. removeRampGradient(gradient: number): IParticleSystem;
  29419. /**
  29420. * Not supported by GPUParticleSystem
  29421. * @returns the list of ramp gradients
  29422. */
  29423. getRampGradients(): Nullable<Array<Color3Gradient>>;
  29424. /**
  29425. * Not supported by GPUParticleSystem
  29426. * Gets or sets a boolean indicating that ramp gradients must be used
  29427. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  29428. */
  29429. useRampGradients: boolean;
  29430. /**
  29431. * Not supported by GPUParticleSystem
  29432. * @param gradient defines the gradient to use (between 0 and 1)
  29433. * @param factor defines the life time factor to affect to the specified gradient
  29434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29435. * @returns the current particle system
  29436. */
  29437. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29438. /**
  29439. * Not supported by GPUParticleSystem
  29440. * @param gradient defines the gradient to remove
  29441. * @returns the current particle system
  29442. */
  29443. removeLifeTimeGradient(gradient: number): IParticleSystem;
  29444. /**
  29445. * Instantiates a GPU particle system.
  29446. * 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.
  29447. * @param name The name of the particle system
  29448. * @param options The options used to create the system
  29449. * @param scene The scene the particle system belongs to
  29450. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  29451. */
  29452. constructor(name: string, options: Partial<{
  29453. capacity: number;
  29454. randomTextureSize: number;
  29455. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  29456. protected _reset(): void;
  29457. private _createUpdateVAO;
  29458. private _createRenderVAO;
  29459. private _initialize;
  29460. /** @hidden */
  29461. _recreateUpdateEffect(): void;
  29462. /** @hidden */
  29463. _recreateRenderEffect(): void;
  29464. /**
  29465. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  29466. * @param preWarm defines if we are in the pre-warmimg phase
  29467. */
  29468. animate(preWarm?: boolean): void;
  29469. private _createFactorGradientTexture;
  29470. private _createSizeGradientTexture;
  29471. private _createAngularSpeedGradientTexture;
  29472. private _createVelocityGradientTexture;
  29473. private _createLimitVelocityGradientTexture;
  29474. private _createDragGradientTexture;
  29475. private _createColorGradientTexture;
  29476. /**
  29477. * Renders the particle system in its current state
  29478. * @param preWarm defines if the system should only update the particles but not render them
  29479. * @returns the current number of particles
  29480. */
  29481. render(preWarm?: boolean): number;
  29482. /**
  29483. * Rebuilds the particle system
  29484. */
  29485. rebuild(): void;
  29486. private _releaseBuffers;
  29487. private _releaseVAOs;
  29488. /**
  29489. * Disposes the particle system and free the associated resources
  29490. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  29491. */
  29492. dispose(disposeTexture?: boolean): void;
  29493. /**
  29494. * Clones the particle system.
  29495. * @param name The name of the cloned object
  29496. * @param newEmitter The new emitter to use
  29497. * @returns the cloned particle system
  29498. */
  29499. clone(name: string, newEmitter: any): GPUParticleSystem;
  29500. /**
  29501. * Serializes the particle system to a JSON object.
  29502. * @returns the JSON object
  29503. */
  29504. serialize(): any;
  29505. /**
  29506. * Parses a JSON object to create a GPU particle system.
  29507. * @param parsedParticleSystem The JSON object to parse
  29508. * @param scene The scene to create the particle system in
  29509. * @param rootUrl The root url to use to load external dependencies like texture
  29510. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  29511. * @returns the parsed GPU particle system
  29512. */
  29513. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  29514. }
  29515. }
  29516. declare module BABYLON {
  29517. /**
  29518. * Interface representing a particle system in Babylon.js.
  29519. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  29520. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  29521. */
  29522. interface IParticleSystem {
  29523. /**
  29524. * List of animations used by the particle system.
  29525. */
  29526. animations: Animation[];
  29527. /**
  29528. * The id of the Particle system.
  29529. */
  29530. id: string;
  29531. /**
  29532. * The name of the Particle system.
  29533. */
  29534. name: string;
  29535. /**
  29536. * The emitter represents the Mesh or position we are attaching the particle system to.
  29537. */
  29538. emitter: Nullable<AbstractMesh | Vector3>;
  29539. /**
  29540. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  29541. */
  29542. isBillboardBased: boolean;
  29543. /**
  29544. * The rendering group used by the Particle system to chose when to render.
  29545. */
  29546. renderingGroupId: number;
  29547. /**
  29548. * The layer mask we are rendering the particles through.
  29549. */
  29550. layerMask: number;
  29551. /**
  29552. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  29553. */
  29554. updateSpeed: number;
  29555. /**
  29556. * The amount of time the particle system is running (depends of the overall update speed).
  29557. */
  29558. targetStopDuration: number;
  29559. /**
  29560. * The texture used to render each particle. (this can be a spritesheet)
  29561. */
  29562. particleTexture: Nullable<Texture>;
  29563. /**
  29564. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  29565. */
  29566. blendMode: number;
  29567. /**
  29568. * Minimum life time of emitting particles.
  29569. */
  29570. minLifeTime: number;
  29571. /**
  29572. * Maximum life time of emitting particles.
  29573. */
  29574. maxLifeTime: number;
  29575. /**
  29576. * Minimum Size of emitting particles.
  29577. */
  29578. minSize: number;
  29579. /**
  29580. * Maximum Size of emitting particles.
  29581. */
  29582. maxSize: number;
  29583. /**
  29584. * Minimum scale of emitting particles on X axis.
  29585. */
  29586. minScaleX: number;
  29587. /**
  29588. * Maximum scale of emitting particles on X axis.
  29589. */
  29590. maxScaleX: number;
  29591. /**
  29592. * Minimum scale of emitting particles on Y axis.
  29593. */
  29594. minScaleY: number;
  29595. /**
  29596. * Maximum scale of emitting particles on Y axis.
  29597. */
  29598. maxScaleY: number;
  29599. /**
  29600. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  29601. */
  29602. color1: Color4;
  29603. /**
  29604. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  29605. */
  29606. color2: Color4;
  29607. /**
  29608. * Color the particle will have at the end of its lifetime.
  29609. */
  29610. colorDead: Color4;
  29611. /**
  29612. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  29613. */
  29614. emitRate: number;
  29615. /**
  29616. * You can use gravity if you want to give an orientation to your particles.
  29617. */
  29618. gravity: Vector3;
  29619. /**
  29620. * Minimum power of emitting particles.
  29621. */
  29622. minEmitPower: number;
  29623. /**
  29624. * Maximum power of emitting particles.
  29625. */
  29626. maxEmitPower: number;
  29627. /**
  29628. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  29629. */
  29630. minAngularSpeed: number;
  29631. /**
  29632. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  29633. */
  29634. maxAngularSpeed: number;
  29635. /**
  29636. * Gets or sets the minimal initial rotation in radians.
  29637. */
  29638. minInitialRotation: number;
  29639. /**
  29640. * Gets or sets the maximal initial rotation in radians.
  29641. */
  29642. maxInitialRotation: number;
  29643. /**
  29644. * The particle emitter type defines the emitter used by the particle system.
  29645. * It can be for example box, sphere, or cone...
  29646. */
  29647. particleEmitterType: Nullable<IParticleEmitterType>;
  29648. /**
  29649. * Defines the delay in milliseconds before starting the system (0 by default)
  29650. */
  29651. startDelay: number;
  29652. /**
  29653. * 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
  29654. */
  29655. preWarmCycles: number;
  29656. /**
  29657. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  29658. */
  29659. preWarmStepOffset: number;
  29660. /**
  29661. * 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)
  29662. */
  29663. spriteCellChangeSpeed: number;
  29664. /**
  29665. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  29666. */
  29667. startSpriteCellID: number;
  29668. /**
  29669. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  29670. */
  29671. endSpriteCellID: number;
  29672. /**
  29673. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  29674. */
  29675. spriteCellWidth: number;
  29676. /**
  29677. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  29678. */
  29679. spriteCellHeight: number;
  29680. /**
  29681. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  29682. */
  29683. spriteRandomStartCell: boolean;
  29684. /**
  29685. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  29686. */
  29687. isAnimationSheetEnabled: boolean;
  29688. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  29689. translationPivot: Vector2;
  29690. /**
  29691. * Gets or sets a texture used to add random noise to particle positions
  29692. */
  29693. noiseTexture: Nullable<BaseTexture>;
  29694. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  29695. noiseStrength: Vector3;
  29696. /**
  29697. * Gets or sets the billboard mode to use when isBillboardBased = true.
  29698. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  29699. */
  29700. billboardMode: number;
  29701. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  29702. limitVelocityDamping: number;
  29703. /**
  29704. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  29705. */
  29706. beginAnimationOnStart: boolean;
  29707. /**
  29708. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  29709. */
  29710. beginAnimationFrom: number;
  29711. /**
  29712. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  29713. */
  29714. beginAnimationTo: number;
  29715. /**
  29716. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  29717. */
  29718. beginAnimationLoop: boolean;
  29719. /**
  29720. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  29721. */
  29722. disposeOnStop: boolean;
  29723. /**
  29724. * Gets the maximum number of particles active at the same time.
  29725. * @returns The max number of active particles.
  29726. */
  29727. getCapacity(): number;
  29728. /**
  29729. * Gets if the system has been started. (Note: this will still be true after stop is called)
  29730. * @returns True if it has been started, otherwise false.
  29731. */
  29732. isStarted(): boolean;
  29733. /**
  29734. * Animates the particle system for this frame.
  29735. */
  29736. animate(): void;
  29737. /**
  29738. * Renders the particle system in its current state.
  29739. * @returns the current number of particles
  29740. */
  29741. render(): number;
  29742. /**
  29743. * Dispose the particle system and frees its associated resources.
  29744. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  29745. */
  29746. dispose(disposeTexture?: boolean): void;
  29747. /**
  29748. * Clones the particle system.
  29749. * @param name The name of the cloned object
  29750. * @param newEmitter The new emitter to use
  29751. * @returns the cloned particle system
  29752. */
  29753. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  29754. /**
  29755. * Serializes the particle system to a JSON object.
  29756. * @returns the JSON object
  29757. */
  29758. serialize(): any;
  29759. /**
  29760. * Rebuild the particle system
  29761. */
  29762. rebuild(): void;
  29763. /**
  29764. * Starts the particle system and begins to emit
  29765. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  29766. */
  29767. start(delay?: number): void;
  29768. /**
  29769. * Stops the particle system.
  29770. */
  29771. stop(): void;
  29772. /**
  29773. * Remove all active particles
  29774. */
  29775. reset(): void;
  29776. /**
  29777. * Is this system ready to be used/rendered
  29778. * @return true if the system is ready
  29779. */
  29780. isReady(): boolean;
  29781. /**
  29782. * Adds a new color gradient
  29783. * @param gradient defines the gradient to use (between 0 and 1)
  29784. * @param color1 defines the color to affect to the specified gradient
  29785. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  29786. * @returns the current particle system
  29787. */
  29788. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  29789. /**
  29790. * Remove a specific color gradient
  29791. * @param gradient defines the gradient to remove
  29792. * @returns the current particle system
  29793. */
  29794. removeColorGradient(gradient: number): IParticleSystem;
  29795. /**
  29796. * Adds a new size gradient
  29797. * @param gradient defines the gradient to use (between 0 and 1)
  29798. * @param factor defines the size factor to affect to the specified gradient
  29799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29800. * @returns the current particle system
  29801. */
  29802. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29803. /**
  29804. * Remove a specific size gradient
  29805. * @param gradient defines the gradient to remove
  29806. * @returns the current particle system
  29807. */
  29808. removeSizeGradient(gradient: number): IParticleSystem;
  29809. /**
  29810. * Gets the current list of color gradients.
  29811. * You must use addColorGradient and removeColorGradient to udpate this list
  29812. * @returns the list of color gradients
  29813. */
  29814. getColorGradients(): Nullable<Array<ColorGradient>>;
  29815. /**
  29816. * Gets the current list of size gradients.
  29817. * You must use addSizeGradient and removeSizeGradient to udpate this list
  29818. * @returns the list of size gradients
  29819. */
  29820. getSizeGradients(): Nullable<Array<FactorGradient>>;
  29821. /**
  29822. * Gets the current list of angular speed gradients.
  29823. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  29824. * @returns the list of angular speed gradients
  29825. */
  29826. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  29827. /**
  29828. * Adds a new angular speed gradient
  29829. * @param gradient defines the gradient to use (between 0 and 1)
  29830. * @param factor defines the angular speed to affect to the specified gradient
  29831. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29832. * @returns the current particle system
  29833. */
  29834. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29835. /**
  29836. * Remove a specific angular speed gradient
  29837. * @param gradient defines the gradient to remove
  29838. * @returns the current particle system
  29839. */
  29840. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  29841. /**
  29842. * Gets the current list of velocity gradients.
  29843. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  29844. * @returns the list of velocity gradients
  29845. */
  29846. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  29847. /**
  29848. * Adds a new velocity gradient
  29849. * @param gradient defines the gradient to use (between 0 and 1)
  29850. * @param factor defines the velocity to affect to the specified gradient
  29851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29852. * @returns the current particle system
  29853. */
  29854. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29855. /**
  29856. * Remove a specific velocity gradient
  29857. * @param gradient defines the gradient to remove
  29858. * @returns the current particle system
  29859. */
  29860. removeVelocityGradient(gradient: number): IParticleSystem;
  29861. /**
  29862. * Gets the current list of limit velocity gradients.
  29863. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  29864. * @returns the list of limit velocity gradients
  29865. */
  29866. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  29867. /**
  29868. * Adds a new limit velocity gradient
  29869. * @param gradient defines the gradient to use (between 0 and 1)
  29870. * @param factor defines the limit velocity to affect to the specified gradient
  29871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29872. * @returns the current particle system
  29873. */
  29874. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29875. /**
  29876. * Remove a specific limit velocity gradient
  29877. * @param gradient defines the gradient to remove
  29878. * @returns the current particle system
  29879. */
  29880. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  29881. /**
  29882. * Adds a new drag gradient
  29883. * @param gradient defines the gradient to use (between 0 and 1)
  29884. * @param factor defines the drag to affect to the specified gradient
  29885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29886. * @returns the current particle system
  29887. */
  29888. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29889. /**
  29890. * Remove a specific drag gradient
  29891. * @param gradient defines the gradient to remove
  29892. * @returns the current particle system
  29893. */
  29894. removeDragGradient(gradient: number): IParticleSystem;
  29895. /**
  29896. * Gets the current list of drag gradients.
  29897. * You must use addDragGradient and removeDragGradient to udpate this list
  29898. * @returns the list of drag gradients
  29899. */
  29900. getDragGradients(): Nullable<Array<FactorGradient>>;
  29901. /**
  29902. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  29903. * @param gradient defines the gradient to use (between 0 and 1)
  29904. * @param factor defines the emit rate to affect to the specified gradient
  29905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29906. * @returns the current particle system
  29907. */
  29908. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29909. /**
  29910. * Remove a specific emit rate gradient
  29911. * @param gradient defines the gradient to remove
  29912. * @returns the current particle system
  29913. */
  29914. removeEmitRateGradient(gradient: number): IParticleSystem;
  29915. /**
  29916. * Gets the current list of emit rate gradients.
  29917. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  29918. * @returns the list of emit rate gradients
  29919. */
  29920. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  29921. /**
  29922. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  29923. * @param gradient defines the gradient to use (between 0 and 1)
  29924. * @param factor defines the start size to affect to the specified gradient
  29925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29926. * @returns the current particle system
  29927. */
  29928. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29929. /**
  29930. * Remove a specific start size gradient
  29931. * @param gradient defines the gradient to remove
  29932. * @returns the current particle system
  29933. */
  29934. removeStartSizeGradient(gradient: number): IParticleSystem;
  29935. /**
  29936. * Gets the current list of start size gradients.
  29937. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  29938. * @returns the list of start size gradients
  29939. */
  29940. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  29941. /**
  29942. * Adds a new life time gradient
  29943. * @param gradient defines the gradient to use (between 0 and 1)
  29944. * @param factor defines the life time factor to affect to the specified gradient
  29945. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  29946. * @returns the current particle system
  29947. */
  29948. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  29949. /**
  29950. * Remove a specific life time gradient
  29951. * @param gradient defines the gradient to remove
  29952. * @returns the current particle system
  29953. */
  29954. removeLifeTimeGradient(gradient: number): IParticleSystem;
  29955. /**
  29956. * Gets the current list of life time gradients.
  29957. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  29958. * @returns the list of life time gradients
  29959. */
  29960. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  29961. /**
  29962. * Gets the current list of color gradients.
  29963. * You must use addColorGradient and removeColorGradient to udpate this list
  29964. * @returns the list of color gradients
  29965. */
  29966. getColorGradients(): Nullable<Array<ColorGradient>>;
  29967. /**
  29968. * Adds a new ramp gradient used to remap particle colors
  29969. * @param gradient defines the gradient to use (between 0 and 1)
  29970. * @param color defines the color to affect to the specified gradient
  29971. * @returns the current particle system
  29972. */
  29973. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  29974. /**
  29975. * Gets the current list of ramp gradients.
  29976. * You must use addRampGradient and removeRampGradient to udpate this list
  29977. * @returns the list of ramp gradients
  29978. */
  29979. getRampGradients(): Nullable<Array<Color3Gradient>>;
  29980. /** Gets or sets a boolean indicating that ramp gradients must be used
  29981. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  29982. */
  29983. useRampGradients: boolean;
  29984. /**
  29985. * Adds a new color remap gradient
  29986. * @param gradient defines the gradient to use (between 0 and 1)
  29987. * @param min defines the color remap minimal range
  29988. * @param max defines the color remap maximal range
  29989. * @returns the current particle system
  29990. */
  29991. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  29992. /**
  29993. * Gets the current list of color remap gradients.
  29994. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  29995. * @returns the list of color remap gradients
  29996. */
  29997. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  29998. /**
  29999. * Adds a new alpha remap gradient
  30000. * @param gradient defines the gradient to use (between 0 and 1)
  30001. * @param min defines the alpha remap minimal range
  30002. * @param max defines the alpha remap maximal range
  30003. * @returns the current particle system
  30004. */
  30005. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30006. /**
  30007. * Gets the current list of alpha remap gradients.
  30008. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30009. * @returns the list of alpha remap gradients
  30010. */
  30011. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30012. /**
  30013. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30014. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30015. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30016. * @returns the emitter
  30017. */
  30018. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30019. /**
  30020. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30021. * @param radius The radius of the hemisphere to emit from
  30022. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30023. * @returns the emitter
  30024. */
  30025. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  30026. /**
  30027. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30028. * @param radius The radius of the sphere to emit from
  30029. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30030. * @returns the emitter
  30031. */
  30032. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  30033. /**
  30034. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30035. * @param radius The radius of the sphere to emit from
  30036. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30037. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30038. * @returns the emitter
  30039. */
  30040. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  30041. /**
  30042. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30043. * @param radius The radius of the emission cylinder
  30044. * @param height The height of the emission cylinder
  30045. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30046. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30047. * @returns the emitter
  30048. */
  30049. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  30050. /**
  30051. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30052. * @param radius The radius of the cylinder to emit from
  30053. * @param height The height of the emission cylinder
  30054. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30055. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30056. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30057. * @returns the emitter
  30058. */
  30059. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  30060. /**
  30061. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30062. * @param radius The radius of the cone to emit from
  30063. * @param angle The base angle of the cone
  30064. * @returns the emitter
  30065. */
  30066. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  30067. /**
  30068. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30069. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30070. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30071. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30072. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30073. * @returns the emitter
  30074. */
  30075. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30076. /**
  30077. * Get hosting scene
  30078. * @returns the scene
  30079. */
  30080. getScene(): Scene;
  30081. }
  30082. }
  30083. declare module BABYLON {
  30084. /**
  30085. * A particle represents one of the element emitted by a particle system.
  30086. * This is mainly define by its coordinates, direction, velocity and age.
  30087. */
  30088. class Particle {
  30089. /**
  30090. * The particle system the particle belongs to.
  30091. */
  30092. particleSystem: ParticleSystem;
  30093. private static _Count;
  30094. /**
  30095. * Unique ID of the particle
  30096. */
  30097. id: number;
  30098. /**
  30099. * The world position of the particle in the scene.
  30100. */
  30101. position: Vector3;
  30102. /**
  30103. * The world direction of the particle in the scene.
  30104. */
  30105. direction: Vector3;
  30106. /**
  30107. * The color of the particle.
  30108. */
  30109. color: Color4;
  30110. /**
  30111. * The color change of the particle per step.
  30112. */
  30113. colorStep: Color4;
  30114. /**
  30115. * Defines how long will the life of the particle be.
  30116. */
  30117. lifeTime: number;
  30118. /**
  30119. * The current age of the particle.
  30120. */
  30121. age: number;
  30122. /**
  30123. * The current size of the particle.
  30124. */
  30125. size: number;
  30126. /**
  30127. * The current scale of the particle.
  30128. */
  30129. scale: Vector2;
  30130. /**
  30131. * The current angle of the particle.
  30132. */
  30133. angle: number;
  30134. /**
  30135. * Defines how fast is the angle changing.
  30136. */
  30137. angularSpeed: number;
  30138. /**
  30139. * Defines the cell index used by the particle to be rendered from a sprite.
  30140. */
  30141. cellIndex: number;
  30142. /**
  30143. * The information required to support color remapping
  30144. */
  30145. remapData: Vector4;
  30146. /** @hidden */
  30147. _randomCellOffset?: number;
  30148. /** @hidden */
  30149. _initialDirection: Nullable<Vector3>;
  30150. /** @hidden */
  30151. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  30152. /** @hidden */
  30153. _initialStartSpriteCellID: number;
  30154. /** @hidden */
  30155. _initialEndSpriteCellID: number;
  30156. /** @hidden */
  30157. _currentColorGradient: Nullable<ColorGradient>;
  30158. /** @hidden */
  30159. _currentColor1: Color4;
  30160. /** @hidden */
  30161. _currentColor2: Color4;
  30162. /** @hidden */
  30163. _currentSizeGradient: Nullable<FactorGradient>;
  30164. /** @hidden */
  30165. _currentSize1: number;
  30166. /** @hidden */
  30167. _currentSize2: number;
  30168. /** @hidden */
  30169. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  30170. /** @hidden */
  30171. _currentAngularSpeed1: number;
  30172. /** @hidden */
  30173. _currentAngularSpeed2: number;
  30174. /** @hidden */
  30175. _currentVelocityGradient: Nullable<FactorGradient>;
  30176. /** @hidden */
  30177. _currentVelocity1: number;
  30178. /** @hidden */
  30179. _currentVelocity2: number;
  30180. /** @hidden */
  30181. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  30182. /** @hidden */
  30183. _currentLimitVelocity1: number;
  30184. /** @hidden */
  30185. _currentLimitVelocity2: number;
  30186. /** @hidden */
  30187. _currentDragGradient: Nullable<FactorGradient>;
  30188. /** @hidden */
  30189. _currentDrag1: number;
  30190. /** @hidden */
  30191. _currentDrag2: number;
  30192. /** @hidden */
  30193. _randomNoiseCoordinates1: Vector3;
  30194. /** @hidden */
  30195. _randomNoiseCoordinates2: Vector3;
  30196. /**
  30197. * Creates a new instance Particle
  30198. * @param particleSystem the particle system the particle belongs to
  30199. */
  30200. constructor(
  30201. /**
  30202. * The particle system the particle belongs to.
  30203. */
  30204. particleSystem: ParticleSystem);
  30205. private updateCellInfoFromSystem;
  30206. /**
  30207. * Defines how the sprite cell index is updated for the particle
  30208. */
  30209. updateCellIndex(): void;
  30210. /** @hidden */
  30211. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  30212. /** @hidden */
  30213. _inheritParticleInfoToSubEmitters(): void;
  30214. /** @hidden */
  30215. _reset(): void;
  30216. /**
  30217. * Copy the properties of particle to another one.
  30218. * @param other the particle to copy the information to.
  30219. */
  30220. copyTo(other: Particle): void;
  30221. }
  30222. }
  30223. declare module BABYLON {
  30224. /**
  30225. * This class is made for on one-liner static method to help creating particle system set.
  30226. */
  30227. class ParticleHelper {
  30228. /**
  30229. * Gets or sets base Assets URL
  30230. */
  30231. static BaseAssetsUrl: string;
  30232. /**
  30233. * Create a default particle system that you can tweak
  30234. * @param emitter defines the emitter to use
  30235. * @param capacity defines the system capacity (default is 500 particles)
  30236. * @param scene defines the hosting scene
  30237. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  30238. * @returns the new Particle system
  30239. */
  30240. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  30241. /**
  30242. * This is the main static method (one-liner) of this helper to create different particle systems
  30243. * @param type This string represents the type to the particle system to create
  30244. * @param scene The scene where the particle system should live
  30245. * @param gpu If the system will use gpu
  30246. * @returns the ParticleSystemSet created
  30247. */
  30248. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  30249. /**
  30250. * Static function used to export a particle system to a ParticleSystemSet variable.
  30251. * Please note that the emitter shape is not exported
  30252. * @param systems defines the particle systems to export
  30253. * @returns the created particle system set
  30254. */
  30255. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  30256. }
  30257. }
  30258. declare module BABYLON {
  30259. /**
  30260. * This represents a particle system in Babylon.
  30261. * 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.
  30262. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30263. * @example https://doc.babylonjs.com/babylon101/particles
  30264. */
  30265. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  30266. /**
  30267. * Billboard mode will only apply to Y axis
  30268. */
  30269. static readonly BILLBOARDMODE_Y: number;
  30270. /**
  30271. * Billboard mode will apply to all axes
  30272. */
  30273. static readonly BILLBOARDMODE_ALL: number;
  30274. /**
  30275. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  30276. */
  30277. static readonly BILLBOARDMODE_STRETCHED: number;
  30278. /**
  30279. * This function can be defined to provide custom update for active particles.
  30280. * This function will be called instead of regular update (age, position, color, etc.).
  30281. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  30282. */
  30283. updateFunction: (particles: Particle[]) => void;
  30284. private _emitterWorldMatrix;
  30285. /**
  30286. * This function can be defined to specify initial direction for every new particle.
  30287. * It by default use the emitterType defined function
  30288. */
  30289. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  30290. /**
  30291. * This function can be defined to specify initial position for every new particle.
  30292. * It by default use the emitterType defined function
  30293. */
  30294. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  30295. /**
  30296. * @hidden
  30297. */
  30298. _inheritedVelocityOffset: Vector3;
  30299. /**
  30300. * An event triggered when the system is disposed
  30301. */
  30302. onDisposeObservable: Observable<ParticleSystem>;
  30303. private _onDisposeObserver;
  30304. /**
  30305. * Sets a callback that will be triggered when the system is disposed
  30306. */
  30307. onDispose: () => void;
  30308. private _particles;
  30309. private _epsilon;
  30310. private _capacity;
  30311. private _stockParticles;
  30312. private _newPartsExcess;
  30313. private _vertexData;
  30314. private _vertexBuffer;
  30315. private _vertexBuffers;
  30316. private _spriteBuffer;
  30317. private _indexBuffer;
  30318. private _effect;
  30319. private _customEffect;
  30320. private _cachedDefines;
  30321. private _scaledColorStep;
  30322. private _colorDiff;
  30323. private _scaledDirection;
  30324. private _scaledGravity;
  30325. private _currentRenderId;
  30326. private _alive;
  30327. private _useInstancing;
  30328. private _started;
  30329. private _stopped;
  30330. private _actualFrame;
  30331. private _scaledUpdateSpeed;
  30332. private _vertexBufferSize;
  30333. /** @hidden */
  30334. _currentEmitRateGradient: Nullable<FactorGradient>;
  30335. /** @hidden */
  30336. _currentEmitRate1: number;
  30337. /** @hidden */
  30338. _currentEmitRate2: number;
  30339. /** @hidden */
  30340. _currentStartSizeGradient: Nullable<FactorGradient>;
  30341. /** @hidden */
  30342. _currentStartSize1: number;
  30343. /** @hidden */
  30344. _currentStartSize2: number;
  30345. private readonly _rawTextureWidth;
  30346. private _rampGradientsTexture;
  30347. private _useRampGradients;
  30348. /** Gets or sets a boolean indicating that ramp gradients must be used
  30349. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30350. */
  30351. useRampGradients: boolean;
  30352. /**
  30353. * 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.
  30354. * 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: [])
  30355. */
  30356. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  30357. private _subEmitters;
  30358. /**
  30359. * @hidden
  30360. * If the particle systems emitter should be disposed when the particle system is disposed
  30361. */
  30362. _disposeEmitterOnDispose: boolean;
  30363. /**
  30364. * The current active Sub-systems, this property is used by the root particle system only.
  30365. */
  30366. activeSubSystems: Array<ParticleSystem>;
  30367. private _rootParticleSystem;
  30368. /**
  30369. * Gets the current list of active particles
  30370. */
  30371. readonly particles: Particle[];
  30372. /**
  30373. * Returns the string "ParticleSystem"
  30374. * @returns a string containing the class name
  30375. */
  30376. getClassName(): string;
  30377. /**
  30378. * Instantiates a particle system.
  30379. * 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.
  30380. * @param name The name of the particle system
  30381. * @param capacity The max number of particles alive at the same time
  30382. * @param scene The scene the particle system belongs to
  30383. * @param customEffect a custom effect used to change the way particles are rendered by default
  30384. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30385. * @param epsilon Offset used to render the particles
  30386. */
  30387. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  30388. private _addFactorGradient;
  30389. private _removeFactorGradient;
  30390. /**
  30391. * Adds a new life time gradient
  30392. * @param gradient defines the gradient to use (between 0 and 1)
  30393. * @param factor defines the life time factor to affect to the specified gradient
  30394. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30395. * @returns the current particle system
  30396. */
  30397. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30398. /**
  30399. * Remove a specific life time gradient
  30400. * @param gradient defines the gradient to remove
  30401. * @returns the current particle system
  30402. */
  30403. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30404. /**
  30405. * Adds a new size gradient
  30406. * @param gradient defines the gradient to use (between 0 and 1)
  30407. * @param factor defines the size factor to affect to the specified gradient
  30408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30409. * @returns the current particle system
  30410. */
  30411. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30412. /**
  30413. * Remove a specific size gradient
  30414. * @param gradient defines the gradient to remove
  30415. * @returns the current particle system
  30416. */
  30417. removeSizeGradient(gradient: number): IParticleSystem;
  30418. /**
  30419. * Adds a new color remap gradient
  30420. * @param gradient defines the gradient to use (between 0 and 1)
  30421. * @param min defines the color remap minimal range
  30422. * @param max defines the color remap maximal range
  30423. * @returns the current particle system
  30424. */
  30425. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30426. /**
  30427. * Remove a specific color remap gradient
  30428. * @param gradient defines the gradient to remove
  30429. * @returns the current particle system
  30430. */
  30431. removeColorRemapGradient(gradient: number): IParticleSystem;
  30432. /**
  30433. * Adds a new alpha remap gradient
  30434. * @param gradient defines the gradient to use (between 0 and 1)
  30435. * @param min defines the alpha remap minimal range
  30436. * @param max defines the alpha remap maximal range
  30437. * @returns the current particle system
  30438. */
  30439. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30440. /**
  30441. * Remove a specific alpha remap gradient
  30442. * @param gradient defines the gradient to remove
  30443. * @returns the current particle system
  30444. */
  30445. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30446. /**
  30447. * Adds a new angular speed gradient
  30448. * @param gradient defines the gradient to use (between 0 and 1)
  30449. * @param factor defines the angular speed to affect to the specified gradient
  30450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30451. * @returns the current particle system
  30452. */
  30453. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30454. /**
  30455. * Remove a specific angular speed gradient
  30456. * @param gradient defines the gradient to remove
  30457. * @returns the current particle system
  30458. */
  30459. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  30460. /**
  30461. * Adds a new velocity gradient
  30462. * @param gradient defines the gradient to use (between 0 and 1)
  30463. * @param factor defines the velocity to affect to the specified gradient
  30464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30465. * @returns the current particle system
  30466. */
  30467. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30468. /**
  30469. * Remove a specific velocity gradient
  30470. * @param gradient defines the gradient to remove
  30471. * @returns the current particle system
  30472. */
  30473. removeVelocityGradient(gradient: number): IParticleSystem;
  30474. /**
  30475. * Adds a new limit velocity gradient
  30476. * @param gradient defines the gradient to use (between 0 and 1)
  30477. * @param factor defines the limit velocity value to affect to the specified gradient
  30478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30479. * @returns the current particle system
  30480. */
  30481. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30482. /**
  30483. * Remove a specific limit velocity gradient
  30484. * @param gradient defines the gradient to remove
  30485. * @returns the current particle system
  30486. */
  30487. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  30488. /**
  30489. * Adds a new drag gradient
  30490. * @param gradient defines the gradient to use (between 0 and 1)
  30491. * @param factor defines the drag value to affect to the specified gradient
  30492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30493. * @returns the current particle system
  30494. */
  30495. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30496. /**
  30497. * Remove a specific drag gradient
  30498. * @param gradient defines the gradient to remove
  30499. * @returns the current particle system
  30500. */
  30501. removeDragGradient(gradient: number): IParticleSystem;
  30502. /**
  30503. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  30504. * @param gradient defines the gradient to use (between 0 and 1)
  30505. * @param factor defines the emit rate value to affect to the specified gradient
  30506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30507. * @returns the current particle system
  30508. */
  30509. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30510. /**
  30511. * Remove a specific emit rate gradient
  30512. * @param gradient defines the gradient to remove
  30513. * @returns the current particle system
  30514. */
  30515. removeEmitRateGradient(gradient: number): IParticleSystem;
  30516. /**
  30517. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  30518. * @param gradient defines the gradient to use (between 0 and 1)
  30519. * @param factor defines the start size value to affect to the specified gradient
  30520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30521. * @returns the current particle system
  30522. */
  30523. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30524. /**
  30525. * Remove a specific start size gradient
  30526. * @param gradient defines the gradient to remove
  30527. * @returns the current particle system
  30528. */
  30529. removeStartSizeGradient(gradient: number): IParticleSystem;
  30530. private _createRampGradientTexture;
  30531. /**
  30532. * Gets the current list of ramp gradients.
  30533. * You must use addRampGradient and removeRampGradient to udpate this list
  30534. * @returns the list of ramp gradients
  30535. */
  30536. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30537. /**
  30538. * Adds a new ramp gradient used to remap particle colors
  30539. * @param gradient defines the gradient to use (between 0 and 1)
  30540. * @param color defines the color to affect to the specified gradient
  30541. * @returns the current particle system
  30542. */
  30543. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  30544. /**
  30545. * Remove a specific ramp gradient
  30546. * @param gradient defines the gradient to remove
  30547. * @returns the current particle system
  30548. */
  30549. removeRampGradient(gradient: number): ParticleSystem;
  30550. /**
  30551. * Adds a new color gradient
  30552. * @param gradient defines the gradient to use (between 0 and 1)
  30553. * @param color1 defines the color to affect to the specified gradient
  30554. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30555. * @returns this particle system
  30556. */
  30557. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  30558. /**
  30559. * Remove a specific color gradient
  30560. * @param gradient defines the gradient to remove
  30561. * @returns this particle system
  30562. */
  30563. removeColorGradient(gradient: number): IParticleSystem;
  30564. private _fetchR;
  30565. protected _reset(): void;
  30566. private _resetEffect;
  30567. private _createVertexBuffers;
  30568. private _createIndexBuffer;
  30569. /**
  30570. * Gets the maximum number of particles active at the same time.
  30571. * @returns The max number of active particles.
  30572. */
  30573. getCapacity(): number;
  30574. /**
  30575. * Gets whether there are still active particles in the system.
  30576. * @returns True if it is alive, otherwise false.
  30577. */
  30578. isAlive(): boolean;
  30579. /**
  30580. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30581. * @returns True if it has been started, otherwise false.
  30582. */
  30583. isStarted(): boolean;
  30584. private _prepareSubEmitterInternalArray;
  30585. /**
  30586. * Starts the particle system and begins to emit
  30587. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30588. */
  30589. start(delay?: number): void;
  30590. /**
  30591. * Stops the particle system.
  30592. * @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.
  30593. */
  30594. stop(stopSubEmitters?: boolean): void;
  30595. /**
  30596. * Remove all active particles
  30597. */
  30598. reset(): void;
  30599. /**
  30600. * @hidden (for internal use only)
  30601. */
  30602. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  30603. /**
  30604. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  30605. * Its lifetime will start back at 0.
  30606. */
  30607. recycleParticle: (particle: Particle) => void;
  30608. private _stopSubEmitters;
  30609. private _createParticle;
  30610. private _removeFromRoot;
  30611. private _emitFromParticle;
  30612. private _update;
  30613. /** @hidden */
  30614. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  30615. /** @hidden */
  30616. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  30617. /** @hidden */
  30618. private _getEffect;
  30619. /**
  30620. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30621. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  30622. */
  30623. animate(preWarmOnly?: boolean): void;
  30624. private _appendParticleVertices;
  30625. /**
  30626. * Rebuilds the particle system.
  30627. */
  30628. rebuild(): void;
  30629. /**
  30630. * Is this system ready to be used/rendered
  30631. * @return true if the system is ready
  30632. */
  30633. isReady(): boolean;
  30634. private _render;
  30635. /**
  30636. * Renders the particle system in its current state.
  30637. * @returns the current number of particles
  30638. */
  30639. render(): number;
  30640. /**
  30641. * Disposes the particle system and free the associated resources
  30642. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30643. */
  30644. dispose(disposeTexture?: boolean): void;
  30645. /**
  30646. * Clones the particle system.
  30647. * @param name The name of the cloned object
  30648. * @param newEmitter The new emitter to use
  30649. * @returns the cloned particle system
  30650. */
  30651. clone(name: string, newEmitter: any): ParticleSystem;
  30652. /**
  30653. * Serializes the particle system to a JSON object.
  30654. * @returns the JSON object
  30655. */
  30656. serialize(): any;
  30657. /** @hidden */
  30658. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  30659. /** @hidden */
  30660. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  30661. /**
  30662. * Parses a JSON object to create a particle system.
  30663. * @param parsedParticleSystem The JSON object to parse
  30664. * @param scene The scene to create the particle system in
  30665. * @param rootUrl The root url to use to load external dependencies like texture
  30666. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30667. * @returns the Parsed particle system
  30668. */
  30669. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  30670. }
  30671. }
  30672. declare module BABYLON {
  30673. interface Engine {
  30674. /**
  30675. * Create an effect to use with particle systems.
  30676. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  30677. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  30678. * @param uniformsNames defines a list of attribute names
  30679. * @param samplers defines an array of string used to represent textures
  30680. * @param defines defines the string containing the defines to use to compile the shaders
  30681. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30682. * @param onCompiled defines a function to call when the effect creation is successful
  30683. * @param onError defines a function to call when the effect creation has failed
  30684. * @returns the new Effect
  30685. */
  30686. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  30687. }
  30688. interface Mesh {
  30689. /**
  30690. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  30691. * @returns an array of IParticleSystem
  30692. */
  30693. getEmittedParticleSystems(): IParticleSystem[];
  30694. /**
  30695. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  30696. * @returns an array of IParticleSystem
  30697. */
  30698. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  30699. }
  30700. }
  30701. declare module BABYLON {
  30702. /**
  30703. * Represents a set of particle systems working together to create a specific effect
  30704. */
  30705. class ParticleSystemSet implements IDisposable {
  30706. private _emitterCreationOptions;
  30707. private _emitterNode;
  30708. /**
  30709. * Gets the particle system list
  30710. */
  30711. systems: IParticleSystem[];
  30712. /**
  30713. * Gets the emitter node used with this set
  30714. */
  30715. readonly emitterNode: Nullable<TransformNode>;
  30716. /**
  30717. * Creates a new emitter mesh as a sphere
  30718. * @param options defines the options used to create the sphere
  30719. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  30720. * @param scene defines the hosting scene
  30721. */
  30722. setEmitterAsSphere(options: {
  30723. diameter: number;
  30724. segments: number;
  30725. color: Color3;
  30726. }, renderingGroupId: number, scene: Scene): void;
  30727. /**
  30728. * Starts all particle systems of the set
  30729. * @param emitter defines an optional mesh to use as emitter for the particle systems
  30730. */
  30731. start(emitter?: AbstractMesh): void;
  30732. /**
  30733. * Release all associated resources
  30734. */
  30735. dispose(): void;
  30736. /**
  30737. * Serialize the set into a JSON compatible object
  30738. * @returns a JSON compatible representation of the set
  30739. */
  30740. serialize(): any;
  30741. /**
  30742. * Parse a new ParticleSystemSet from a serialized source
  30743. * @param data defines a JSON compatible representation of the set
  30744. * @param scene defines the hosting scene
  30745. * @param gpu defines if we want GPU particles or CPU particles
  30746. * @returns a new ParticleSystemSet
  30747. */
  30748. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  30749. }
  30750. }
  30751. declare module BABYLON {
  30752. /**
  30753. * Represents one particle of a solid particle system.
  30754. */
  30755. class SolidParticle {
  30756. /**
  30757. * particle global index
  30758. */
  30759. idx: number;
  30760. /**
  30761. * The color of the particle
  30762. */
  30763. color: Nullable<Color4>;
  30764. /**
  30765. * The world space position of the particle.
  30766. */
  30767. position: Vector3;
  30768. /**
  30769. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30770. */
  30771. rotation: Vector3;
  30772. /**
  30773. * The world space rotation quaternion of the particle.
  30774. */
  30775. rotationQuaternion: Nullable<Quaternion>;
  30776. /**
  30777. * The scaling of the particle.
  30778. */
  30779. scaling: Vector3;
  30780. /**
  30781. * The uvs of the particle.
  30782. */
  30783. uvs: Vector4;
  30784. /**
  30785. * The current speed of the particle.
  30786. */
  30787. velocity: Vector3;
  30788. /**
  30789. * The pivot point in the particle local space.
  30790. */
  30791. pivot: Vector3;
  30792. /**
  30793. * Must the particle be translated from its pivot point in its local space ?
  30794. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30795. * Default : false
  30796. */
  30797. translateFromPivot: boolean;
  30798. /**
  30799. * Is the particle active or not ?
  30800. */
  30801. alive: boolean;
  30802. /**
  30803. * Is the particle visible or not ?
  30804. */
  30805. isVisible: boolean;
  30806. /**
  30807. * Index of this particle in the global "positions" array (Internal use)
  30808. * @hidden
  30809. */
  30810. _pos: number;
  30811. /**
  30812. * @hidden Index of this particle in the global "indices" array (Internal use)
  30813. */
  30814. _ind: number;
  30815. /**
  30816. * @hidden ModelShape of this particle (Internal use)
  30817. */
  30818. _model: ModelShape;
  30819. /**
  30820. * ModelShape id of this particle
  30821. */
  30822. shapeId: number;
  30823. /**
  30824. * Index of the particle in its shape id (Internal use)
  30825. */
  30826. idxInShape: number;
  30827. /**
  30828. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30829. */
  30830. _modelBoundingInfo: BoundingInfo;
  30831. /**
  30832. * @hidden Particle BoundingInfo object (Internal use)
  30833. */
  30834. _boundingInfo: BoundingInfo;
  30835. /**
  30836. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30837. */
  30838. _sps: SolidParticleSystem;
  30839. /**
  30840. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30841. */
  30842. _stillInvisible: boolean;
  30843. /**
  30844. * @hidden Last computed particle rotation matrix
  30845. */
  30846. _rotationMatrix: number[];
  30847. /**
  30848. * Parent particle Id, if any.
  30849. * Default null.
  30850. */
  30851. parentId: Nullable<number>;
  30852. /**
  30853. * @hidden Internal global position in the SPS.
  30854. */
  30855. _globalPosition: Vector3;
  30856. /**
  30857. * Creates a Solid Particle object.
  30858. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30859. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  30860. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30861. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30862. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30863. * @param shapeId (integer) is the model shape identifier in the SPS.
  30864. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30865. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30866. */
  30867. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  30868. /**
  30869. * Legacy support, changed scale to scaling
  30870. */
  30871. /**
  30872. * Legacy support, changed scale to scaling
  30873. */
  30874. scale: Vector3;
  30875. /**
  30876. * Legacy support, changed quaternion to rotationQuaternion
  30877. */
  30878. /**
  30879. * Legacy support, changed quaternion to rotationQuaternion
  30880. */
  30881. quaternion: Nullable<Quaternion>;
  30882. /**
  30883. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30884. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30885. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30886. * @returns true if it intersects
  30887. */
  30888. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30889. }
  30890. /**
  30891. * Represents the shape of the model used by one particle of a solid particle system.
  30892. * SPS internal tool, don't use it manually.
  30893. */
  30894. class ModelShape {
  30895. /**
  30896. * The shape id
  30897. * @hidden
  30898. */
  30899. shapeID: number;
  30900. /**
  30901. * flat array of model positions (internal use)
  30902. * @hidden
  30903. */
  30904. _shape: Vector3[];
  30905. /**
  30906. * flat array of model UVs (internal use)
  30907. * @hidden
  30908. */
  30909. _shapeUV: number[];
  30910. /**
  30911. * length of the shape in the model indices array (internal use)
  30912. * @hidden
  30913. */
  30914. _indicesLength: number;
  30915. /**
  30916. * Custom position function (internal use)
  30917. * @hidden
  30918. */
  30919. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30920. /**
  30921. * Custom vertex function (internal use)
  30922. * @hidden
  30923. */
  30924. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30925. /**
  30926. * 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.
  30927. * SPS internal tool, don't use it manually.
  30928. * @hidden
  30929. */
  30930. 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>);
  30931. }
  30932. /**
  30933. * Represents a Depth Sorted Particle in the solid particle system.
  30934. */
  30935. class DepthSortedParticle {
  30936. /**
  30937. * Index of the particle in the "indices" array
  30938. */
  30939. ind: number;
  30940. /**
  30941. * Length of the particle shape in the "indices" array
  30942. */
  30943. indicesLength: number;
  30944. /**
  30945. * Squared distance from the particle to the camera
  30946. */
  30947. sqDistance: number;
  30948. }
  30949. }
  30950. declare module BABYLON {
  30951. /**
  30952. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30953. *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.
  30954. * The SPS is also a particle system. It provides some methods to manage the particles.
  30955. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30956. *
  30957. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  30958. */
  30959. class SolidParticleSystem implements IDisposable {
  30960. /**
  30961. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30962. * Example : var p = SPS.particles[i];
  30963. */
  30964. particles: SolidParticle[];
  30965. /**
  30966. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30967. */
  30968. nbParticles: number;
  30969. /**
  30970. * If the particles must ever face the camera (default false). Useful for planar particles.
  30971. */
  30972. billboard: boolean;
  30973. /**
  30974. * Recompute normals when adding a shape
  30975. */
  30976. recomputeNormals: boolean;
  30977. /**
  30978. * This a counter ofr your own usage. It's not set by any SPS functions.
  30979. */
  30980. counter: number;
  30981. /**
  30982. * The SPS name. This name is also given to the underlying mesh.
  30983. */
  30984. name: string;
  30985. /**
  30986. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30987. */
  30988. mesh: Mesh;
  30989. /**
  30990. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30991. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  30992. */
  30993. vars: any;
  30994. /**
  30995. * This array is populated when the SPS is set as 'pickable'.
  30996. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30997. * Each element of this array is an object `{idx: int, faceId: int}`.
  30998. * `idx` is the picked particle index in the `SPS.particles` array
  30999. * `faceId` is the picked face index counted within this particle.
  31000. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  31001. */
  31002. pickedParticles: {
  31003. idx: number;
  31004. faceId: number;
  31005. }[];
  31006. /**
  31007. * This array is populated when `enableDepthSort` is set to true.
  31008. * Each element of this array is an instance of the class DepthSortedParticle.
  31009. */
  31010. depthSortedParticles: DepthSortedParticle[];
  31011. /**
  31012. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31013. * @hidden
  31014. */
  31015. _bSphereOnly: boolean;
  31016. /**
  31017. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31018. * @hidden
  31019. */
  31020. _bSphereRadiusFactor: number;
  31021. private _scene;
  31022. private _positions;
  31023. private _indices;
  31024. private _normals;
  31025. private _colors;
  31026. private _uvs;
  31027. private _indices32;
  31028. private _positions32;
  31029. private _normals32;
  31030. private _fixedNormal32;
  31031. private _colors32;
  31032. private _uvs32;
  31033. private _index;
  31034. private _updatable;
  31035. private _pickable;
  31036. private _isVisibilityBoxLocked;
  31037. private _alwaysVisible;
  31038. private _depthSort;
  31039. private _shapeCounter;
  31040. private _copy;
  31041. private _shape;
  31042. private _shapeUV;
  31043. private _color;
  31044. private _computeParticleColor;
  31045. private _computeParticleTexture;
  31046. private _computeParticleRotation;
  31047. private _computeParticleVertex;
  31048. private _computeBoundingBox;
  31049. private _depthSortParticles;
  31050. private _cam_axisZ;
  31051. private _cam_axisY;
  31052. private _cam_axisX;
  31053. private _axisZ;
  31054. private _camera;
  31055. private _particle;
  31056. private _camDir;
  31057. private _camInvertedPosition;
  31058. private _rotMatrix;
  31059. private _invertMatrix;
  31060. private _rotated;
  31061. private _quaternion;
  31062. private _vertex;
  31063. private _normal;
  31064. private _yaw;
  31065. private _pitch;
  31066. private _roll;
  31067. private _halfroll;
  31068. private _halfpitch;
  31069. private _halfyaw;
  31070. private _sinRoll;
  31071. private _cosRoll;
  31072. private _sinPitch;
  31073. private _cosPitch;
  31074. private _sinYaw;
  31075. private _cosYaw;
  31076. private _mustUnrotateFixedNormals;
  31077. private _minimum;
  31078. private _maximum;
  31079. private _minBbox;
  31080. private _maxBbox;
  31081. private _particlesIntersect;
  31082. private _depthSortFunction;
  31083. private _needs32Bits;
  31084. private _pivotBackTranslation;
  31085. private _scaledPivot;
  31086. private _particleHasParent;
  31087. private _parent;
  31088. /**
  31089. * Creates a SPS (Solid Particle System) object.
  31090. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31091. * @param scene (Scene) is the scene in which the SPS is added.
  31092. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31093. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31094. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31095. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31096. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31097. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31098. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31099. */
  31100. constructor(name: string, scene: Scene, options?: {
  31101. updatable?: boolean;
  31102. isPickable?: boolean;
  31103. enableDepthSort?: boolean;
  31104. particleIntersection?: boolean;
  31105. boundingSphereOnly?: boolean;
  31106. bSphereRadiusFactor?: number;
  31107. });
  31108. /**
  31109. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31110. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31111. * @returns the created mesh
  31112. */
  31113. buildMesh(): Mesh;
  31114. /**
  31115. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31116. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31117. * Thus the particles generated from `digest()` have their property `position` set yet.
  31118. * @param mesh ( Mesh ) is the mesh to be digested
  31119. * @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
  31120. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31121. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31122. * @returns the current SPS
  31123. */
  31124. digest(mesh: Mesh, options?: {
  31125. facetNb?: number;
  31126. number?: number;
  31127. delta?: number;
  31128. }): SolidParticleSystem;
  31129. private _unrotateFixedNormals;
  31130. private _resetCopy;
  31131. private _meshBuilder;
  31132. private _posToShape;
  31133. private _uvsToShapeUV;
  31134. private _addParticle;
  31135. /**
  31136. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31137. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  31138. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31139. * @param nb (positive integer) the number of particles to be created from this model
  31140. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31141. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31142. * @returns the number of shapes in the system
  31143. */
  31144. addShape(mesh: Mesh, nb: number, options?: {
  31145. positionFunction?: any;
  31146. vertexFunction?: any;
  31147. }): number;
  31148. private _rebuildParticle;
  31149. /**
  31150. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31151. * @returns the SPS.
  31152. */
  31153. rebuildMesh(): SolidParticleSystem;
  31154. /**
  31155. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31156. * This method calls `updateParticle()` for each particle of the SPS.
  31157. * For an animated SPS, it is usually called within the render loop.
  31158. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31159. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31160. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31161. * @returns the SPS.
  31162. */
  31163. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31164. private _quaternionRotationYPR;
  31165. private _quaternionToRotationMatrix;
  31166. /**
  31167. * Disposes the SPS.
  31168. */
  31169. dispose(): void;
  31170. /**
  31171. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31172. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31173. * @returns the SPS.
  31174. */
  31175. refreshVisibleSize(): SolidParticleSystem;
  31176. /**
  31177. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31178. * @param size the size (float) of the visibility box
  31179. * note : this doesn't lock the SPS mesh bounding box.
  31180. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31181. */
  31182. setVisibilityBox(size: number): void;
  31183. /**
  31184. * Gets whether the SPS as always visible or not
  31185. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31186. */
  31187. /**
  31188. * Sets the SPS as always visible or not
  31189. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31190. */
  31191. isAlwaysVisible: boolean;
  31192. /**
  31193. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31194. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31195. */
  31196. /**
  31197. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31198. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  31199. */
  31200. isVisibilityBoxLocked: boolean;
  31201. /**
  31202. * Tells to `setParticles()` to compute the particle rotations or not.
  31203. * Default value : true. The SPS is faster when it's set to false.
  31204. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31205. */
  31206. /**
  31207. * Gets if `setParticles()` computes the particle rotations or not.
  31208. * Default value : true. The SPS is faster when it's set to false.
  31209. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31210. */
  31211. computeParticleRotation: boolean;
  31212. /**
  31213. * Tells to `setParticles()` to compute the particle colors or not.
  31214. * Default value : true. The SPS is faster when it's set to false.
  31215. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31216. */
  31217. /**
  31218. * Gets if `setParticles()` computes the particle colors or not.
  31219. * Default value : true. The SPS is faster when it's set to false.
  31220. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31221. */
  31222. computeParticleColor: boolean;
  31223. /**
  31224. * Gets if `setParticles()` computes the particle textures or not.
  31225. * Default value : true. The SPS is faster when it's set to false.
  31226. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31227. */
  31228. computeParticleTexture: boolean;
  31229. /**
  31230. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31231. * Default value : false. The SPS is faster when it's set to false.
  31232. * Note : the particle custom vertex positions aren't stored values.
  31233. */
  31234. /**
  31235. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31236. * Default value : false. The SPS is faster when it's set to false.
  31237. * Note : the particle custom vertex positions aren't stored values.
  31238. */
  31239. computeParticleVertex: boolean;
  31240. /**
  31241. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31242. */
  31243. /**
  31244. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31245. */
  31246. computeBoundingBox: boolean;
  31247. /**
  31248. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31249. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31250. * Default : `true`
  31251. */
  31252. /**
  31253. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31254. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31255. * Default : `true`
  31256. */
  31257. depthSortParticles: boolean;
  31258. /**
  31259. * This function does nothing. It may be overwritten to set all the particle first values.
  31260. * The SPS doesn't call this function, you may have to call it by your own.
  31261. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31262. */
  31263. initParticles(): void;
  31264. /**
  31265. * This function does nothing. It may be overwritten to recycle a particle.
  31266. * The SPS doesn't call this function, you may have to call it by your own.
  31267. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31268. * @param particle The particle to recycle
  31269. * @returns the recycled particle
  31270. */
  31271. recycleParticle(particle: SolidParticle): SolidParticle;
  31272. /**
  31273. * Updates a particle : this function should be overwritten by the user.
  31274. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31275. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  31276. * @example : just set a particle position or velocity and recycle conditions
  31277. * @param particle The particle to update
  31278. * @returns the updated particle
  31279. */
  31280. updateParticle(particle: SolidParticle): SolidParticle;
  31281. /**
  31282. * Updates a vertex of a particle : it can be overwritten by the user.
  31283. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31284. * @param particle the current particle
  31285. * @param vertex the current index of the current particle
  31286. * @param pt the index of the current vertex in the particle shape
  31287. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  31288. * @example : just set a vertex particle position
  31289. * @returns the updated vertex
  31290. */
  31291. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  31292. /**
  31293. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31294. * This does nothing and may be overwritten by the user.
  31295. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31296. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31297. * @param update the boolean update value actually passed to setParticles()
  31298. */
  31299. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31300. /**
  31301. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31302. * This will be passed three parameters.
  31303. * This does nothing and may be overwritten by the user.
  31304. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31305. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31306. * @param update the boolean update value actually passed to setParticles()
  31307. */
  31308. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31309. }
  31310. }
  31311. declare module BABYLON {
  31312. /**
  31313. * Type of sub emitter
  31314. */
  31315. enum SubEmitterType {
  31316. /**
  31317. * Attached to the particle over it's lifetime
  31318. */
  31319. ATTACHED = 0,
  31320. /**
  31321. * Created when the particle dies
  31322. */
  31323. END = 1
  31324. }
  31325. /**
  31326. * Sub emitter class used to emit particles from an existing particle
  31327. */
  31328. class SubEmitter {
  31329. /**
  31330. * the particle system to be used by the sub emitter
  31331. */
  31332. particleSystem: ParticleSystem;
  31333. /**
  31334. * Type of the submitter (Default: END)
  31335. */
  31336. type: SubEmitterType;
  31337. /**
  31338. * 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)
  31339. * Note: This only is supported when using an emitter of type Mesh
  31340. */
  31341. inheritDirection: boolean;
  31342. /**
  31343. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  31344. */
  31345. inheritedVelocityAmount: number;
  31346. /**
  31347. * Creates a sub emitter
  31348. * @param particleSystem the particle system to be used by the sub emitter
  31349. */
  31350. constructor(
  31351. /**
  31352. * the particle system to be used by the sub emitter
  31353. */
  31354. particleSystem: ParticleSystem);
  31355. /**
  31356. * Clones the sub emitter
  31357. * @returns the cloned sub emitter
  31358. */
  31359. clone(): SubEmitter;
  31360. /**
  31361. * Serialize current object to a JSON object
  31362. * @returns the serialized object
  31363. */
  31364. serialize(): any;
  31365. /**
  31366. * Creates a new SubEmitter from a serialized JSON version
  31367. * @param serializationObject defines the JSON object to read from
  31368. * @param scene defines the hosting scene
  31369. * @param rootUrl defines the rootUrl for data loading
  31370. * @returns a new SubEmitter
  31371. */
  31372. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  31373. /** Release associated resources */
  31374. dispose(): void;
  31375. }
  31376. }
  31377. declare module BABYLON {
  31378. /**
  31379. * Interface used to describe a physics joint
  31380. */
  31381. interface PhysicsImpostorJoint {
  31382. /** Defines the main impostor to which the joint is linked */
  31383. mainImpostor: PhysicsImpostor;
  31384. /** Defines the impostor that is connected to the main impostor using this joint */
  31385. connectedImpostor: PhysicsImpostor;
  31386. /** Defines the joint itself */
  31387. joint: PhysicsJoint;
  31388. }
  31389. /** @hidden */
  31390. interface IPhysicsEnginePlugin {
  31391. world: any;
  31392. name: string;
  31393. setGravity(gravity: Vector3): void;
  31394. setTimeStep(timeStep: number): void;
  31395. getTimeStep(): number;
  31396. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31397. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31398. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31399. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31400. removePhysicsBody(impostor: PhysicsImpostor): void;
  31401. generateJoint(joint: PhysicsImpostorJoint): void;
  31402. removeJoint(joint: PhysicsImpostorJoint): void;
  31403. isSupported(): boolean;
  31404. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31405. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31406. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31407. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31408. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31409. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31410. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31411. getBodyMass(impostor: PhysicsImpostor): number;
  31412. getBodyFriction(impostor: PhysicsImpostor): number;
  31413. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31414. getBodyRestitution(impostor: PhysicsImpostor): number;
  31415. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31416. sleepBody(impostor: PhysicsImpostor): void;
  31417. wakeUpBody(impostor: PhysicsImpostor): void;
  31418. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31419. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31420. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31421. getRadius(impostor: PhysicsImpostor): number;
  31422. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31424. dispose(): void;
  31425. }
  31426. /**
  31427. * Interface used to define a physics engine
  31428. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  31429. */
  31430. interface IPhysicsEngine {
  31431. /**
  31432. * Gets the gravity vector used by the simulation
  31433. */
  31434. gravity: Vector3;
  31435. /**
  31436. * Sets the gravity vector used by the simulation
  31437. * @param gravity defines the gravity vector to use
  31438. */
  31439. setGravity(gravity: Vector3): void;
  31440. /**
  31441. * Set the time step of the physics engine.
  31442. * Default is 1/60.
  31443. * To slow it down, enter 1/600 for example.
  31444. * To speed it up, 1/30
  31445. * @param newTimeStep the new timestep to apply to this world.
  31446. */
  31447. setTimeStep(newTimeStep: number): void;
  31448. /**
  31449. * Get the time step of the physics engine.
  31450. * @returns the current time step
  31451. */
  31452. getTimeStep(): number;
  31453. /**
  31454. * Release all resources
  31455. */
  31456. dispose(): void;
  31457. /**
  31458. * Gets the name of the current physics plugin
  31459. * @returns the name of the plugin
  31460. */
  31461. getPhysicsPluginName(): string;
  31462. /**
  31463. * Adding a new impostor for the impostor tracking.
  31464. * This will be done by the impostor itself.
  31465. * @param impostor the impostor to add
  31466. */
  31467. addImpostor(impostor: PhysicsImpostor): void;
  31468. /**
  31469. * Remove an impostor from the engine.
  31470. * This impostor and its mesh will not longer be updated by the physics engine.
  31471. * @param impostor the impostor to remove
  31472. */
  31473. removeImpostor(impostor: PhysicsImpostor): void;
  31474. /**
  31475. * Add a joint to the physics engine
  31476. * @param mainImpostor defines the main impostor to which the joint is added.
  31477. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31478. * @param joint defines the joint that will connect both impostors.
  31479. */
  31480. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31481. /**
  31482. * Removes a joint from the simulation
  31483. * @param mainImpostor defines the impostor used with the joint
  31484. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31485. * @param joint defines the joint to remove
  31486. */
  31487. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31488. /**
  31489. * Gets the current plugin used to run the simulation
  31490. * @returns current plugin
  31491. */
  31492. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31493. /**
  31494. * Gets the list of physic impostors
  31495. * @returns an array of PhysicsImpostor
  31496. */
  31497. getImpostors(): Array<PhysicsImpostor>;
  31498. /**
  31499. * Gets the impostor for a physics enabled object
  31500. * @param object defines the object impersonated by the impostor
  31501. * @returns the PhysicsImpostor or null if not found
  31502. */
  31503. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31504. /**
  31505. * Gets the impostor for a physics body object
  31506. * @param body defines physics body used by the impostor
  31507. * @returns the PhysicsImpostor or null if not found
  31508. */
  31509. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31510. /**
  31511. * Called by the scene. No need to call it.
  31512. * @param delta defines the timespam between frames
  31513. */
  31514. _step(delta: number): void;
  31515. }
  31516. }
  31517. declare module BABYLON {
  31518. /**
  31519. * Class used to control physics engine
  31520. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  31521. */
  31522. class PhysicsEngine implements IPhysicsEngine {
  31523. private _physicsPlugin;
  31524. /**
  31525. * Global value used to control the smallest number supported by the simulation
  31526. */
  31527. static Epsilon: number;
  31528. private _impostors;
  31529. private _joints;
  31530. /**
  31531. * Gets the gravity vector used by the simulation
  31532. */
  31533. gravity: Vector3;
  31534. /**
  31535. * Creates a new Physics Engine
  31536. * @param gravity defines the gravity vector used by the simulation
  31537. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  31538. */
  31539. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  31540. /**
  31541. * Sets the gravity vector used by the simulation
  31542. * @param gravity defines the gravity vector to use
  31543. */
  31544. setGravity(gravity: Vector3): void;
  31545. /**
  31546. * Set the time step of the physics engine.
  31547. * Default is 1/60.
  31548. * To slow it down, enter 1/600 for example.
  31549. * To speed it up, 1/30
  31550. * @param newTimeStep defines the new timestep to apply to this world.
  31551. */
  31552. setTimeStep(newTimeStep?: number): void;
  31553. /**
  31554. * Get the time step of the physics engine.
  31555. * @returns the current time step
  31556. */
  31557. getTimeStep(): number;
  31558. /**
  31559. * Release all resources
  31560. */
  31561. dispose(): void;
  31562. /**
  31563. * Gets the name of the current physics plugin
  31564. * @returns the name of the plugin
  31565. */
  31566. getPhysicsPluginName(): string;
  31567. /**
  31568. * Adding a new impostor for the impostor tracking.
  31569. * This will be done by the impostor itself.
  31570. * @param impostor the impostor to add
  31571. */
  31572. addImpostor(impostor: PhysicsImpostor): void;
  31573. /**
  31574. * Remove an impostor from the engine.
  31575. * This impostor and its mesh will not longer be updated by the physics engine.
  31576. * @param impostor the impostor to remove
  31577. */
  31578. removeImpostor(impostor: PhysicsImpostor): void;
  31579. /**
  31580. * Add a joint to the physics engine
  31581. * @param mainImpostor defines the main impostor to which the joint is added.
  31582. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31583. * @param joint defines the joint that will connect both impostors.
  31584. */
  31585. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31586. /**
  31587. * Removes a joint from the simulation
  31588. * @param mainImpostor defines the impostor used with the joint
  31589. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31590. * @param joint defines the joint to remove
  31591. */
  31592. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31593. /**
  31594. * Called by the scene. No need to call it.
  31595. * @param delta defines the timespam between frames
  31596. */
  31597. _step(delta: number): void;
  31598. /**
  31599. * Gets the current plugin used to run the simulation
  31600. * @returns current plugin
  31601. */
  31602. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31603. /**
  31604. * Gets the list of physic impostors
  31605. * @returns an array of PhysicsImpostor
  31606. */
  31607. getImpostors(): Array<PhysicsImpostor>;
  31608. /**
  31609. * Gets the impostor for a physics enabled object
  31610. * @param object defines the object impersonated by the impostor
  31611. * @returns the PhysicsImpostor or null if not found
  31612. */
  31613. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31614. /**
  31615. * Gets the impostor for a physics body object
  31616. * @param body defines physics body used by the impostor
  31617. * @returns the PhysicsImpostor or null if not found
  31618. */
  31619. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31620. }
  31621. }
  31622. declare module BABYLON {
  31623. interface Scene {
  31624. /** @hidden (Backing field) */
  31625. _physicsEngine: Nullable<IPhysicsEngine>;
  31626. /**
  31627. * Gets the current physics engine
  31628. * @returns a IPhysicsEngine or null if none attached
  31629. */
  31630. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  31631. /**
  31632. * Enables physics to the current scene
  31633. * @param gravity defines the scene's gravity for the physics engine
  31634. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  31635. * @return a boolean indicating if the physics engine was initialized
  31636. */
  31637. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  31638. /**
  31639. * Disables and disposes the physics engine associated with the scene
  31640. */
  31641. disablePhysicsEngine(): void;
  31642. /**
  31643. * Gets a boolean indicating if there is an active physics engine
  31644. * @returns a boolean indicating if there is an active physics engine
  31645. */
  31646. isPhysicsEnabled(): boolean;
  31647. /**
  31648. * Deletes a physics compound impostor
  31649. * @param compound defines the compound to delete
  31650. */
  31651. deleteCompoundImpostor(compound: any): void;
  31652. /**
  31653. * An event triggered when physic simulation is about to be run
  31654. */
  31655. onBeforePhysicsObservable: Observable<Scene>;
  31656. /**
  31657. * An event triggered when physic simulation has been done
  31658. */
  31659. onAfterPhysicsObservable: Observable<Scene>;
  31660. }
  31661. interface AbstractMesh {
  31662. /** @hidden */
  31663. _physicsImpostor: Nullable<PhysicsImpostor>;
  31664. /**
  31665. * Gets or sets impostor used for physic simulation
  31666. * @see http://doc.babylonjs.com/features/physics_engine
  31667. */
  31668. physicsImpostor: Nullable<PhysicsImpostor>;
  31669. /**
  31670. * Gets the current physics impostor
  31671. * @see http://doc.babylonjs.com/features/physics_engine
  31672. * @returns a physics impostor or null
  31673. */
  31674. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  31675. /** Apply a physic impulse to the mesh
  31676. * @param force defines the force to apply
  31677. * @param contactPoint defines where to apply the force
  31678. * @returns the current mesh
  31679. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  31680. */
  31681. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  31682. /**
  31683. * Creates a physic joint between two meshes
  31684. * @param otherMesh defines the other mesh to use
  31685. * @param pivot1 defines the pivot to use on this mesh
  31686. * @param pivot2 defines the pivot to use on the other mesh
  31687. * @param options defines additional options (can be plugin dependent)
  31688. * @returns the current mesh
  31689. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  31690. */
  31691. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  31692. /** @hidden */
  31693. _disposePhysicsObserver: Nullable<Observer<Node>>;
  31694. }
  31695. /**
  31696. * Defines the physics engine scene component responsible to manage a physics engine
  31697. */
  31698. class PhysicsEngineSceneComponent implements ISceneComponent {
  31699. /**
  31700. * The component name helpful to identify the component in the list of scene components.
  31701. */
  31702. readonly name: string;
  31703. /**
  31704. * The scene the component belongs to.
  31705. */
  31706. scene: Scene;
  31707. /**
  31708. * Creates a new instance of the component for the given scene
  31709. * @param scene Defines the scene to register the component in
  31710. */
  31711. constructor(scene: Scene);
  31712. /**
  31713. * Registers the component in a given scene
  31714. */
  31715. register(): void;
  31716. /**
  31717. * Rebuilds the elements related to this component in case of
  31718. * context lost for instance.
  31719. */
  31720. rebuild(): void;
  31721. /**
  31722. * Disposes the component and the associated ressources
  31723. */
  31724. dispose(): void;
  31725. }
  31726. }
  31727. declare module BABYLON {
  31728. class PhysicsHelper {
  31729. private _scene;
  31730. private _physicsEngine;
  31731. constructor(scene: Scene);
  31732. /**
  31733. * @param {Vector3} origin the origin of the explosion
  31734. * @param {number} radius the explosion radius
  31735. * @param {number} strength the explosion strength
  31736. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  31737. */
  31738. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  31739. /**
  31740. * @param {Vector3} origin the origin of the explosion
  31741. * @param {number} radius the explosion radius
  31742. * @param {number} strength the explosion strength
  31743. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  31744. */
  31745. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  31746. /**
  31747. * @param {Vector3} origin the origin of the explosion
  31748. * @param {number} radius the explosion radius
  31749. * @param {number} strength the explosion strength
  31750. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  31751. */
  31752. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  31753. /**
  31754. * @param {Vector3} origin the origin of the updraft
  31755. * @param {number} radius the radius of the updraft
  31756. * @param {number} strength the strength of the updraft
  31757. * @param {number} height the height of the updraft
  31758. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  31759. */
  31760. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  31761. /**
  31762. * @param {Vector3} origin the of the vortex
  31763. * @param {number} radius the radius of the vortex
  31764. * @param {number} strength the strength of the vortex
  31765. * @param {number} height the height of the vortex
  31766. */
  31767. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  31768. }
  31769. /***** Radial explosion *****/
  31770. class PhysicsRadialExplosionEvent {
  31771. private _scene;
  31772. private _sphere;
  31773. private _sphereOptions;
  31774. private _rays;
  31775. private _dataFetched;
  31776. constructor(scene: Scene);
  31777. /**
  31778. * Returns the data related to the radial explosion event (sphere & rays).
  31779. * @returns {PhysicsRadialExplosionEventData}
  31780. */
  31781. getData(): PhysicsRadialExplosionEventData;
  31782. /**
  31783. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  31784. * @param impostor
  31785. * @param {Vector3} origin the origin of the explosion
  31786. * @param {number} radius the explosion radius
  31787. * @param {number} strength the explosion strength
  31788. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  31789. * @returns {Nullable<PhysicsForceAndContactPoint>}
  31790. */
  31791. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  31792. /**
  31793. * Disposes the sphere.
  31794. * @param {bolean} force
  31795. */
  31796. dispose(force?: boolean): void;
  31797. /*** Helpers ***/
  31798. private _prepareSphere;
  31799. private _intersectsWithSphere;
  31800. }
  31801. /***** Gravitational Field *****/
  31802. class PhysicsGravitationalFieldEvent {
  31803. private _physicsHelper;
  31804. private _scene;
  31805. private _origin;
  31806. private _radius;
  31807. private _strength;
  31808. private _falloff;
  31809. private _tickCallback;
  31810. private _sphere;
  31811. private _dataFetched;
  31812. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  31813. /**
  31814. * Returns the data related to the gravitational field event (sphere).
  31815. * @returns {PhysicsGravitationalFieldEventData}
  31816. */
  31817. getData(): PhysicsGravitationalFieldEventData;
  31818. /**
  31819. * Enables the gravitational field.
  31820. */
  31821. enable(): void;
  31822. /**
  31823. * Disables the gravitational field.
  31824. */
  31825. disable(): void;
  31826. /**
  31827. * Disposes the sphere.
  31828. * @param {bolean} force
  31829. */
  31830. dispose(force?: boolean): void;
  31831. private _tick;
  31832. }
  31833. /***** Updraft *****/
  31834. class PhysicsUpdraftEvent {
  31835. private _scene;
  31836. private _origin;
  31837. private _radius;
  31838. private _strength;
  31839. private _height;
  31840. private _updraftMode;
  31841. private _physicsEngine;
  31842. private _originTop;
  31843. private _originDirection;
  31844. private _tickCallback;
  31845. private _cylinder;
  31846. private _cylinderPosition;
  31847. private _dataFetched;
  31848. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  31849. /**
  31850. * Returns the data related to the updraft event (cylinder).
  31851. * @returns {PhysicsUpdraftEventData}
  31852. */
  31853. getData(): PhysicsUpdraftEventData;
  31854. /**
  31855. * Enables the updraft.
  31856. */
  31857. enable(): void;
  31858. /**
  31859. * Disables the cortex.
  31860. */
  31861. disable(): void;
  31862. /**
  31863. * Disposes the sphere.
  31864. * @param {bolean} force
  31865. */
  31866. dispose(force?: boolean): void;
  31867. private getImpostorForceAndContactPoint;
  31868. private _tick;
  31869. /*** Helpers ***/
  31870. private _prepareCylinder;
  31871. private _intersectsWithCylinder;
  31872. }
  31873. /***** Vortex *****/
  31874. class PhysicsVortexEvent {
  31875. private _scene;
  31876. private _origin;
  31877. private _radius;
  31878. private _strength;
  31879. private _height;
  31880. private _physicsEngine;
  31881. private _originTop;
  31882. private _centripetalForceThreshold;
  31883. private _updraftMultiplier;
  31884. private _tickCallback;
  31885. private _cylinder;
  31886. private _cylinderPosition;
  31887. private _dataFetched;
  31888. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  31889. /**
  31890. * Returns the data related to the vortex event (cylinder).
  31891. * @returns {PhysicsVortexEventData}
  31892. */
  31893. getData(): PhysicsVortexEventData;
  31894. /**
  31895. * Enables the vortex.
  31896. */
  31897. enable(): void;
  31898. /**
  31899. * Disables the cortex.
  31900. */
  31901. disable(): void;
  31902. /**
  31903. * Disposes the sphere.
  31904. * @param {bolean} force
  31905. */
  31906. dispose(force?: boolean): void;
  31907. private getImpostorForceAndContactPoint;
  31908. private _tick;
  31909. /*** Helpers ***/
  31910. private _prepareCylinder;
  31911. private _intersectsWithCylinder;
  31912. }
  31913. /***** Enums *****/
  31914. /**
  31915. * The strenght of the force in correspondence to the distance of the affected object
  31916. */
  31917. enum PhysicsRadialImpulseFalloff {
  31918. /** Defines that impulse is constant in strength across it's whole radius */
  31919. Constant = 0,
  31920. /** DEfines that impulse gets weaker if it's further from the origin */
  31921. Linear = 1
  31922. }
  31923. /**
  31924. * The strenght of the force in correspondence to the distance of the affected object
  31925. */
  31926. enum PhysicsUpdraftMode {
  31927. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  31928. Center = 0,
  31929. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  31930. Perpendicular = 1
  31931. }
  31932. /***** Data interfaces *****/
  31933. interface PhysicsForceAndContactPoint {
  31934. force: Vector3;
  31935. contactPoint: Vector3;
  31936. }
  31937. interface PhysicsRadialExplosionEventData {
  31938. sphere: Mesh;
  31939. rays: Array<Ray>;
  31940. }
  31941. interface PhysicsGravitationalFieldEventData {
  31942. sphere: Mesh;
  31943. }
  31944. interface PhysicsUpdraftEventData {
  31945. cylinder: Mesh;
  31946. }
  31947. interface PhysicsVortexEventData {
  31948. cylinder: Mesh;
  31949. }
  31950. }
  31951. declare module BABYLON {
  31952. interface PhysicsImpostorParameters {
  31953. mass: number;
  31954. friction?: number;
  31955. restitution?: number;
  31956. nativeOptions?: any;
  31957. ignoreParent?: boolean;
  31958. disableBidirectionalTransformation?: boolean;
  31959. }
  31960. interface IPhysicsEnabledObject {
  31961. position: Vector3;
  31962. rotationQuaternion: Nullable<Quaternion>;
  31963. scaling: Vector3;
  31964. rotation?: Vector3;
  31965. parent?: any;
  31966. getBoundingInfo(): BoundingInfo;
  31967. computeWorldMatrix(force: boolean): Matrix;
  31968. getWorldMatrix?(): Matrix;
  31969. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31970. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31971. getIndices?(): Nullable<IndicesArray>;
  31972. getScene?(): Scene;
  31973. getAbsolutePosition(): Vector3;
  31974. getAbsolutePivotPoint(): Vector3;
  31975. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31976. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31977. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31978. getClassName(): string;
  31979. }
  31980. class PhysicsImpostor {
  31981. object: IPhysicsEnabledObject;
  31982. type: number;
  31983. private _options;
  31984. private _scene?;
  31985. static DEFAULT_OBJECT_SIZE: Vector3;
  31986. static IDENTITY_QUATERNION: Quaternion;
  31987. private _physicsEngine;
  31988. private _physicsBody;
  31989. private _bodyUpdateRequired;
  31990. private _onBeforePhysicsStepCallbacks;
  31991. private _onAfterPhysicsStepCallbacks;
  31992. private _onPhysicsCollideCallbacks;
  31993. private _deltaPosition;
  31994. private _deltaRotation;
  31995. private _deltaRotationConjugated;
  31996. private _parent;
  31997. private _isDisposed;
  31998. private static _tmpVecs;
  31999. private static _tmpQuat;
  32000. readonly isDisposed: boolean;
  32001. mass: number;
  32002. friction: number;
  32003. restitution: number;
  32004. uniqueId: number;
  32005. private _joints;
  32006. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32007. /**
  32008. * This function will completly initialize this impostor.
  32009. * It will create a new body - but only if this mesh has no parent.
  32010. * If it has, this impostor will not be used other than to define the impostor
  32011. * of the child mesh.
  32012. * @hidden
  32013. */
  32014. _init(): void;
  32015. private _getPhysicsParent;
  32016. /**
  32017. * Should a new body be generated.
  32018. */
  32019. isBodyInitRequired(): boolean;
  32020. setScalingUpdated(updated: boolean): void;
  32021. /**
  32022. * Force a regeneration of this or the parent's impostor's body.
  32023. * Use under cautious - This will remove all joints already implemented.
  32024. */
  32025. forceUpdate(): void;
  32026. /**
  32027. * Gets the body that holds this impostor. Either its own, or its parent.
  32028. */
  32029. /**
  32030. * Set the physics body. Used mainly by the physics engine/plugin
  32031. */
  32032. physicsBody: any;
  32033. parent: Nullable<PhysicsImpostor>;
  32034. resetUpdateFlags(): void;
  32035. getObjectExtendSize(): Vector3;
  32036. getObjectCenter(): Vector3;
  32037. /**
  32038. * Get a specific parametes from the options parameter.
  32039. */
  32040. getParam(paramName: string): any;
  32041. /**
  32042. * Sets a specific parameter in the options given to the physics plugin
  32043. */
  32044. setParam(paramName: string, value: number): void;
  32045. /**
  32046. * Specifically change the body's mass option. Won't recreate the physics body object
  32047. */
  32048. setMass(mass: number): void;
  32049. getLinearVelocity(): Nullable<Vector3>;
  32050. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32051. getAngularVelocity(): Nullable<Vector3>;
  32052. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32053. /**
  32054. * Execute a function with the physics plugin native code.
  32055. * Provide a function the will have two variables - the world object and the physics body object.
  32056. */
  32057. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32058. /**
  32059. * Register a function that will be executed before the physics world is stepping forward.
  32060. */
  32061. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32062. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32063. /**
  32064. * Register a function that will be executed after the physics step
  32065. */
  32066. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32067. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32068. /**
  32069. * register a function that will be executed when this impostor collides against a different body.
  32070. */
  32071. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32072. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32073. private _tmpQuat;
  32074. private _tmpQuat2;
  32075. getParentsRotation(): Quaternion;
  32076. /**
  32077. * this function is executed by the physics engine.
  32078. */
  32079. beforeStep: () => void;
  32080. /**
  32081. * this function is executed by the physics engine.
  32082. */
  32083. afterStep: () => void;
  32084. /**
  32085. * Legacy collision detection event support
  32086. */
  32087. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32088. onCollide: (e: {
  32089. body: any;
  32090. }) => void;
  32091. /**
  32092. * Apply a force
  32093. */
  32094. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32095. /**
  32096. * Apply an impulse
  32097. */
  32098. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32099. /**
  32100. * A help function to create a joint.
  32101. */
  32102. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32103. /**
  32104. * Add a joint to this impostor with a different impostor.
  32105. */
  32106. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32107. /**
  32108. * Will keep this body still, in a sleep mode.
  32109. */
  32110. sleep(): PhysicsImpostor;
  32111. /**
  32112. * Wake the body up.
  32113. */
  32114. wakeUp(): PhysicsImpostor;
  32115. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32116. dispose(): void;
  32117. setDeltaPosition(position: Vector3): void;
  32118. setDeltaRotation(rotation: Quaternion): void;
  32119. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32120. getRadius(): number;
  32121. /**
  32122. * Sync a bone with this impostor
  32123. * @param bone The bone to sync to the impostor.
  32124. * @param boneMesh The mesh that the bone is influencing.
  32125. * @param jointPivot The pivot of the joint / bone in local space.
  32126. * @param distToJoint Optional distance from the impostor to the joint.
  32127. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32128. */
  32129. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32130. /**
  32131. * Sync impostor to a bone
  32132. * @param bone The bone that the impostor will be synced to.
  32133. * @param boneMesh The mesh that the bone is influencing.
  32134. * @param jointPivot The pivot of the joint / bone in local space.
  32135. * @param distToJoint Optional distance from the impostor to the joint.
  32136. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32137. * @param boneAxis Optional vector3 axis the bone is aligned with
  32138. */
  32139. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32140. static NoImpostor: number;
  32141. static SphereImpostor: number;
  32142. static BoxImpostor: number;
  32143. static PlaneImpostor: number;
  32144. static MeshImpostor: number;
  32145. static CylinderImpostor: number;
  32146. static ParticleImpostor: number;
  32147. static HeightmapImpostor: number;
  32148. }
  32149. }
  32150. declare module BABYLON {
  32151. interface PhysicsJointData {
  32152. mainPivot?: Vector3;
  32153. connectedPivot?: Vector3;
  32154. mainAxis?: Vector3;
  32155. connectedAxis?: Vector3;
  32156. collision?: boolean;
  32157. nativeParams?: any;
  32158. }
  32159. /**
  32160. * This is a holder class for the physics joint created by the physics plugin.
  32161. * It holds a set of functions to control the underlying joint.
  32162. */
  32163. class PhysicsJoint {
  32164. type: number;
  32165. jointData: PhysicsJointData;
  32166. private _physicsJoint;
  32167. protected _physicsPlugin: IPhysicsEnginePlugin;
  32168. constructor(type: number, jointData: PhysicsJointData);
  32169. physicsJoint: any;
  32170. physicsPlugin: IPhysicsEnginePlugin;
  32171. /**
  32172. * Execute a function that is physics-plugin specific.
  32173. * @param {Function} func the function that will be executed.
  32174. * It accepts two parameters: the physics world and the physics joint.
  32175. */
  32176. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32177. static DistanceJoint: number;
  32178. static HingeJoint: number;
  32179. static BallAndSocketJoint: number;
  32180. static WheelJoint: number;
  32181. static SliderJoint: number;
  32182. static PrismaticJoint: number;
  32183. static UniversalJoint: number;
  32184. static Hinge2Joint: number;
  32185. static PointToPointJoint: number;
  32186. static SpringJoint: number;
  32187. static LockJoint: number;
  32188. }
  32189. /**
  32190. * A class representing a physics distance joint.
  32191. */
  32192. class DistanceJoint extends PhysicsJoint {
  32193. constructor(jointData: DistanceJointData);
  32194. /**
  32195. * Update the predefined distance.
  32196. */
  32197. updateDistance(maxDistance: number, minDistance?: number): void;
  32198. }
  32199. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32200. constructor(type: number, jointData: PhysicsJointData);
  32201. /**
  32202. * Set the motor values.
  32203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32204. * @param {number} force the force to apply
  32205. * @param {number} maxForce max force for this motor.
  32206. */
  32207. setMotor(force?: number, maxForce?: number): void;
  32208. /**
  32209. * Set the motor's limits.
  32210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32211. */
  32212. setLimit(upperLimit: number, lowerLimit?: number): void;
  32213. }
  32214. /**
  32215. * This class represents a single hinge physics joint
  32216. */
  32217. class HingeJoint extends MotorEnabledJoint {
  32218. constructor(jointData: PhysicsJointData);
  32219. /**
  32220. * Set the motor values.
  32221. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32222. * @param {number} force the force to apply
  32223. * @param {number} maxForce max force for this motor.
  32224. */
  32225. setMotor(force?: number, maxForce?: number): void;
  32226. /**
  32227. * Set the motor's limits.
  32228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32229. */
  32230. setLimit(upperLimit: number, lowerLimit?: number): void;
  32231. }
  32232. /**
  32233. * This class represents a dual hinge physics joint (same as wheel joint)
  32234. */
  32235. class Hinge2Joint extends MotorEnabledJoint {
  32236. constructor(jointData: PhysicsJointData);
  32237. /**
  32238. * Set the motor values.
  32239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32240. * @param {number} force the force to apply
  32241. * @param {number} maxForce max force for this motor.
  32242. * @param {motorIndex} the motor's index, 0 or 1.
  32243. */
  32244. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32245. /**
  32246. * Set the motor limits.
  32247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32248. * @param {number} upperLimit the upper limit
  32249. * @param {number} lowerLimit lower limit
  32250. * @param {motorIndex} the motor's index, 0 or 1.
  32251. */
  32252. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32253. }
  32254. interface IMotorEnabledJoint {
  32255. physicsJoint: any;
  32256. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32257. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32258. }
  32259. /**
  32260. * Joint data for a distance joint
  32261. */
  32262. interface DistanceJointData extends PhysicsJointData {
  32263. /**
  32264. * Max distance the 2 joint objects can be apart
  32265. */
  32266. maxDistance: number;
  32267. }
  32268. /**
  32269. * Joint data from a spring joint
  32270. */
  32271. interface SpringJointData extends PhysicsJointData {
  32272. /**
  32273. * Length of the spring
  32274. */
  32275. length: number;
  32276. /**
  32277. * Stiffness of the spring
  32278. */
  32279. stiffness: number;
  32280. /**
  32281. * Damping of the spring
  32282. */
  32283. damping: number;
  32284. /** this callback will be called when applying the force to the impostors. */
  32285. forceApplicationCallback: () => void;
  32286. }
  32287. }
  32288. declare module BABYLON {
  32289. interface Scene {
  32290. /**
  32291. * The list of reflection probes added to the scene
  32292. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  32293. */
  32294. reflectionProbes: Array<ReflectionProbe>;
  32295. }
  32296. /**
  32297. * Class used to generate realtime reflection / refraction cube textures
  32298. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  32299. */
  32300. class ReflectionProbe {
  32301. /** defines the name of the probe */
  32302. name: string;
  32303. private _scene;
  32304. private _renderTargetTexture;
  32305. private _projectionMatrix;
  32306. private _viewMatrix;
  32307. private _target;
  32308. private _add;
  32309. private _attachedMesh;
  32310. private _invertYAxis;
  32311. /** Gets or sets probe position (center of the cube map) */
  32312. position: Vector3;
  32313. /**
  32314. * Creates a new reflection probe
  32315. * @param name defines the name of the probe
  32316. * @param size defines the texture resolution (for each face)
  32317. * @param scene defines the hosting scene
  32318. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  32319. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  32320. */
  32321. constructor(
  32322. /** defines the name of the probe */
  32323. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  32324. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  32325. samples: number;
  32326. /** Gets or sets the refresh rate to use (on every frame by default) */
  32327. refreshRate: number;
  32328. /**
  32329. * Gets the hosting scene
  32330. * @returns a Scene
  32331. */
  32332. getScene(): Scene;
  32333. /** Gets the internal CubeTexture used to render to */
  32334. readonly cubeTexture: RenderTargetTexture;
  32335. /** Gets the list of meshes to render */
  32336. readonly renderList: Nullable<AbstractMesh[]>;
  32337. /**
  32338. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  32339. * @param mesh defines the mesh to attach to
  32340. */
  32341. attachToMesh(mesh: AbstractMesh): void;
  32342. /**
  32343. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  32344. * @param renderingGroupId The rendering group id corresponding to its index
  32345. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32346. */
  32347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  32348. /**
  32349. * Clean all associated resources
  32350. */
  32351. dispose(): void;
  32352. }
  32353. }
  32354. declare module BABYLON {
  32355. /**
  32356. * Postprocess used to generate anaglyphic rendering
  32357. */
  32358. class AnaglyphPostProcess extends PostProcess {
  32359. private _passedProcess;
  32360. /**
  32361. * Creates a new AnaglyphPostProcess
  32362. * @param name defines postprocess name
  32363. * @param options defines creation options or target ratio scale
  32364. * @param rigCameras defines cameras using this postprocess
  32365. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  32366. * @param engine defines hosting engine
  32367. * @param reusable defines if the postprocess will be reused multiple times per frame
  32368. */
  32369. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  32370. }
  32371. }
  32372. declare module BABYLON {
  32373. /**
  32374. * Post process used to render in black and white
  32375. */
  32376. class BlackAndWhitePostProcess extends PostProcess {
  32377. /**
  32378. * Linear about to convert he result to black and white (default: 1)
  32379. */
  32380. degree: number;
  32381. /**
  32382. * Creates a black and white post process
  32383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  32384. * @param name The name of the effect.
  32385. * @param options The required width/height ratio to downsize to before computing the render pass.
  32386. * @param camera The camera to apply the render pass to.
  32387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32388. * @param engine The engine which the post process will be applied. (default: current engine)
  32389. * @param reusable If the post process can be reused on the same frame. (default: false)
  32390. */
  32391. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  32392. }
  32393. }
  32394. declare module BABYLON {
  32395. /**
  32396. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  32397. */
  32398. class BloomEffect extends PostProcessRenderEffect {
  32399. private bloomScale;
  32400. /**
  32401. * @hidden Internal
  32402. */
  32403. _effects: Array<PostProcess>;
  32404. /**
  32405. * @hidden Internal
  32406. */
  32407. _downscale: ExtractHighlightsPostProcess;
  32408. private _blurX;
  32409. private _blurY;
  32410. private _merge;
  32411. /**
  32412. * The luminance threshold to find bright areas of the image to bloom.
  32413. */
  32414. threshold: number;
  32415. /**
  32416. * The strength of the bloom.
  32417. */
  32418. weight: number;
  32419. /**
  32420. * Specifies the size of the bloom blur kernel, relative to the final output size
  32421. */
  32422. kernel: number;
  32423. /**
  32424. * Creates a new instance of @see BloomEffect
  32425. * @param scene The scene the effect belongs to.
  32426. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  32427. * @param bloomKernel The size of the kernel to be used when applying the blur.
  32428. * @param bloomWeight The the strength of bloom.
  32429. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  32430. * @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)
  32431. */
  32432. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  32433. /**
  32434. * Disposes each of the internal effects for a given camera.
  32435. * @param camera The camera to dispose the effect on.
  32436. */
  32437. disposeEffects(camera: Camera): void;
  32438. /**
  32439. * @hidden Internal
  32440. */
  32441. _updateEffects(): void;
  32442. /**
  32443. * Internal
  32444. * @returns if all the contained post processes are ready.
  32445. * @hidden
  32446. */
  32447. _isReady(): boolean;
  32448. }
  32449. }
  32450. declare module BABYLON {
  32451. /**
  32452. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  32453. */
  32454. class BloomMergePostProcess extends PostProcess {
  32455. /** Weight of the bloom to be added to the original input. */
  32456. weight: number;
  32457. /**
  32458. * Creates a new instance of @see BloomMergePostProcess
  32459. * @param name The name of the effect.
  32460. * @param originalFromInput Post process which's input will be used for the merge.
  32461. * @param blurred Blurred highlights post process which's output will be used.
  32462. * @param weight Weight of the bloom to be added to the original input.
  32463. * @param options The required width/height ratio to downsize to before computing the render pass.
  32464. * @param camera The camera to apply the render pass to.
  32465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32466. * @param engine The engine which the post process will be applied. (default: current engine)
  32467. * @param reusable If the post process can be reused on the same frame. (default: false)
  32468. * @param textureType Type of textures used when performing the post process. (default: 0)
  32469. * @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)
  32470. */
  32471. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  32472. /** Weight of the bloom to be added to the original input. */
  32473. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  32474. }
  32475. }
  32476. declare module BABYLON {
  32477. /**
  32478. * The Blur Post Process which blurs an image based on a kernel and direction.
  32479. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  32480. */
  32481. class BlurPostProcess extends PostProcess {
  32482. /** The direction in which to blur the image. */
  32483. direction: Vector2;
  32484. private blockCompilation;
  32485. protected _kernel: number;
  32486. protected _idealKernel: number;
  32487. protected _packedFloat: boolean;
  32488. private _staticDefines;
  32489. /**
  32490. * Sets the length in pixels of the blur sample region
  32491. */
  32492. /**
  32493. * Gets the length in pixels of the blur sample region
  32494. */
  32495. kernel: number;
  32496. /**
  32497. * Sets wether or not the blur needs to unpack/repack floats
  32498. */
  32499. /**
  32500. * Gets wether or not the blur is unpacking/repacking floats
  32501. */
  32502. packedFloat: boolean;
  32503. /**
  32504. * Creates a new instance BlurPostProcess
  32505. * @param name The name of the effect.
  32506. * @param direction The direction in which to blur the image.
  32507. * @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.
  32508. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  32509. * @param camera The camera to apply the render pass to.
  32510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32511. * @param engine The engine which the post process will be applied. (default: current engine)
  32512. * @param reusable If the post process can be reused on the same frame. (default: false)
  32513. * @param textureType Type of textures used when performing the post process. (default: 0)
  32514. * @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)
  32515. */
  32516. constructor(name: string,
  32517. /** The direction in which to blur the image. */
  32518. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  32519. /**
  32520. * Updates the effect with the current post process compile time values and recompiles the shader.
  32521. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  32522. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  32523. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  32524. * @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
  32525. * @param onCompiled Called when the shader has been compiled.
  32526. * @param onError Called if there is an error when compiling a shader.
  32527. */
  32528. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  32529. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  32530. /**
  32531. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  32532. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  32533. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  32534. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  32535. * The gaps between physical kernels are compensated for in the weighting of the samples
  32536. * @param idealKernel Ideal blur kernel.
  32537. * @return Nearest best kernel.
  32538. */
  32539. protected _nearestBestKernel(idealKernel: number): number;
  32540. /**
  32541. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  32542. * @param x The point on the Gaussian distribution to sample.
  32543. * @return the value of the Gaussian function at x.
  32544. */
  32545. protected _gaussianWeight(x: number): number;
  32546. /**
  32547. * Generates a string that can be used as a floating point number in GLSL.
  32548. * @param x Value to print.
  32549. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  32550. * @return GLSL float string.
  32551. */
  32552. protected _glslFloat(x: number, decimalFigures?: number): string;
  32553. }
  32554. }
  32555. declare module BABYLON {
  32556. /**
  32557. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  32558. */
  32559. class ChromaticAberrationPostProcess extends PostProcess {
  32560. /**
  32561. * The amount of seperation of rgb channels (default: 30)
  32562. */
  32563. aberrationAmount: number;
  32564. /**
  32565. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  32566. */
  32567. radialIntensity: number;
  32568. /**
  32569. * 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))
  32570. */
  32571. direction: Vector2;
  32572. /**
  32573. * 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))
  32574. */
  32575. centerPosition: Vector2;
  32576. /**
  32577. * Creates a new instance ChromaticAberrationPostProcess
  32578. * @param name The name of the effect.
  32579. * @param screenWidth The width of the screen to apply the effect on.
  32580. * @param screenHeight The height of the screen to apply the effect on.
  32581. * @param options The required width/height ratio to downsize to before computing the render pass.
  32582. * @param camera The camera to apply the render pass to.
  32583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32584. * @param engine The engine which the post process will be applied. (default: current engine)
  32585. * @param reusable If the post process can be reused on the same frame. (default: false)
  32586. * @param textureType Type of textures used when performing the post process. (default: 0)
  32587. * @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)
  32588. */
  32589. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  32590. }
  32591. }
  32592. declare module BABYLON {
  32593. /**
  32594. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  32595. */
  32596. class CircleOfConfusionPostProcess extends PostProcess {
  32597. /**
  32598. * 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.
  32599. */
  32600. lensSize: number;
  32601. /**
  32602. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  32603. */
  32604. fStop: number;
  32605. /**
  32606. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  32607. */
  32608. focusDistance: number;
  32609. /**
  32610. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  32611. */
  32612. focalLength: number;
  32613. private _depthTexture;
  32614. /**
  32615. * Creates a new instance CircleOfConfusionPostProcess
  32616. * @param name The name of the effect.
  32617. * @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.
  32618. * @param options The required width/height ratio to downsize to before computing the render pass.
  32619. * @param camera The camera to apply the render pass to.
  32620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32621. * @param engine The engine which the post process will be applied. (default: current engine)
  32622. * @param reusable If the post process can be reused on the same frame. (default: false)
  32623. * @param textureType Type of textures used when performing the post process. (default: 0)
  32624. * @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)
  32625. */
  32626. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  32627. /**
  32628. * 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.
  32629. */
  32630. depthTexture: RenderTargetTexture;
  32631. }
  32632. }
  32633. declare module BABYLON {
  32634. /**
  32635. *
  32636. * This post-process allows the modification of rendered colors by using
  32637. * a 'look-up table' (LUT). This effect is also called Color Grading.
  32638. *
  32639. * The object needs to be provided an url to a texture containing the color
  32640. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  32641. * Use an image editing software to tweak the LUT to match your needs.
  32642. *
  32643. * For an example of a color LUT, see here:
  32644. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  32645. * For explanations on color grading, see here:
  32646. * @see http://udn.epicgames.com/Three/ColorGrading.html
  32647. *
  32648. */
  32649. class ColorCorrectionPostProcess extends PostProcess {
  32650. private _colorTableTexture;
  32651. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  32652. }
  32653. }
  32654. declare module BABYLON {
  32655. /**
  32656. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  32657. * input texture to perform effects such as edge detection or sharpening
  32658. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  32659. */
  32660. class ConvolutionPostProcess extends PostProcess {
  32661. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  32662. kernel: number[];
  32663. /**
  32664. * Creates a new instance ConvolutionPostProcess
  32665. * @param name The name of the effect.
  32666. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  32667. * @param options The required width/height ratio to downsize to before computing the render pass.
  32668. * @param camera The camera to apply the render pass to.
  32669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32670. * @param engine The engine which the post process will be applied. (default: current engine)
  32671. * @param reusable If the post process can be reused on the same frame. (default: false)
  32672. * @param textureType Type of textures used when performing the post process. (default: 0)
  32673. */
  32674. constructor(name: string,
  32675. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  32676. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  32677. /**
  32678. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  32679. */
  32680. static EdgeDetect0Kernel: number[];
  32681. /**
  32682. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  32683. */
  32684. static EdgeDetect1Kernel: number[];
  32685. /**
  32686. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  32687. */
  32688. static EdgeDetect2Kernel: number[];
  32689. /**
  32690. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  32691. */
  32692. static SharpenKernel: number[];
  32693. /**
  32694. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  32695. */
  32696. static EmbossKernel: number[];
  32697. /**
  32698. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  32699. */
  32700. static GaussianKernel: number[];
  32701. }
  32702. }
  32703. declare module BABYLON {
  32704. /**
  32705. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  32706. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  32707. * based on samples that have a large difference in distance than the center pixel.
  32708. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  32709. */
  32710. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  32711. direction: Vector2;
  32712. /**
  32713. * Creates a new instance CircleOfConfusionPostProcess
  32714. * @param name The name of the effect.
  32715. * @param scene The scene the effect belongs to.
  32716. * @param direction The direction the blur should be applied.
  32717. * @param kernel The size of the kernel used to blur.
  32718. * @param options The required width/height ratio to downsize to before computing the render pass.
  32719. * @param camera The camera to apply the render pass to.
  32720. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  32721. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  32722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32723. * @param engine The engine which the post process will be applied. (default: current engine)
  32724. * @param reusable If the post process can be reused on the same frame. (default: false)
  32725. * @param textureType Type of textures used when performing the post process. (default: 0)
  32726. * @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)
  32727. */
  32728. 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);
  32729. }
  32730. }
  32731. declare module BABYLON {
  32732. /**
  32733. * Specifies the level of max blur that should be applied when using the depth of field effect
  32734. */
  32735. enum DepthOfFieldEffectBlurLevel {
  32736. /**
  32737. * Subtle blur
  32738. */
  32739. Low = 0,
  32740. /**
  32741. * Medium blur
  32742. */
  32743. Medium = 1,
  32744. /**
  32745. * Large blur
  32746. */
  32747. High = 2
  32748. }
  32749. /**
  32750. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  32751. */
  32752. class DepthOfFieldEffect extends PostProcessRenderEffect {
  32753. private _circleOfConfusion;
  32754. /**
  32755. * @hidden Internal, blurs from high to low
  32756. */
  32757. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  32758. private _depthOfFieldBlurY;
  32759. private _dofMerge;
  32760. /**
  32761. * @hidden Internal post processes in depth of field effect
  32762. */
  32763. _effects: Array<PostProcess>;
  32764. /**
  32765. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  32766. */
  32767. focalLength: number;
  32768. /**
  32769. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  32770. */
  32771. fStop: number;
  32772. /**
  32773. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  32774. */
  32775. focusDistance: number;
  32776. /**
  32777. * 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.
  32778. */
  32779. lensSize: number;
  32780. /**
  32781. * Creates a new instance DepthOfFieldEffect
  32782. * @param scene The scene the effect belongs to.
  32783. * @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.
  32784. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  32785. * @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)
  32786. */
  32787. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  32788. /**
  32789. * 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.
  32790. */
  32791. depthTexture: RenderTargetTexture;
  32792. /**
  32793. * Disposes each of the internal effects for a given camera.
  32794. * @param camera The camera to dispose the effect on.
  32795. */
  32796. disposeEffects(camera: Camera): void;
  32797. /**
  32798. * @hidden Internal
  32799. */
  32800. _updateEffects(): void;
  32801. /**
  32802. * Internal
  32803. * @returns if all the contained post processes are ready.
  32804. * @hidden
  32805. */
  32806. _isReady(): boolean;
  32807. }
  32808. }
  32809. declare module BABYLON {
  32810. /**
  32811. * Options to be set when merging outputs from the default pipeline.
  32812. */
  32813. class DepthOfFieldMergePostProcessOptions {
  32814. /**
  32815. * The original image to merge on top of
  32816. */
  32817. originalFromInput: PostProcess;
  32818. /**
  32819. * Parameters to perform the merge of the depth of field effect
  32820. */
  32821. depthOfField?: {
  32822. circleOfConfusion: PostProcess;
  32823. blurSteps: Array<PostProcess>;
  32824. };
  32825. /**
  32826. * Parameters to perform the merge of bloom effect
  32827. */
  32828. bloom?: {
  32829. blurred: PostProcess;
  32830. weight: number;
  32831. };
  32832. }
  32833. /**
  32834. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  32835. */
  32836. class DepthOfFieldMergePostProcess extends PostProcess {
  32837. private blurSteps;
  32838. /**
  32839. * Creates a new instance of DepthOfFieldMergePostProcess
  32840. * @param name The name of the effect.
  32841. * @param originalFromInput Post process which's input will be used for the merge.
  32842. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  32843. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  32844. * @param options The required width/height ratio to downsize to before computing the render pass.
  32845. * @param camera The camera to apply the render pass to.
  32846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32847. * @param engine The engine which the post process will be applied. (default: current engine)
  32848. * @param reusable If the post process can be reused on the same frame. (default: false)
  32849. * @param textureType Type of textures used when performing the post process. (default: 0)
  32850. * @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)
  32851. */
  32852. 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);
  32853. /**
  32854. * Updates the effect with the current post process compile time values and recompiles the shader.
  32855. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  32856. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  32857. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  32858. * @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
  32859. * @param onCompiled Called when the shader has been compiled.
  32860. * @param onError Called if there is an error when compiling a shader.
  32861. */
  32862. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  32863. }
  32864. }
  32865. declare module BABYLON {
  32866. /**
  32867. * DisplayPassPostProcess which produces an output the same as it's input
  32868. */
  32869. class DisplayPassPostProcess extends PostProcess {
  32870. /**
  32871. * Creates the DisplayPassPostProcess
  32872. * @param name The name of the effect.
  32873. * @param options The required width/height ratio to downsize to before computing the render pass.
  32874. * @param camera The camera to apply the render pass to.
  32875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32876. * @param engine The engine which the post process will be applied. (default: current engine)
  32877. * @param reusable If the post process can be reused on the same frame. (default: false)
  32878. */
  32879. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  32880. }
  32881. }
  32882. declare module BABYLON {
  32883. /**
  32884. * 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.
  32885. */
  32886. class ExtractHighlightsPostProcess extends PostProcess {
  32887. /**
  32888. * The luminance threshold, pixels below this value will be set to black.
  32889. */
  32890. threshold: number;
  32891. /** @hidden */
  32892. _exposure: number;
  32893. /**
  32894. * Post process which has the input texture to be used when performing highlight extraction
  32895. * @hidden
  32896. */
  32897. _inputPostProcess: Nullable<PostProcess>;
  32898. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  32899. }
  32900. }
  32901. declare module BABYLON {
  32902. /**
  32903. * Applies a kernel filter to the image
  32904. */
  32905. class FilterPostProcess extends PostProcess {
  32906. /** The matrix to be applied to the image */
  32907. kernelMatrix: Matrix;
  32908. /**
  32909. *
  32910. * @param name The name of the effect.
  32911. * @param kernelMatrix The matrix to be applied to the image
  32912. * @param options The required width/height ratio to downsize to before computing the render pass.
  32913. * @param camera The camera to apply the render pass to.
  32914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32915. * @param engine The engine which the post process will be applied. (default: current engine)
  32916. * @param reusable If the post process can be reused on the same frame. (default: false)
  32917. */
  32918. constructor(name: string,
  32919. /** The matrix to be applied to the image */
  32920. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  32921. }
  32922. }
  32923. declare module BABYLON {
  32924. class FxaaPostProcess extends PostProcess {
  32925. texelWidth: number;
  32926. texelHeight: number;
  32927. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  32928. private _getDefines;
  32929. }
  32930. }
  32931. declare module BABYLON {
  32932. /**
  32933. * The GrainPostProcess adds noise to the image at mid luminance levels
  32934. */
  32935. class GrainPostProcess extends PostProcess {
  32936. /**
  32937. * The intensity of the grain added (default: 30)
  32938. */
  32939. intensity: number;
  32940. /**
  32941. * If the grain should be randomized on every frame
  32942. */
  32943. animated: boolean;
  32944. /**
  32945. * Creates a new instance of @see GrainPostProcess
  32946. * @param name The name of the effect.
  32947. * @param options The required width/height ratio to downsize to before computing the render pass.
  32948. * @param camera The camera to apply the render pass to.
  32949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32950. * @param engine The engine which the post process will be applied. (default: current engine)
  32951. * @param reusable If the post process can be reused on the same frame. (default: false)
  32952. * @param textureType Type of textures used when performing the post process. (default: 0)
  32953. * @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)
  32954. */
  32955. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  32956. }
  32957. }
  32958. declare module BABYLON {
  32959. /**
  32960. * Extracts highlights from the image
  32961. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  32962. */
  32963. class HighlightsPostProcess extends PostProcess {
  32964. /**
  32965. * Extracts highlights from the image
  32966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  32967. * @param name The name of the effect.
  32968. * @param options The required width/height ratio to downsize to before computing the render pass.
  32969. * @param camera The camera to apply the render pass to.
  32970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  32971. * @param engine The engine which the post process will be applied. (default: current engine)
  32972. * @param reusable If the post process can be reused on the same frame. (default: false)
  32973. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  32974. */
  32975. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  32976. }
  32977. }
  32978. declare module BABYLON {
  32979. /**
  32980. * ImageProcessingPostProcess
  32981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  32982. */
  32983. class ImageProcessingPostProcess extends PostProcess {
  32984. /**
  32985. * Default configuration related to image processing available in the PBR Material.
  32986. */
  32987. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32988. /**
  32989. * Gets the image processing configuration used either in this material.
  32990. */
  32991. /**
  32992. * Sets the Default image processing configuration used either in the this material.
  32993. *
  32994. * If sets to null, the scene one is in use.
  32995. */
  32996. imageProcessingConfiguration: ImageProcessingConfiguration;
  32997. /**
  32998. * Keep track of the image processing observer to allow dispose and replace.
  32999. */
  33000. private _imageProcessingObserver;
  33001. /**
  33002. * Attaches a new image processing configuration to the PBR Material.
  33003. * @param configuration
  33004. */
  33005. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  33006. /**
  33007. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  33008. */
  33009. /**
  33010. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  33011. */
  33012. colorCurves: Nullable<ColorCurves>;
  33013. /**
  33014. * Gets wether the color curves effect is enabled.
  33015. */
  33016. /**
  33017. * Sets wether the color curves effect is enabled.
  33018. */
  33019. colorCurvesEnabled: boolean;
  33020. /**
  33021. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  33022. */
  33023. /**
  33024. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  33025. */
  33026. colorGradingTexture: Nullable<BaseTexture>;
  33027. /**
  33028. * Gets wether the color grading effect is enabled.
  33029. */
  33030. /**
  33031. * Gets wether the color grading effect is enabled.
  33032. */
  33033. colorGradingEnabled: boolean;
  33034. /**
  33035. * Gets exposure used in the effect.
  33036. */
  33037. /**
  33038. * Sets exposure used in the effect.
  33039. */
  33040. exposure: number;
  33041. /**
  33042. * Gets wether tonemapping is enabled or not.
  33043. */
  33044. /**
  33045. * Sets wether tonemapping is enabled or not
  33046. */
  33047. toneMappingEnabled: boolean;
  33048. /**
  33049. * Gets contrast used in the effect.
  33050. */
  33051. /**
  33052. * Sets contrast used in the effect.
  33053. */
  33054. contrast: number;
  33055. /**
  33056. * Gets Vignette stretch size.
  33057. */
  33058. /**
  33059. * Sets Vignette stretch size.
  33060. */
  33061. vignetteStretch: number;
  33062. /**
  33063. * Gets Vignette centre X Offset.
  33064. */
  33065. /**
  33066. * Sets Vignette centre X Offset.
  33067. */
  33068. vignetteCentreX: number;
  33069. /**
  33070. * Gets Vignette centre Y Offset.
  33071. */
  33072. /**
  33073. * Sets Vignette centre Y Offset.
  33074. */
  33075. vignetteCentreY: number;
  33076. /**
  33077. * Gets Vignette weight or intensity of the vignette effect.
  33078. */
  33079. /**
  33080. * Sets Vignette weight or intensity of the vignette effect.
  33081. */
  33082. vignetteWeight: number;
  33083. /**
  33084. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  33085. * if vignetteEnabled is set to true.
  33086. */
  33087. /**
  33088. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  33089. * if vignetteEnabled is set to true.
  33090. */
  33091. vignetteColor: Color4;
  33092. /**
  33093. * Gets Camera field of view used by the Vignette effect.
  33094. */
  33095. /**
  33096. * Sets Camera field of view used by the Vignette effect.
  33097. */
  33098. vignetteCameraFov: number;
  33099. /**
  33100. * Gets the vignette blend mode allowing different kind of effect.
  33101. */
  33102. /**
  33103. * Sets the vignette blend mode allowing different kind of effect.
  33104. */
  33105. vignetteBlendMode: number;
  33106. /**
  33107. * Gets wether the vignette effect is enabled.
  33108. */
  33109. /**
  33110. * Sets wether the vignette effect is enabled.
  33111. */
  33112. vignetteEnabled: boolean;
  33113. private _fromLinearSpace;
  33114. /**
  33115. * Gets wether the input of the processing is in Gamma or Linear Space.
  33116. */
  33117. /**
  33118. * Sets wether the input of the processing is in Gamma or Linear Space.
  33119. */
  33120. fromLinearSpace: boolean;
  33121. /**
  33122. * Defines cache preventing GC.
  33123. */
  33124. private _defines;
  33125. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  33126. /**
  33127. * "ImageProcessingPostProcess"
  33128. * @returns "ImageProcessingPostProcess"
  33129. */
  33130. getClassName(): string;
  33131. protected _updateParameters(): void;
  33132. dispose(camera?: Camera): void;
  33133. }
  33134. }
  33135. declare module BABYLON {
  33136. class PassPostProcess extends PostProcess {
  33137. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33138. }
  33139. }
  33140. declare module BABYLON {
  33141. /**
  33142. * Size options for a post process
  33143. */
  33144. type PostProcessOptions = {
  33145. width: number;
  33146. height: number;
  33147. };
  33148. /**
  33149. * PostProcess can be used to apply a shader to a texture after it has been rendered
  33150. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  33151. */
  33152. class PostProcess {
  33153. /** Name of the PostProcess. */
  33154. name: string;
  33155. /**
  33156. * Width of the texture to apply the post process on
  33157. */
  33158. width: number;
  33159. /**
  33160. * Height of the texture to apply the post process on
  33161. */
  33162. height: number;
  33163. /**
  33164. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  33165. * @hidden
  33166. */
  33167. _outputTexture: Nullable<InternalTexture>;
  33168. /**
  33169. * Sampling mode used by the shader
  33170. * See https://doc.babylonjs.com/classes/3.1/texture
  33171. */
  33172. renderTargetSamplingMode: number;
  33173. /**
  33174. * Clear color to use when screen clearing
  33175. */
  33176. clearColor: Color4;
  33177. /**
  33178. * If the buffer needs to be cleared before applying the post process. (default: true)
  33179. * Should be set to false if shader will overwrite all previous pixels.
  33180. */
  33181. autoClear: boolean;
  33182. /**
  33183. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  33184. */
  33185. alphaMode: number;
  33186. /**
  33187. * Sets the setAlphaBlendConstants of the babylon engine
  33188. */
  33189. alphaConstants: Color4;
  33190. /**
  33191. * Animations to be used for the post processing
  33192. */
  33193. animations: Animation[];
  33194. /**
  33195. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  33196. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  33197. */
  33198. enablePixelPerfectMode: boolean;
  33199. /**
  33200. * Force the postprocess to be applied without taking in account viewport
  33201. */
  33202. forceFullscreenViewport: boolean;
  33203. /**
  33204. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  33205. *
  33206. * | Value | Type | Description |
  33207. * | ----- | ----------------------------------- | ----------- |
  33208. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  33209. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  33210. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  33211. *
  33212. */
  33213. scaleMode: number;
  33214. /**
  33215. * Force textures to be a power of two (default: false)
  33216. */
  33217. alwaysForcePOT: boolean;
  33218. private _samples;
  33219. /**
  33220. * Number of sample textures (default: 1)
  33221. */
  33222. samples: number;
  33223. /**
  33224. * Modify the scale of the post process to be the same as the viewport (default: false)
  33225. */
  33226. adaptScaleToCurrentViewport: boolean;
  33227. private _camera;
  33228. private _scene;
  33229. private _engine;
  33230. private _options;
  33231. private _reusable;
  33232. private _textureType;
  33233. /**
  33234. * Smart array of input and output textures for the post process.
  33235. * @hidden
  33236. */
  33237. _textures: SmartArray<InternalTexture>;
  33238. /**
  33239. * The index in _textures that corresponds to the output texture.
  33240. * @hidden
  33241. */
  33242. _currentRenderTextureInd: number;
  33243. private _effect;
  33244. private _samplers;
  33245. private _fragmentUrl;
  33246. private _vertexUrl;
  33247. private _parameters;
  33248. private _scaleRatio;
  33249. protected _indexParameters: any;
  33250. private _shareOutputWithPostProcess;
  33251. private _texelSize;
  33252. private _forcedOutputTexture;
  33253. /**
  33254. * An event triggered when the postprocess is activated.
  33255. */
  33256. onActivateObservable: Observable<Camera>;
  33257. private _onActivateObserver;
  33258. /**
  33259. * A function that is added to the onActivateObservable
  33260. */
  33261. onActivate: Nullable<(camera: Camera) => void>;
  33262. /**
  33263. * An event triggered when the postprocess changes its size.
  33264. */
  33265. onSizeChangedObservable: Observable<PostProcess>;
  33266. private _onSizeChangedObserver;
  33267. /**
  33268. * A function that is added to the onSizeChangedObservable
  33269. */
  33270. onSizeChanged: (postProcess: PostProcess) => void;
  33271. /**
  33272. * An event triggered when the postprocess applies its effect.
  33273. */
  33274. onApplyObservable: Observable<Effect>;
  33275. private _onApplyObserver;
  33276. /**
  33277. * A function that is added to the onApplyObservable
  33278. */
  33279. onApply: (effect: Effect) => void;
  33280. /**
  33281. * An event triggered before rendering the postprocess
  33282. */
  33283. onBeforeRenderObservable: Observable<Effect>;
  33284. private _onBeforeRenderObserver;
  33285. /**
  33286. * A function that is added to the onBeforeRenderObservable
  33287. */
  33288. onBeforeRender: (effect: Effect) => void;
  33289. /**
  33290. * An event triggered after rendering the postprocess
  33291. */
  33292. onAfterRenderObservable: Observable<Effect>;
  33293. private _onAfterRenderObserver;
  33294. /**
  33295. * A function that is added to the onAfterRenderObservable
  33296. */
  33297. onAfterRender: (efect: Effect) => void;
  33298. /**
  33299. * 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
  33300. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  33301. */
  33302. inputTexture: InternalTexture;
  33303. /**
  33304. * Gets the camera which post process is applied to.
  33305. * @returns The camera the post process is applied to.
  33306. */
  33307. getCamera(): Camera;
  33308. /**
  33309. * Gets the texel size of the postprocess.
  33310. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  33311. */
  33312. readonly texelSize: Vector2;
  33313. /**
  33314. * Creates a new instance PostProcess
  33315. * @param name The name of the PostProcess.
  33316. * @param fragmentUrl The url of the fragment shader to be used.
  33317. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  33318. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  33319. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  33320. * @param camera The camera to apply the render pass to.
  33321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33322. * @param engine The engine which the post process will be applied. (default: current engine)
  33323. * @param reusable If the post process can be reused on the same frame. (default: false)
  33324. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  33325. * @param textureType Type of textures used when performing the post process. (default: 0)
  33326. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  33327. * @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
  33328. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  33329. */
  33330. constructor(
  33331. /** Name of the PostProcess. */
  33332. 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);
  33333. /**
  33334. * Gets the engine which this post process belongs to.
  33335. * @returns The engine the post process was enabled with.
  33336. */
  33337. getEngine(): Engine;
  33338. /**
  33339. * The effect that is created when initializing the post process.
  33340. * @returns The created effect corrisponding the the postprocess.
  33341. */
  33342. getEffect(): Effect;
  33343. /**
  33344. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  33345. * @param postProcess The post process to share the output with.
  33346. * @returns This post process.
  33347. */
  33348. shareOutputWith(postProcess: PostProcess): PostProcess;
  33349. /**
  33350. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  33351. * This should be called if the post process that shares output with this post process is disabled/disposed.
  33352. */
  33353. useOwnOutput(): void;
  33354. /**
  33355. * Updates the effect with the current post process compile time values and recompiles the shader.
  33356. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  33357. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  33358. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  33359. * @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
  33360. * @param onCompiled Called when the shader has been compiled.
  33361. * @param onError Called if there is an error when compiling a shader.
  33362. */
  33363. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  33364. /**
  33365. * The post process is reusable if it can be used multiple times within one frame.
  33366. * @returns If the post process is reusable
  33367. */
  33368. isReusable(): boolean;
  33369. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  33370. markTextureDirty(): void;
  33371. /**
  33372. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  33373. * 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.
  33374. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  33375. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  33376. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  33377. * @returns The target texture that was bound to be written to.
  33378. */
  33379. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  33380. /**
  33381. * If the post process is supported.
  33382. */
  33383. readonly isSupported: boolean;
  33384. /**
  33385. * The aspect ratio of the output texture.
  33386. */
  33387. readonly aspectRatio: number;
  33388. /**
  33389. * Get a value indicating if the post-process is ready to be used
  33390. * @returns true if the post-process is ready (shader is compiled)
  33391. */
  33392. isReady(): boolean;
  33393. /**
  33394. * Binds all textures and uniforms to the shader, this will be run on every pass.
  33395. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  33396. */
  33397. apply(): Nullable<Effect>;
  33398. private _disposeTextures;
  33399. /**
  33400. * Disposes the post process.
  33401. * @param camera The camera to dispose the post process on.
  33402. */
  33403. dispose(camera?: Camera): void;
  33404. }
  33405. }
  33406. declare module BABYLON {
  33407. /**
  33408. * PostProcessManager is used to manage one or more post processes or post process pipelines
  33409. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  33410. */
  33411. class PostProcessManager {
  33412. private _scene;
  33413. private _indexBuffer;
  33414. private _vertexBuffers;
  33415. /**
  33416. * Creates a new instance PostProcess
  33417. * @param scene The scene that the post process is associated with.
  33418. */
  33419. constructor(scene: Scene);
  33420. private _prepareBuffers;
  33421. private _buildIndexBuffer;
  33422. /**
  33423. * Rebuilds the vertex buffers of the manager.
  33424. * @hidden
  33425. */
  33426. _rebuild(): void;
  33427. /**
  33428. * Prepares a frame to be run through a post process.
  33429. * @param sourceTexture The input texture to the post procesess. (default: null)
  33430. * @param postProcesses An array of post processes to be run. (default: null)
  33431. * @returns True if the post processes were able to be run.
  33432. * @hidden
  33433. */
  33434. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  33435. /**
  33436. * Manually render a set of post processes to a texture.
  33437. * @param postProcesses An array of post processes to be run.
  33438. * @param targetTexture The target texture to render to.
  33439. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  33440. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  33441. * @param lodLevel defines which lod of the texture to render to
  33442. */
  33443. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  33444. /**
  33445. * Finalize the result of the output of the postprocesses.
  33446. * @param doNotPresent If true the result will not be displayed to the screen.
  33447. * @param targetTexture The target texture to render to.
  33448. * @param faceIndex The index of the face to bind the target texture to.
  33449. * @param postProcesses The array of post processes to render.
  33450. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  33451. * @hidden
  33452. */
  33453. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  33454. /**
  33455. * Disposes of the post process manager.
  33456. */
  33457. dispose(): void;
  33458. }
  33459. }
  33460. declare module BABYLON {
  33461. /**
  33462. * Post process which applies a refractin texture
  33463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  33464. */
  33465. class RefractionPostProcess extends PostProcess {
  33466. /** the base color of the refraction (used to taint the rendering) */
  33467. color: Color3;
  33468. /** simulated refraction depth */
  33469. depth: number;
  33470. /** the coefficient of the base color (0 to remove base color tainting) */
  33471. colorLevel: number;
  33472. private _refTexture;
  33473. private _ownRefractionTexture;
  33474. /**
  33475. * Gets or sets the refraction texture
  33476. * Please note that you are responsible for disposing the texture if you set it manually
  33477. */
  33478. refractionTexture: Texture;
  33479. /**
  33480. * Initializes the RefractionPostProcess
  33481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  33482. * @param name The name of the effect.
  33483. * @param refractionTextureUrl Url of the refraction texture to use
  33484. * @param color the base color of the refraction (used to taint the rendering)
  33485. * @param depth simulated refraction depth
  33486. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  33487. * @param camera The camera to apply the render pass to.
  33488. * @param options The required width/height ratio to downsize to before computing the render pass.
  33489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33490. * @param engine The engine which the post process will be applied. (default: current engine)
  33491. * @param reusable If the post process can be reused on the same frame. (default: false)
  33492. */
  33493. constructor(name: string, refractionTextureUrl: string,
  33494. /** the base color of the refraction (used to taint the rendering) */
  33495. color: Color3,
  33496. /** simulated refraction depth */
  33497. depth: number,
  33498. /** the coefficient of the base color (0 to remove base color tainting) */
  33499. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33500. /**
  33501. * Disposes of the post process
  33502. * @param camera Camera to dispose post process on
  33503. */
  33504. dispose(camera: Camera): void;
  33505. }
  33506. }
  33507. declare module BABYLON {
  33508. /**
  33509. * The SharpenPostProcess applies a sharpen kernel to every pixel
  33510. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  33511. */
  33512. class SharpenPostProcess extends PostProcess {
  33513. /**
  33514. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  33515. */
  33516. colorAmount: number;
  33517. /**
  33518. * How much sharpness should be applied (default: 0.3)
  33519. */
  33520. edgeAmount: number;
  33521. /**
  33522. * Creates a new instance ConvolutionPostProcess
  33523. * @param name The name of the effect.
  33524. * @param options The required width/height ratio to downsize to before computing the render pass.
  33525. * @param camera The camera to apply the render pass to.
  33526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33527. * @param engine The engine which the post process will be applied. (default: current engine)
  33528. * @param reusable If the post process can be reused on the same frame. (default: false)
  33529. * @param textureType Type of textures used when performing the post process. (default: 0)
  33530. * @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)
  33531. */
  33532. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  33533. }
  33534. }
  33535. declare module BABYLON {
  33536. /**
  33537. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  33538. */
  33539. class StereoscopicInterlacePostProcess extends PostProcess {
  33540. private _stepSize;
  33541. private _passedProcess;
  33542. /**
  33543. * Initializes a StereoscopicInterlacePostProcess
  33544. * @param name The name of the effect.
  33545. * @param rigCameras The rig cameras to be appled to the post process
  33546. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  33547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33548. * @param engine The engine which the post process will be applied. (default: current engine)
  33549. * @param reusable If the post process can be reused on the same frame. (default: false)
  33550. */
  33551. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33552. }
  33553. }
  33554. declare module BABYLON {
  33555. /** Defines operator used for tonemapping */
  33556. enum TonemappingOperator {
  33557. /** Hable */
  33558. Hable = 0,
  33559. /** Reinhard */
  33560. Reinhard = 1,
  33561. /** HejiDawson */
  33562. HejiDawson = 2,
  33563. /** Photographic */
  33564. Photographic = 3
  33565. }
  33566. /**
  33567. * Defines a post process to apply tone mapping
  33568. */
  33569. class TonemapPostProcess extends PostProcess {
  33570. private _operator;
  33571. /** Defines the required exposure adjustement */
  33572. exposureAdjustment: number;
  33573. /**
  33574. * Creates a new TonemapPostProcess
  33575. * @param name defines the name of the postprocess
  33576. * @param _operator defines the operator to use
  33577. * @param exposureAdjustment defines the required exposure adjustement
  33578. * @param camera defines the camera to use (can be null)
  33579. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  33580. * @param engine defines the hosting engine (can be ignore if camera is set)
  33581. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  33582. */
  33583. constructor(name: string, _operator: TonemappingOperator,
  33584. /** Defines the required exposure adjustement */
  33585. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  33586. }
  33587. }
  33588. declare module BABYLON {
  33589. /**
  33590. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  33591. */
  33592. class VolumetricLightScatteringPostProcess extends PostProcess {
  33593. private _volumetricLightScatteringPass;
  33594. private _volumetricLightScatteringRTT;
  33595. private _viewPort;
  33596. private _screenCoordinates;
  33597. private _cachedDefines;
  33598. /**
  33599. * If not undefined, the mesh position is computed from the attached node position
  33600. */
  33601. attachedNode: {
  33602. position: Vector3;
  33603. };
  33604. /**
  33605. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  33606. */
  33607. customMeshPosition: Vector3;
  33608. /**
  33609. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  33610. */
  33611. useCustomMeshPosition: boolean;
  33612. /**
  33613. * If the post-process should inverse the light scattering direction
  33614. */
  33615. invert: boolean;
  33616. /**
  33617. * The internal mesh used by the post-process
  33618. */
  33619. mesh: Mesh;
  33620. /**
  33621. * @hidden
  33622. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  33623. */
  33624. useDiffuseColor: boolean;
  33625. /**
  33626. * Array containing the excluded meshes not rendered in the internal pass
  33627. */
  33628. excludedMeshes: AbstractMesh[];
  33629. /**
  33630. * Controls the overall intensity of the post-process
  33631. */
  33632. exposure: number;
  33633. /**
  33634. * Dissipates each sample's contribution in range [0, 1]
  33635. */
  33636. decay: number;
  33637. /**
  33638. * Controls the overall intensity of each sample
  33639. */
  33640. weight: number;
  33641. /**
  33642. * Controls the density of each sample
  33643. */
  33644. density: number;
  33645. /**
  33646. * @constructor
  33647. * @param {string} name - The post-process name
  33648. * @param {any} ratio - The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  33649. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  33650. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  33651. * @param {number} samples - The post-process quality, default 100
  33652. * @param {number} samplingMode - The post-process filtering mode
  33653. * @param {BABYLON.Engine} engine - The babylon engine
  33654. * @param {boolean} reusable - If the post-process is reusable
  33655. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  33656. */
  33657. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  33658. /**
  33659. * Returns the string "VolumetricLightScatteringPostProcess"
  33660. * @returns "VolumetricLightScatteringPostProcess"
  33661. */
  33662. getClassName(): string;
  33663. private _isReady;
  33664. /**
  33665. * Sets the new light position for light scattering effect
  33666. * @param position The new custom light position
  33667. */
  33668. setCustomMeshPosition(position: Vector3): void;
  33669. /**
  33670. * Returns the light position for light scattering effect
  33671. * @return {BABYLON.Vector3} The custom light position
  33672. */
  33673. getCustomMeshPosition(): Vector3;
  33674. /**
  33675. * Disposes the internal assets and detaches the post-process from the camera
  33676. */
  33677. dispose(camera: Camera): void;
  33678. /**
  33679. * Returns the render target texture used by the post-process
  33680. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  33681. */
  33682. getPass(): RenderTargetTexture;
  33683. private _meshExcluded;
  33684. private _createPass;
  33685. private _updateMeshScreenCoordinates;
  33686. /**
  33687. * Creates a default mesh for the Volumeric Light Scattering post-process
  33688. * @param name The mesh name
  33689. * @param scene The scene where to create the mesh
  33690. * @return {BABYLON.Mesh} the default mesh
  33691. */
  33692. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  33693. }
  33694. }
  33695. declare module BABYLON {
  33696. /**
  33697. * VRDistortionCorrectionPostProcess used for mobile VR
  33698. */
  33699. class VRDistortionCorrectionPostProcess extends PostProcess {
  33700. private _isRightEye;
  33701. private _distortionFactors;
  33702. private _postProcessScaleFactor;
  33703. private _lensCenterOffset;
  33704. private _scaleIn;
  33705. private _scaleFactor;
  33706. private _lensCenter;
  33707. /**
  33708. * Initializes the VRDistortionCorrectionPostProcess
  33709. * @param name The name of the effect.
  33710. * @param camera The camera to apply the render pass to.
  33711. * @param isRightEye If this is for the right eye distortion
  33712. * @param vrMetrics All the required metrics for the VR camera
  33713. */
  33714. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  33715. }
  33716. }
  33717. declare module BABYLON {
  33718. interface Scene {
  33719. /** @hidden (Backing field) */
  33720. _boundingBoxRenderer: BoundingBoxRenderer;
  33721. /** @hidden (Backing field) */
  33722. _forceShowBoundingBoxes: boolean;
  33723. /**
  33724. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  33725. */
  33726. forceShowBoundingBoxes: boolean;
  33727. /**
  33728. * Gets the bounding box renderer associated with the scene
  33729. * @returns a BoundingBoxRenderer
  33730. */
  33731. getBoundingBoxRenderer(): BoundingBoxRenderer;
  33732. }
  33733. interface AbstractMesh {
  33734. /** @hidden (Backing field) */
  33735. _showBoundingBox: boolean;
  33736. /**
  33737. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  33738. */
  33739. showBoundingBox: boolean;
  33740. }
  33741. /**
  33742. * Component responsible of rendering the bounding box of the meshes in a scene.
  33743. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  33744. */
  33745. class BoundingBoxRenderer implements ISceneComponent {
  33746. /**
  33747. * The component name helpfull to identify the component in the list of scene components.
  33748. */
  33749. readonly name: string;
  33750. /**
  33751. * The scene the component belongs to.
  33752. */
  33753. scene: Scene;
  33754. /**
  33755. * Color of the bounding box lines placed in front of an object
  33756. */
  33757. frontColor: Color3;
  33758. /**
  33759. * Color of the bounding box lines placed behind an object
  33760. */
  33761. backColor: Color3;
  33762. /**
  33763. * Defines if the renderer should show the back lines or not
  33764. */
  33765. showBackLines: boolean;
  33766. /**
  33767. * @hidden
  33768. */
  33769. renderList: SmartArray<BoundingBox>;
  33770. private _colorShader;
  33771. private _vertexBuffers;
  33772. private _indexBuffer;
  33773. /**
  33774. * Instantiates a new bounding box renderer in a scene.
  33775. * @param scene the scene the renderer renders in
  33776. */
  33777. constructor(scene: Scene);
  33778. /**
  33779. * Registers the component in a given scene
  33780. */
  33781. register(): void;
  33782. private _evaluateSubMesh;
  33783. private _activeMesh;
  33784. private _prepareRessources;
  33785. private _createIndexBuffer;
  33786. /**
  33787. * Rebuilds the elements related to this component in case of
  33788. * context lost for instance.
  33789. */
  33790. rebuild(): void;
  33791. /**
  33792. * @hidden
  33793. */
  33794. reset(): void;
  33795. /**
  33796. * Render the bounding boxes of a specific rendering group
  33797. * @param renderingGroupId defines the rendering group to render
  33798. */
  33799. render(renderingGroupId: number): void;
  33800. /**
  33801. * In case of occlusion queries, we can render the occlusion bounding box through this method
  33802. * @param mesh Define the mesh to render the occlusion bounding box for
  33803. */
  33804. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  33805. /**
  33806. * Dispose and release the resources attached to this renderer.
  33807. */
  33808. dispose(): void;
  33809. }
  33810. }
  33811. declare module BABYLON {
  33812. /**
  33813. * This represents a depth renderer in Babylon.
  33814. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  33815. */
  33816. class DepthRenderer {
  33817. private _scene;
  33818. private _depthMap;
  33819. private _effect;
  33820. private _cachedDefines;
  33821. private _camera;
  33822. /**
  33823. * Specifiess that the depth renderer will only be used within
  33824. * the camera it is created for.
  33825. * This can help forcing its rendering during the camera processing.
  33826. */
  33827. useOnlyInActiveCamera: boolean;
  33828. /**
  33829. * Instantiates a depth renderer
  33830. * @param scene The scene the renderer belongs to
  33831. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  33832. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  33833. */
  33834. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  33835. /**
  33836. * Creates the depth rendering effect and checks if the effect is ready.
  33837. * @param subMesh The submesh to be used to render the depth map of
  33838. * @param useInstances If multiple world instances should be used
  33839. * @returns if the depth renderer is ready to render the depth map
  33840. */
  33841. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  33842. /**
  33843. * Gets the texture which the depth map will be written to.
  33844. * @returns The depth map texture
  33845. */
  33846. getDepthMap(): RenderTargetTexture;
  33847. /**
  33848. * Disposes of the depth renderer.
  33849. */
  33850. dispose(): void;
  33851. }
  33852. }
  33853. declare module BABYLON {
  33854. interface Scene {
  33855. /** @hidden (Backing field) */
  33856. _depthRenderer: {
  33857. [id: string]: DepthRenderer;
  33858. };
  33859. /**
  33860. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  33861. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  33862. * @returns the created depth renderer
  33863. */
  33864. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  33865. /**
  33866. * Disables a depth renderer for a given camera
  33867. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  33868. */
  33869. disableDepthRenderer(camera?: Nullable<Camera>): void;
  33870. }
  33871. /**
  33872. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  33873. * in several rendering techniques.
  33874. */
  33875. class DepthRendererSceneComponent implements ISceneComponent {
  33876. /**
  33877. * The component name helpfull to identify the component in the list of scene components.
  33878. */
  33879. readonly name: string;
  33880. /**
  33881. * The scene the component belongs to.
  33882. */
  33883. scene: Scene;
  33884. /**
  33885. * Creates a new instance of the component for the given scene
  33886. * @param scene Defines the scene to register the component in
  33887. */
  33888. constructor(scene: Scene);
  33889. /**
  33890. * Registers the component in a given scene
  33891. */
  33892. register(): void;
  33893. /**
  33894. * Rebuilds the elements related to this component in case of
  33895. * context lost for instance.
  33896. */
  33897. rebuild(): void;
  33898. /**
  33899. * Disposes the component and the associated ressources
  33900. */
  33901. dispose(): void;
  33902. private _gatherRenderTargets;
  33903. private _gatherActiveCameraRenderTargets;
  33904. }
  33905. }
  33906. declare module BABYLON {
  33907. interface AbstractMesh {
  33908. /**
  33909. * Disables the mesh edge rendering mode
  33910. * @returns the currentAbstractMesh
  33911. */
  33912. disableEdgesRendering(): AbstractMesh;
  33913. /**
  33914. * Enables the edge rendering mode on the mesh.
  33915. * This mode makes the mesh edges visible
  33916. * @param epsilon defines the maximal distance between two angles to detect a face
  33917. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33918. * @returns the currentAbstractMesh
  33919. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33920. */
  33921. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33922. /**
  33923. * Gets the edgesRenderer associated with the mesh
  33924. */
  33925. edgesRenderer: Nullable<EdgesRenderer>;
  33926. }
  33927. interface LinesMesh {
  33928. /**
  33929. * Enables the edge rendering mode on the mesh.
  33930. * This mode makes the mesh edges visible
  33931. * @param epsilon defines the maximal distance between two angles to detect a face
  33932. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33933. * @returns the currentAbstractMesh
  33934. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33935. */
  33936. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33937. }
  33938. /**
  33939. * Defines the minimum contract an Edges renderer should follow.
  33940. */
  33941. interface IEdgesRenderer extends IDisposable {
  33942. /**
  33943. * Gets or sets a boolean indicating if the edgesRenderer is active
  33944. */
  33945. isEnabled: boolean;
  33946. /**
  33947. * Renders the edges of the attached mesh,
  33948. */
  33949. render(): void;
  33950. /**
  33951. * Checks wether or not the edges renderer is ready to render.
  33952. * @return true if ready, otherwise false.
  33953. */
  33954. isReady(): boolean;
  33955. }
  33956. /**
  33957. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  33958. */
  33959. class EdgesRenderer implements IEdgesRenderer {
  33960. /**
  33961. * Define the size of the edges with an orthographic camera
  33962. */
  33963. edgesWidthScalerForOrthographic: number;
  33964. /**
  33965. * Define the size of the edges with a perspective camera
  33966. */
  33967. edgesWidthScalerForPerspective: number;
  33968. protected _source: AbstractMesh;
  33969. protected _linesPositions: number[];
  33970. protected _linesNormals: number[];
  33971. protected _linesIndices: number[];
  33972. protected _epsilon: number;
  33973. protected _indicesCount: number;
  33974. protected _lineShader: ShaderMaterial;
  33975. protected _ib: WebGLBuffer;
  33976. protected _buffers: {
  33977. [key: string]: Nullable<VertexBuffer>;
  33978. };
  33979. protected _checkVerticesInsteadOfIndices: boolean;
  33980. private _meshRebuildObserver;
  33981. private _meshDisposeObserver;
  33982. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  33983. isEnabled: boolean;
  33984. /**
  33985. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  33986. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  33987. * @param source Mesh used to create edges
  33988. * @param epsilon sum of angles in adjacency to check for edge
  33989. * @param checkVerticesInsteadOfIndices
  33990. * @param generateEdgesLines - should generate Lines or only prepare resources.
  33991. */
  33992. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  33993. protected _prepareRessources(): void;
  33994. /** @hidden */
  33995. _rebuild(): void;
  33996. /**
  33997. * Releases the required resources for the edges renderer
  33998. */
  33999. dispose(): void;
  34000. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34001. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34002. /**
  34003. * Checks if the pair of p0 and p1 is en edge
  34004. * @param faceIndex
  34005. * @param edge
  34006. * @param faceNormals
  34007. * @param p0
  34008. * @param p1
  34009. * @private
  34010. */
  34011. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34012. /**
  34013. * Generates lines edges from adjacencjes
  34014. * @private
  34015. */
  34016. _generateEdgesLines(): void;
  34017. /**
  34018. * Checks wether or not the edges renderer is ready to render.
  34019. * @return true if ready, otherwise false.
  34020. */
  34021. isReady(): boolean;
  34022. /**
  34023. * Renders the edges of the attached mesh,
  34024. */
  34025. render(): void;
  34026. }
  34027. }
  34028. declare module BABYLON {
  34029. /**
  34030. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34031. */
  34032. class GeometryBufferRenderer {
  34033. private _scene;
  34034. private _multiRenderTarget;
  34035. private _ratio;
  34036. private _enablePosition;
  34037. protected _effect: Effect;
  34038. protected _cachedDefines: string;
  34039. /**
  34040. * Set the render list (meshes to be rendered) used in the G buffer.
  34041. */
  34042. renderList: Mesh[];
  34043. /**
  34044. * Gets wether or not G buffer are supported by the running hardware.
  34045. * This requires draw buffer supports
  34046. */
  34047. readonly isSupported: boolean;
  34048. /**
  34049. * Gets wether or not position are enabled for the G buffer.
  34050. */
  34051. /**
  34052. * Sets wether or not position are enabled for the G buffer.
  34053. */
  34054. enablePosition: boolean;
  34055. /**
  34056. * Gets the scene associated with the buffer.
  34057. */
  34058. readonly scene: Scene;
  34059. /**
  34060. * Gets the ratio used by the buffer during its creation.
  34061. * How big is the buffer related to the main canvas.
  34062. */
  34063. readonly ratio: number;
  34064. /**
  34065. * Creates a new G Buffer for the scene
  34066. * @param scene The scene the buffer belongs to
  34067. * @param ratio How big is the buffer related to the main canvas.
  34068. */
  34069. constructor(scene: Scene, ratio?: number);
  34070. /**
  34071. * Checks wether everything is ready to render a submesh to the G buffer.
  34072. * @param subMesh the submesh to check readiness for
  34073. * @param useInstances is the mesh drawn using instance or not
  34074. * @returns true if ready otherwise false
  34075. */
  34076. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34077. /**
  34078. * Gets the current underlying G Buffer.
  34079. * @returns the buffer
  34080. */
  34081. getGBuffer(): MultiRenderTarget;
  34082. /**
  34083. * Gets the number of samples used to render the buffer (anti aliasing).
  34084. */
  34085. /**
  34086. * Sets the number of samples used to render the buffer (anti aliasing).
  34087. */
  34088. samples: number;
  34089. /**
  34090. * Disposes the renderer and frees up associated resources.
  34091. */
  34092. dispose(): void;
  34093. protected _createRenderTargets(): void;
  34094. }
  34095. }
  34096. declare module BABYLON {
  34097. interface Scene {
  34098. /** @hidden (Backing field) */
  34099. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34100. /**
  34101. * Gets or Sets the current geometry buffer associated to the scene.
  34102. */
  34103. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34104. /**
  34105. * Enables a GeometryBufferRender and associates it with the scene
  34106. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  34107. * @returns the GeometryBufferRenderer
  34108. */
  34109. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  34110. /**
  34111. * Disables the GeometryBufferRender associated with the scene
  34112. */
  34113. disableGeometryBufferRenderer(): void;
  34114. }
  34115. /**
  34116. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  34117. * in several rendering techniques.
  34118. */
  34119. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  34120. /**
  34121. * The component name helpful to identify the component in the list of scene components.
  34122. */
  34123. readonly name: string;
  34124. /**
  34125. * The scene the component belongs to.
  34126. */
  34127. scene: Scene;
  34128. /**
  34129. * Creates a new instance of the component for the given scene
  34130. * @param scene Defines the scene to register the component in
  34131. */
  34132. constructor(scene: Scene);
  34133. /**
  34134. * Registers the component in a given scene
  34135. */
  34136. register(): void;
  34137. /**
  34138. * Rebuilds the elements related to this component in case of
  34139. * context lost for instance.
  34140. */
  34141. rebuild(): void;
  34142. /**
  34143. * Disposes the component and the associated ressources
  34144. */
  34145. dispose(): void;
  34146. private _gatherRenderTargets;
  34147. }
  34148. }
  34149. declare module BABYLON {
  34150. /**
  34151. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  34152. */
  34153. class LineEdgesRenderer extends EdgesRenderer {
  34154. /**
  34155. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  34156. * @param source LineMesh used to generate edges
  34157. * @param epsilon not important (specified angle for edge detection)
  34158. * @param checkVerticesInsteadOfIndices not important for LineMesh
  34159. */
  34160. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  34161. /**
  34162. * Always create the edge since its a line so only important things are p0 and p1
  34163. * @param faceIndex not important for LineMesh
  34164. * @param edge not important for LineMesh
  34165. * @param faceNormals not important for LineMesh
  34166. * @param p0 beginnig of line
  34167. * @param p1 end of line
  34168. */
  34169. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34170. /**
  34171. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  34172. */
  34173. _generateEdgesLines(): void;
  34174. }
  34175. }
  34176. declare module BABYLON {
  34177. interface Scene {
  34178. /** @hidden */
  34179. _outlineRenderer: OutlineRenderer;
  34180. /**
  34181. * Gets the outline renderer associated with the scene
  34182. * @returns a OutlineRenderer
  34183. */
  34184. getOutlineRenderer(): OutlineRenderer;
  34185. }
  34186. interface AbstractMesh {
  34187. /** @hidden (Backing field) */
  34188. _renderOutline: boolean;
  34189. /**
  34190. * Gets or sets a boolean indicating if the outline must be rendered as well
  34191. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  34192. */
  34193. renderOutline: boolean;
  34194. /** @hidden (Backing field) */
  34195. _renderOverlay: boolean;
  34196. /**
  34197. * Gets or sets a boolean indicating if the overlay must be rendered as well
  34198. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  34199. */
  34200. renderOverlay: boolean;
  34201. }
  34202. /**
  34203. * This class is responsible to draw bothe outline/overlay of meshes.
  34204. * It should not be used directly but through the available method on mesh.
  34205. */
  34206. class OutlineRenderer implements ISceneComponent {
  34207. /**
  34208. * The name of the component. Each component must have a unique name.
  34209. */
  34210. name: string;
  34211. /**
  34212. * The scene the component belongs to.
  34213. */
  34214. scene: Scene;
  34215. /**
  34216. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  34217. */
  34218. zOffset: number;
  34219. private _engine;
  34220. private _effect;
  34221. private _cachedDefines;
  34222. private _savedDepthWrite;
  34223. /**
  34224. * Instantiates a new outline renderer. (There could be only one per scene).
  34225. * @param scene Defines the scene it belongs to
  34226. */
  34227. constructor(scene: Scene);
  34228. /**
  34229. * Register the component to one instance of a scene.
  34230. */
  34231. register(): void;
  34232. /**
  34233. * Rebuilds the elements related to this component in case of
  34234. * context lost for instance.
  34235. */
  34236. rebuild(): void;
  34237. /**
  34238. * Disposes the component and the associated ressources.
  34239. */
  34240. dispose(): void;
  34241. /**
  34242. * Renders the outline in the canvas.
  34243. * @param subMesh Defines the sumesh to render
  34244. * @param batch Defines the batch of meshes in case of instances
  34245. * @param useOverlay Defines if the rendering is for the overlay or the outline
  34246. */
  34247. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  34248. /**
  34249. * Returns whether or not the outline renderer is ready for a given submesh.
  34250. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  34251. * @param subMesh Defines the submesh to check readyness for
  34252. * @param useInstances Defines wheter wee are trying to render instances or not
  34253. * @returns true if ready otherwise false
  34254. */
  34255. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34256. private _beforeRenderingMesh;
  34257. private _afterRenderingMesh;
  34258. }
  34259. }
  34260. declare module BABYLON {
  34261. /**
  34262. * This represents the object necessary to create a rendering group.
  34263. * This is exclusively used and created by the rendering manager.
  34264. * To modify the behavior, you use the available helpers in your scene or meshes.
  34265. * @hidden
  34266. */
  34267. class RenderingGroup {
  34268. index: number;
  34269. private _scene;
  34270. private _opaqueSubMeshes;
  34271. private _transparentSubMeshes;
  34272. private _alphaTestSubMeshes;
  34273. private _depthOnlySubMeshes;
  34274. private _particleSystems;
  34275. private _spriteManagers;
  34276. private _opaqueSortCompareFn;
  34277. private _alphaTestSortCompareFn;
  34278. private _transparentSortCompareFn;
  34279. private _renderOpaque;
  34280. private _renderAlphaTest;
  34281. private _renderTransparent;
  34282. private _edgesRenderers;
  34283. onBeforeTransparentRendering: () => void;
  34284. /**
  34285. * Set the opaque sort comparison function.
  34286. * If null the sub meshes will be render in the order they were created
  34287. */
  34288. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34289. /**
  34290. * Set the alpha test sort comparison function.
  34291. * If null the sub meshes will be render in the order they were created
  34292. */
  34293. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34294. /**
  34295. * Set the transparent sort comparison function.
  34296. * If null the sub meshes will be render in the order they were created
  34297. */
  34298. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34299. /**
  34300. * Creates a new rendering group.
  34301. * @param index The rendering group index
  34302. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  34303. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  34304. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  34305. */
  34306. 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>);
  34307. /**
  34308. * Render all the sub meshes contained in the group.
  34309. * @param customRenderFunction Used to override the default render behaviour of the group.
  34310. * @returns true if rendered some submeshes.
  34311. */
  34312. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  34313. /**
  34314. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  34315. * @param subMeshes The submeshes to render
  34316. */
  34317. private renderOpaqueSorted;
  34318. /**
  34319. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  34320. * @param subMeshes The submeshes to render
  34321. */
  34322. private renderAlphaTestSorted;
  34323. /**
  34324. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  34325. * @param subMeshes The submeshes to render
  34326. */
  34327. private renderTransparentSorted;
  34328. /**
  34329. * Renders the submeshes in a specified order.
  34330. * @param subMeshes The submeshes to sort before render
  34331. * @param sortCompareFn The comparison function use to sort
  34332. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  34333. * @param transparent Specifies to activate blending if true
  34334. */
  34335. private static renderSorted;
  34336. /**
  34337. * Renders the submeshes in the order they were dispatched (no sort applied).
  34338. * @param subMeshes The submeshes to render
  34339. */
  34340. private static renderUnsorted;
  34341. /**
  34342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34343. * are rendered back to front if in the same alpha index.
  34344. *
  34345. * @param a The first submesh
  34346. * @param b The second submesh
  34347. * @returns The result of the comparison
  34348. */
  34349. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  34350. /**
  34351. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34352. * are rendered back to front.
  34353. *
  34354. * @param a The first submesh
  34355. * @param b The second submesh
  34356. * @returns The result of the comparison
  34357. */
  34358. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  34359. /**
  34360. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34361. * are rendered front to back (prevent overdraw).
  34362. *
  34363. * @param a The first submesh
  34364. * @param b The second submesh
  34365. * @returns The result of the comparison
  34366. */
  34367. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  34368. /**
  34369. * Resets the different lists of submeshes to prepare a new frame.
  34370. */
  34371. prepare(): void;
  34372. dispose(): void;
  34373. /**
  34374. * Inserts the submesh in its correct queue depending on its material.
  34375. * @param subMesh The submesh to dispatch
  34376. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  34377. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  34378. */
  34379. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  34380. dispatchSprites(spriteManager: ISpriteManager): void;
  34381. dispatchParticles(particleSystem: IParticleSystem): void;
  34382. private _renderParticles;
  34383. private _renderSprites;
  34384. }
  34385. }
  34386. declare module BABYLON {
  34387. /**
  34388. * Interface describing the different options available in the rendering manager
  34389. * regarding Auto Clear between groups.
  34390. */
  34391. interface IRenderingManagerAutoClearSetup {
  34392. /**
  34393. * Defines whether or not autoclear is enable.
  34394. */
  34395. autoClear: boolean;
  34396. /**
  34397. * Defines whether or not to autoclear the depth buffer.
  34398. */
  34399. depth: boolean;
  34400. /**
  34401. * Defines whether or not to autoclear the stencil buffer.
  34402. */
  34403. stencil: boolean;
  34404. }
  34405. /**
  34406. * This is the manager responsible of all the rendering for meshes sprites and particles.
  34407. * It is enable to manage the different groups as well as the different necessary sort functions.
  34408. * This should not be used directly aside of the few static configurations
  34409. */
  34410. class RenderingManager {
  34411. /**
  34412. * The max id used for rendering groups (not included)
  34413. */
  34414. static MAX_RENDERINGGROUPS: number;
  34415. /**
  34416. * The min id used for rendering groups (included)
  34417. */
  34418. static MIN_RENDERINGGROUPS: number;
  34419. /**
  34420. * Used to globally prevent autoclearing scenes.
  34421. */
  34422. static AUTOCLEAR: boolean;
  34423. /**
  34424. * @hidden
  34425. */
  34426. _useSceneAutoClearSetup: boolean;
  34427. private _scene;
  34428. private _renderingGroups;
  34429. private _depthStencilBufferAlreadyCleaned;
  34430. private _autoClearDepthStencil;
  34431. private _customOpaqueSortCompareFn;
  34432. private _customAlphaTestSortCompareFn;
  34433. private _customTransparentSortCompareFn;
  34434. private _renderingGroupInfo;
  34435. /**
  34436. * Instantiates a new rendering group for a particular scene
  34437. * @param scene Defines the scene the groups belongs to
  34438. */
  34439. constructor(scene: Scene);
  34440. private _clearDepthStencilBuffer;
  34441. /**
  34442. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  34443. * @hidden
  34444. */
  34445. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  34446. /**
  34447. * Resets the different information of the group to prepare a new frame
  34448. * @hidden
  34449. */
  34450. reset(): void;
  34451. /**
  34452. * Dispose and release the group and its associated resources.
  34453. * @hidden
  34454. */
  34455. dispose(): void;
  34456. /**
  34457. * Clear the info related to rendering groups preventing retention points during dispose.
  34458. */
  34459. freeRenderingGroups(): void;
  34460. private _prepareRenderingGroup;
  34461. /**
  34462. * Add a sprite manager to the rendering manager in order to render it this frame.
  34463. * @param spriteManager Define the sprite manager to render
  34464. */
  34465. dispatchSprites(spriteManager: ISpriteManager): void;
  34466. /**
  34467. * Add a particle system to the rendering manager in order to render it this frame.
  34468. * @param particleSystem Define the particle system to render
  34469. */
  34470. dispatchParticles(particleSystem: IParticleSystem): void;
  34471. /**
  34472. * Add a submesh to the manager in order to render it this frame
  34473. * @param subMesh The submesh to dispatch
  34474. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  34475. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  34476. */
  34477. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  34478. /**
  34479. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34480. * This allowed control for front to back rendering or reversly depending of the special needs.
  34481. *
  34482. * @param renderingGroupId The rendering group id corresponding to its index
  34483. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34484. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34485. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34486. */
  34487. 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;
  34488. /**
  34489. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34490. *
  34491. * @param renderingGroupId The rendering group id corresponding to its index
  34492. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34493. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34494. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34495. */
  34496. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34497. /**
  34498. * Gets the current auto clear configuration for one rendering group of the rendering
  34499. * manager.
  34500. * @param index the rendering group index to get the information for
  34501. * @returns The auto clear setup for the requested rendering group
  34502. */
  34503. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34504. }
  34505. }
  34506. declare module BABYLON {
  34507. /**
  34508. * Renders a layer on top of an existing scene
  34509. */
  34510. class UtilityLayerRenderer implements IDisposable {
  34511. /** the original scene that will be rendered on top of */
  34512. originalScene: Scene;
  34513. private _pointerCaptures;
  34514. private _lastPointerEvents;
  34515. private static _DefaultUtilityLayer;
  34516. private static _DefaultKeepDepthUtilityLayer;
  34517. /**
  34518. * 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)
  34519. */
  34520. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  34521. /**
  34522. * 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)
  34523. */
  34524. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  34525. /**
  34526. * The scene that is rendered on top of the original scene
  34527. */
  34528. utilityLayerScene: Scene;
  34529. /**
  34530. * If the utility layer should automatically be rendered on top of existing scene
  34531. */
  34532. shouldRender: boolean;
  34533. /**
  34534. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  34535. */
  34536. onlyCheckPointerDownEvents: boolean;
  34537. /**
  34538. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  34539. */
  34540. processAllEvents: boolean;
  34541. /**
  34542. * Observable raised when the pointer move from the utility layer scene to the main scene
  34543. */
  34544. onPointerOutObservable: Observable<number>;
  34545. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  34546. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  34547. private _afterRenderObserver;
  34548. private _sceneDisposeObserver;
  34549. private _originalPointerObserver;
  34550. /**
  34551. * Instantiates a UtilityLayerRenderer
  34552. * @param originalScene the original scene that will be rendered on top of
  34553. */
  34554. constructor(
  34555. /** the original scene that will be rendered on top of */
  34556. originalScene: Scene);
  34557. private _notifyObservers;
  34558. /**
  34559. * Renders the utility layers scene on top of the original scene
  34560. */
  34561. render(): void;
  34562. /**
  34563. * Disposes of the renderer
  34564. */
  34565. dispose(): void;
  34566. private _updateCamera;
  34567. }
  34568. }
  34569. declare module BABYLON {
  34570. class Sprite {
  34571. name: string;
  34572. position: Vector3;
  34573. color: Color4;
  34574. width: number;
  34575. height: number;
  34576. angle: number;
  34577. cellIndex: number;
  34578. invertU: number;
  34579. invertV: number;
  34580. disposeWhenFinishedAnimating: boolean;
  34581. animations: Animation[];
  34582. isPickable: boolean;
  34583. actionManager: ActionManager;
  34584. private _animationStarted;
  34585. private _loopAnimation;
  34586. private _fromIndex;
  34587. private _toIndex;
  34588. private _delay;
  34589. private _direction;
  34590. private _manager;
  34591. private _time;
  34592. private _onAnimationEnd;
  34593. /**
  34594. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  34595. */
  34596. isVisible: boolean;
  34597. size: number;
  34598. constructor(name: string, manager: ISpriteManager);
  34599. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  34600. stopAnimation(): void;
  34601. /** @hidden */
  34602. _animate(deltaTime: number): void;
  34603. dispose(): void;
  34604. }
  34605. }
  34606. declare module BABYLON {
  34607. /**
  34608. * Defines the minimum interface to fullfil in order to be a sprite manager.
  34609. */
  34610. interface ISpriteManager extends IDisposable {
  34611. /**
  34612. * Restricts the camera to viewing objects with the same layerMask.
  34613. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  34614. */
  34615. layerMask: number;
  34616. /**
  34617. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  34618. */
  34619. isPickable: boolean;
  34620. /**
  34621. * Specifies the rendering group id for this mesh (0 by default)
  34622. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  34623. */
  34624. renderingGroupId: number;
  34625. /**
  34626. * Defines the list of sprites managed by the manager.
  34627. */
  34628. sprites: Array<Sprite>;
  34629. /**
  34630. * Tests the intersection of a sprite with a specific ray.
  34631. * @param ray The ray we are sending to test the collision
  34632. * @param camera The camera space we are sending rays in
  34633. * @param predicate A predicate allowing excluding sprites from the list of object to test
  34634. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  34635. * @returns picking info or null.
  34636. */
  34637. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  34638. /**
  34639. * Renders the list of sprites on screen.
  34640. */
  34641. render(): void;
  34642. }
  34643. class SpriteManager implements ISpriteManager {
  34644. name: string;
  34645. sprites: Sprite[];
  34646. renderingGroupId: number;
  34647. layerMask: number;
  34648. fogEnabled: boolean;
  34649. isPickable: boolean;
  34650. cellWidth: number;
  34651. cellHeight: number;
  34652. /**
  34653. * An event triggered when the manager is disposed.
  34654. */
  34655. onDisposeObservable: Observable<SpriteManager>;
  34656. private _onDisposeObserver;
  34657. onDispose: () => void;
  34658. private _capacity;
  34659. private _spriteTexture;
  34660. private _epsilon;
  34661. private _scene;
  34662. private _vertexData;
  34663. private _buffer;
  34664. private _vertexBuffers;
  34665. private _indexBuffer;
  34666. private _effectBase;
  34667. private _effectFog;
  34668. texture: Texture;
  34669. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  34670. private _appendSpriteVertex;
  34671. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  34672. render(): void;
  34673. dispose(): void;
  34674. }
  34675. }
  34676. declare module BABYLON {
  34677. interface Scene {
  34678. /** @hidden */
  34679. _pointerOverSprite: Nullable<Sprite>;
  34680. /** @hidden */
  34681. _pickedDownSprite: Nullable<Sprite>;
  34682. /** @hidden */
  34683. _tempSpritePickingRay: Nullable<Ray>;
  34684. /**
  34685. * All of the sprite managers added to this scene
  34686. * @see http://doc.babylonjs.com/babylon101/sprites
  34687. */
  34688. spriteManagers: Array<ISpriteManager>;
  34689. /**
  34690. * An event triggered when sprites rendering is about to start
  34691. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  34692. */
  34693. onBeforeSpritesRenderingObservable: Observable<Scene>;
  34694. /**
  34695. * An event triggered when sprites rendering is done
  34696. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  34697. */
  34698. onAfterSpritesRenderingObservable: Observable<Scene>;
  34699. /** @hidden */
  34700. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  34701. /** Launch a ray to try to pick a sprite in the scene
  34702. * @param x position on screen
  34703. * @param y position on screen
  34704. * @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
  34705. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34706. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34707. * @returns a PickingInfo
  34708. */
  34709. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  34710. /** Use the given ray to pick a sprite in the scene
  34711. * @param ray The ray (in world space) to use to pick meshes
  34712. * @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
  34713. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34714. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  34715. * @returns a PickingInfo
  34716. */
  34717. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  34718. /**
  34719. * Force the sprite under the pointer
  34720. * @param sprite defines the sprite to use
  34721. */
  34722. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  34723. /**
  34724. * Gets the sprite under the pointer
  34725. * @returns a Sprite or null if no sprite is under the pointer
  34726. */
  34727. getPointerOverSprite(): Nullable<Sprite>;
  34728. }
  34729. /**
  34730. * Defines the sprite scene component responsible to manage sprites
  34731. * in a given scene.
  34732. */
  34733. class SpriteSceneComponent implements ISceneComponent {
  34734. /**
  34735. * The component name helpfull to identify the component in the list of scene components.
  34736. */
  34737. readonly name: string;
  34738. /**
  34739. * The scene the component belongs to.
  34740. */
  34741. scene: Scene;
  34742. /** @hidden */
  34743. private _spritePredicate;
  34744. /**
  34745. * Creates a new instance of the component for the given scene
  34746. * @param scene Defines the scene to register the component in
  34747. */
  34748. constructor(scene: Scene);
  34749. /**
  34750. * Registers the component in a given scene
  34751. */
  34752. register(): void;
  34753. /**
  34754. * Rebuilds the elements related to this component in case of
  34755. * context lost for instance.
  34756. */
  34757. rebuild(): void;
  34758. /**
  34759. * Disposes the component and the associated ressources.
  34760. */
  34761. dispose(): void;
  34762. private _pickSpriteButKeepRay;
  34763. private _pointerMove;
  34764. private _pointerDown;
  34765. private _pointerUp;
  34766. }
  34767. }
  34768. declare module BABYLON {
  34769. /**
  34770. * @hidden
  34771. **/
  34772. class _AlphaState {
  34773. private _isAlphaBlendDirty;
  34774. private _isBlendFunctionParametersDirty;
  34775. private _isBlendEquationParametersDirty;
  34776. private _isBlendConstantsDirty;
  34777. private _alphaBlend;
  34778. private _blendFunctionParameters;
  34779. private _blendEquationParameters;
  34780. private _blendConstants;
  34781. /**
  34782. * Initializes the state.
  34783. */
  34784. constructor();
  34785. readonly isDirty: boolean;
  34786. alphaBlend: boolean;
  34787. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34788. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34789. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34790. reset(): void;
  34791. apply(gl: WebGLRenderingContext): void;
  34792. }
  34793. }
  34794. declare module BABYLON {
  34795. /**
  34796. * @hidden
  34797. **/
  34798. class _DepthCullingState {
  34799. private _isDepthTestDirty;
  34800. private _isDepthMaskDirty;
  34801. private _isDepthFuncDirty;
  34802. private _isCullFaceDirty;
  34803. private _isCullDirty;
  34804. private _isZOffsetDirty;
  34805. private _isFrontFaceDirty;
  34806. private _depthTest;
  34807. private _depthMask;
  34808. private _depthFunc;
  34809. private _cull;
  34810. private _cullFace;
  34811. private _zOffset;
  34812. private _frontFace;
  34813. /**
  34814. * Initializes the state.
  34815. */
  34816. constructor();
  34817. readonly isDirty: boolean;
  34818. zOffset: number;
  34819. cullFace: Nullable<number>;
  34820. cull: Nullable<boolean>;
  34821. depthFunc: Nullable<number>;
  34822. depthMask: boolean;
  34823. depthTest: boolean;
  34824. frontFace: Nullable<number>;
  34825. reset(): void;
  34826. apply(gl: WebGLRenderingContext): void;
  34827. }
  34828. }
  34829. declare module BABYLON {
  34830. /**
  34831. * @hidden
  34832. **/
  34833. class _StencilState {
  34834. private _isStencilTestDirty;
  34835. private _isStencilMaskDirty;
  34836. private _isStencilFuncDirty;
  34837. private _isStencilOpDirty;
  34838. private _stencilTest;
  34839. private _stencilMask;
  34840. private _stencilFunc;
  34841. private _stencilFuncRef;
  34842. private _stencilFuncMask;
  34843. private _stencilOpStencilFail;
  34844. private _stencilOpDepthFail;
  34845. private _stencilOpStencilDepthPass;
  34846. readonly isDirty: boolean;
  34847. stencilFunc: number;
  34848. stencilFuncRef: number;
  34849. stencilFuncMask: number;
  34850. stencilOpStencilFail: number;
  34851. stencilOpDepthFail: number;
  34852. stencilOpStencilDepthPass: number;
  34853. stencilMask: number;
  34854. stencilTest: boolean;
  34855. constructor();
  34856. reset(): void;
  34857. apply(gl: WebGLRenderingContext): void;
  34858. }
  34859. }
  34860. declare module BABYLON {
  34861. /**
  34862. * Class used to evalaute queries containing `and` and `or` operators
  34863. */
  34864. class AndOrNotEvaluator {
  34865. /**
  34866. * Evaluate a query
  34867. * @param query defines the query to evaluate
  34868. * @param evaluateCallback defines the callback used to filter result
  34869. * @returns true if the query matches
  34870. */
  34871. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  34872. private static _HandleParenthesisContent;
  34873. private static _SimplifyNegation;
  34874. }
  34875. }
  34876. declare module BABYLON {
  34877. /**
  34878. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  34879. */
  34880. enum AssetTaskState {
  34881. /**
  34882. * Initialization
  34883. */
  34884. INIT = 0,
  34885. /**
  34886. * Running
  34887. */
  34888. RUNNING = 1,
  34889. /**
  34890. * Done
  34891. */
  34892. DONE = 2,
  34893. /**
  34894. * Error
  34895. */
  34896. ERROR = 3
  34897. }
  34898. /**
  34899. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  34900. */
  34901. abstract class AbstractAssetTask {
  34902. /**
  34903. * Task name
  34904. */ name: string;
  34905. /**
  34906. * Callback called when the task is successful
  34907. */
  34908. onSuccess: (task: any) => void;
  34909. /**
  34910. * Callback called when the task is not successful
  34911. */
  34912. onError: (task: any, message?: string, exception?: any) => void;
  34913. /**
  34914. * Creates a new {BABYLON.AssetsManager}
  34915. * @param name defines the name of the task
  34916. */
  34917. constructor(
  34918. /**
  34919. * Task name
  34920. */ name: string);
  34921. private _isCompleted;
  34922. private _taskState;
  34923. private _errorObject;
  34924. /**
  34925. * Get if the task is completed
  34926. */
  34927. readonly isCompleted: boolean;
  34928. /**
  34929. * Gets the current state of the task
  34930. */
  34931. readonly taskState: AssetTaskState;
  34932. /**
  34933. * Gets the current error object (if task is in error)
  34934. */
  34935. readonly errorObject: {
  34936. message?: string;
  34937. exception?: any;
  34938. };
  34939. /**
  34940. * Internal only
  34941. * @hidden
  34942. */
  34943. _setErrorObject(message?: string, exception?: any): void;
  34944. /**
  34945. * Execute the current task
  34946. * @param scene defines the scene where you want your assets to be loaded
  34947. * @param onSuccess is a callback called when the task is successfully executed
  34948. * @param onError is a callback called if an error occurs
  34949. */
  34950. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  34951. /**
  34952. * Execute the current task
  34953. * @param scene defines the scene where you want your assets to be loaded
  34954. * @param onSuccess is a callback called when the task is successfully executed
  34955. * @param onError is a callback called if an error occurs
  34956. */
  34957. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  34958. /**
  34959. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  34960. * This can be used with failed tasks that have the reason for failure fixed.
  34961. */
  34962. reset(): void;
  34963. private onErrorCallback;
  34964. private onDoneCallback;
  34965. }
  34966. /**
  34967. * Define the interface used by progress events raised during assets loading
  34968. */
  34969. interface IAssetsProgressEvent {
  34970. /**
  34971. * Defines the number of remaining tasks to process
  34972. */
  34973. remainingCount: number;
  34974. /**
  34975. * Defines the total number of tasks
  34976. */
  34977. totalCount: number;
  34978. /**
  34979. * Defines the task that was just processed
  34980. */
  34981. task: AbstractAssetTask;
  34982. }
  34983. /**
  34984. * Class used to share progress information about assets loading
  34985. */
  34986. class AssetsProgressEvent implements IAssetsProgressEvent {
  34987. /**
  34988. * Defines the number of remaining tasks to process
  34989. */
  34990. remainingCount: number;
  34991. /**
  34992. * Defines the total number of tasks
  34993. */
  34994. totalCount: number;
  34995. /**
  34996. * Defines the task that was just processed
  34997. */
  34998. task: AbstractAssetTask;
  34999. /**
  35000. * Creates a {BABYLON.AssetsProgressEvent}
  35001. * @param remainingCount defines the number of remaining tasks to process
  35002. * @param totalCount defines the total number of tasks
  35003. * @param task defines the task that was just processed
  35004. */
  35005. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  35006. }
  35007. /**
  35008. * Define a task used by {BABYLON.AssetsManager} to load meshes
  35009. */
  35010. class MeshAssetTask extends AbstractAssetTask {
  35011. /**
  35012. * Defines the name of the task
  35013. */
  35014. name: string;
  35015. /**
  35016. * Defines the list of mesh's names you want to load
  35017. */
  35018. meshesNames: any;
  35019. /**
  35020. * Defines the root url to use as a base to load your meshes and associated resources
  35021. */
  35022. rootUrl: string;
  35023. /**
  35024. * Defines the filename of the scene to load from
  35025. */
  35026. sceneFilename: string;
  35027. /**
  35028. * Gets the list of loaded meshes
  35029. */
  35030. loadedMeshes: Array<AbstractMesh>;
  35031. /**
  35032. * Gets the list of loaded particle systems
  35033. */
  35034. loadedParticleSystems: Array<IParticleSystem>;
  35035. /**
  35036. * Gets the list of loaded skeletons
  35037. */
  35038. loadedSkeletons: Array<Skeleton>;
  35039. /**
  35040. * Callback called when the task is successful
  35041. */
  35042. onSuccess: (task: MeshAssetTask) => void;
  35043. /**
  35044. * Callback called when the task is successful
  35045. */
  35046. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  35047. /**
  35048. * Creates a new {BABYLON.MeshAssetTask}
  35049. * @param name defines the name of the task
  35050. * @param meshesNames defines the list of mesh's names you want to load
  35051. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  35052. * @param sceneFilename defines the filename of the scene to load from
  35053. */
  35054. constructor(
  35055. /**
  35056. * Defines the name of the task
  35057. */
  35058. name: string,
  35059. /**
  35060. * Defines the list of mesh's names you want to load
  35061. */
  35062. meshesNames: any,
  35063. /**
  35064. * Defines the root url to use as a base to load your meshes and associated resources
  35065. */
  35066. rootUrl: string,
  35067. /**
  35068. * Defines the filename of the scene to load from
  35069. */
  35070. sceneFilename: string);
  35071. /**
  35072. * Execute the current task
  35073. * @param scene defines the scene where you want your assets to be loaded
  35074. * @param onSuccess is a callback called when the task is successfully executed
  35075. * @param onError is a callback called if an error occurs
  35076. */
  35077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35078. }
  35079. /**
  35080. * Define a task used by {BABYLON.AssetsManager} to load text content
  35081. */
  35082. class TextFileAssetTask extends AbstractAssetTask {
  35083. /**
  35084. * Defines the name of the task
  35085. */
  35086. name: string;
  35087. /**
  35088. * Defines the location of the file to load
  35089. */
  35090. url: string;
  35091. /**
  35092. * Gets the loaded text string
  35093. */
  35094. text: string;
  35095. /**
  35096. * Callback called when the task is successful
  35097. */
  35098. onSuccess: (task: TextFileAssetTask) => void;
  35099. /**
  35100. * Callback called when the task is successful
  35101. */
  35102. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  35103. /**
  35104. * Creates a new TextFileAssetTask object
  35105. * @param name defines the name of the task
  35106. * @param url defines the location of the file to load
  35107. */
  35108. constructor(
  35109. /**
  35110. * Defines the name of the task
  35111. */
  35112. name: string,
  35113. /**
  35114. * Defines the location of the file to load
  35115. */
  35116. url: string);
  35117. /**
  35118. * Execute the current task
  35119. * @param scene defines the scene where you want your assets to be loaded
  35120. * @param onSuccess is a callback called when the task is successfully executed
  35121. * @param onError is a callback called if an error occurs
  35122. */
  35123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35124. }
  35125. /**
  35126. * Define a task used by {BABYLON.AssetsManager} to load binary data
  35127. */
  35128. class BinaryFileAssetTask extends AbstractAssetTask {
  35129. /**
  35130. * Defines the name of the task
  35131. */
  35132. name: string;
  35133. /**
  35134. * Defines the location of the file to load
  35135. */
  35136. url: string;
  35137. /**
  35138. * Gets the lodaded data (as an array buffer)
  35139. */
  35140. data: ArrayBuffer;
  35141. /**
  35142. * Callback called when the task is successful
  35143. */
  35144. onSuccess: (task: BinaryFileAssetTask) => void;
  35145. /**
  35146. * Callback called when the task is successful
  35147. */
  35148. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  35149. /**
  35150. * Creates a new BinaryFileAssetTask object
  35151. * @param name defines the name of the new task
  35152. * @param url defines the location of the file to load
  35153. */
  35154. constructor(
  35155. /**
  35156. * Defines the name of the task
  35157. */
  35158. name: string,
  35159. /**
  35160. * Defines the location of the file to load
  35161. */
  35162. url: string);
  35163. /**
  35164. * Execute the current task
  35165. * @param scene defines the scene where you want your assets to be loaded
  35166. * @param onSuccess is a callback called when the task is successfully executed
  35167. * @param onError is a callback called if an error occurs
  35168. */
  35169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35170. }
  35171. /**
  35172. * Define a task used by {BABYLON.AssetsManager} to load images
  35173. */
  35174. class ImageAssetTask extends AbstractAssetTask {
  35175. /**
  35176. * Defines the name of the task
  35177. */
  35178. name: string;
  35179. /**
  35180. * Defines the location of the image to load
  35181. */
  35182. url: string;
  35183. /**
  35184. * Gets the loaded images
  35185. */
  35186. image: HTMLImageElement;
  35187. /**
  35188. * Callback called when the task is successful
  35189. */
  35190. onSuccess: (task: ImageAssetTask) => void;
  35191. /**
  35192. * Callback called when the task is successful
  35193. */
  35194. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  35195. /**
  35196. * Creates a new ImageAssetTask
  35197. * @param name defines the name of the task
  35198. * @param url defines the location of the image to load
  35199. */
  35200. constructor(
  35201. /**
  35202. * Defines the name of the task
  35203. */
  35204. name: string,
  35205. /**
  35206. * Defines the location of the image to load
  35207. */
  35208. url: string);
  35209. /**
  35210. * Execute the current task
  35211. * @param scene defines the scene where you want your assets to be loaded
  35212. * @param onSuccess is a callback called when the task is successfully executed
  35213. * @param onError is a callback called if an error occurs
  35214. */
  35215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35216. }
  35217. /**
  35218. * Defines the interface used by texture loading tasks
  35219. */
  35220. interface ITextureAssetTask<TEX extends BaseTexture> {
  35221. /**
  35222. * Gets the loaded texture
  35223. */
  35224. texture: TEX;
  35225. }
  35226. /**
  35227. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  35228. */
  35229. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  35230. /**
  35231. * Defines the name of the task
  35232. */
  35233. name: string;
  35234. /**
  35235. * Defines the location of the file to load
  35236. */
  35237. url: string;
  35238. /**
  35239. * Defines if mipmap should not be generated (default is false)
  35240. */
  35241. noMipmap?: boolean | undefined;
  35242. /**
  35243. * Defines if texture must be inverted on Y axis (default is false)
  35244. */
  35245. invertY?: boolean | undefined;
  35246. /**
  35247. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  35248. */
  35249. samplingMode: number;
  35250. /**
  35251. * Gets the loaded texture
  35252. */
  35253. texture: Texture;
  35254. /**
  35255. * Callback called when the task is successful
  35256. */
  35257. onSuccess: (task: TextureAssetTask) => void;
  35258. /**
  35259. * Callback called when the task is successful
  35260. */
  35261. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  35262. /**
  35263. * Creates a new TextureAssetTask object
  35264. * @param name defines the name of the task
  35265. * @param url defines the location of the file to load
  35266. * @param noMipmap defines if mipmap should not be generated (default is false)
  35267. * @param invertY defines if texture must be inverted on Y axis (default is false)
  35268. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  35269. */
  35270. constructor(
  35271. /**
  35272. * Defines the name of the task
  35273. */
  35274. name: string,
  35275. /**
  35276. * Defines the location of the file to load
  35277. */
  35278. url: string,
  35279. /**
  35280. * Defines if mipmap should not be generated (default is false)
  35281. */
  35282. noMipmap?: boolean | undefined,
  35283. /**
  35284. * Defines if texture must be inverted on Y axis (default is false)
  35285. */
  35286. invertY?: boolean | undefined,
  35287. /**
  35288. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  35289. */
  35290. samplingMode?: number);
  35291. /**
  35292. * Execute the current task
  35293. * @param scene defines the scene where you want your assets to be loaded
  35294. * @param onSuccess is a callback called when the task is successfully executed
  35295. * @param onError is a callback called if an error occurs
  35296. */
  35297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35298. }
  35299. /**
  35300. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  35301. */
  35302. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  35303. /**
  35304. * Defines the name of the task
  35305. */
  35306. name: string;
  35307. /**
  35308. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  35309. */
  35310. url: string;
  35311. /**
  35312. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  35313. */
  35314. extensions?: string[] | undefined;
  35315. /**
  35316. * Defines if mipmaps should not be generated (default is false)
  35317. */
  35318. noMipmap?: boolean | undefined;
  35319. /**
  35320. * Defines the explicit list of files (undefined by default)
  35321. */
  35322. files?: string[] | undefined;
  35323. /**
  35324. * Gets the loaded texture
  35325. */
  35326. texture: CubeTexture;
  35327. /**
  35328. * Callback called when the task is successful
  35329. */
  35330. onSuccess: (task: CubeTextureAssetTask) => void;
  35331. /**
  35332. * Callback called when the task is successful
  35333. */
  35334. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  35335. /**
  35336. * Creates a new CubeTextureAssetTask
  35337. * @param name defines the name of the task
  35338. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  35339. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  35340. * @param noMipmap defines if mipmaps should not be generated (default is false)
  35341. * @param files defines the explicit list of files (undefined by default)
  35342. */
  35343. constructor(
  35344. /**
  35345. * Defines the name of the task
  35346. */
  35347. name: string,
  35348. /**
  35349. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  35350. */
  35351. url: string,
  35352. /**
  35353. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  35354. */
  35355. extensions?: string[] | undefined,
  35356. /**
  35357. * Defines if mipmaps should not be generated (default is false)
  35358. */
  35359. noMipmap?: boolean | undefined,
  35360. /**
  35361. * Defines the explicit list of files (undefined by default)
  35362. */
  35363. files?: string[] | undefined);
  35364. /**
  35365. * Execute the current task
  35366. * @param scene defines the scene where you want your assets to be loaded
  35367. * @param onSuccess is a callback called when the task is successfully executed
  35368. * @param onError is a callback called if an error occurs
  35369. */
  35370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35371. }
  35372. /**
  35373. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  35374. */
  35375. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  35376. /**
  35377. * Defines the name of the task
  35378. */
  35379. name: string;
  35380. /**
  35381. * Defines the location of the file to load
  35382. */
  35383. url: string;
  35384. /**
  35385. * Defines the desired size (the more it increases the longer the generation will be)
  35386. */
  35387. size: number;
  35388. /**
  35389. * Defines if mipmaps should not be generated (default is false)
  35390. */
  35391. noMipmap: boolean;
  35392. /**
  35393. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  35394. */
  35395. generateHarmonics: boolean;
  35396. /**
  35397. * 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)
  35398. */
  35399. gammaSpace: boolean;
  35400. /**
  35401. * Internal Use Only
  35402. */
  35403. reserved: boolean;
  35404. /**
  35405. * Gets the loaded texture
  35406. */
  35407. texture: HDRCubeTexture;
  35408. /**
  35409. * Callback called when the task is successful
  35410. */
  35411. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  35412. /**
  35413. * Callback called when the task is successful
  35414. */
  35415. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  35416. /**
  35417. * Creates a new HDRCubeTextureAssetTask object
  35418. * @param name defines the name of the task
  35419. * @param url defines the location of the file to load
  35420. * @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.
  35421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  35422. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  35423. * @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)
  35424. * @param reserved Internal use only
  35425. */
  35426. constructor(
  35427. /**
  35428. * Defines the name of the task
  35429. */
  35430. name: string,
  35431. /**
  35432. * Defines the location of the file to load
  35433. */
  35434. url: string,
  35435. /**
  35436. * Defines the desired size (the more it increases the longer the generation will be)
  35437. */
  35438. size: number,
  35439. /**
  35440. * Defines if mipmaps should not be generated (default is false)
  35441. */
  35442. noMipmap?: boolean,
  35443. /**
  35444. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  35445. */
  35446. generateHarmonics?: boolean,
  35447. /**
  35448. * 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)
  35449. */
  35450. gammaSpace?: boolean,
  35451. /**
  35452. * Internal Use Only
  35453. */
  35454. reserved?: boolean);
  35455. /**
  35456. * Execute the current task
  35457. * @param scene defines the scene where you want your assets to be loaded
  35458. * @param onSuccess is a callback called when the task is successfully executed
  35459. * @param onError is a callback called if an error occurs
  35460. */
  35461. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  35462. }
  35463. /**
  35464. * This class can be used to easily import assets into a scene
  35465. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  35466. */
  35467. class AssetsManager {
  35468. private _scene;
  35469. private _isLoading;
  35470. protected _tasks: AbstractAssetTask[];
  35471. protected _waitingTasksCount: number;
  35472. protected _totalTasksCount: number;
  35473. /**
  35474. * Callback called when all tasks are processed
  35475. */
  35476. onFinish: (tasks: AbstractAssetTask[]) => void;
  35477. /**
  35478. * Callback called when a task is successful
  35479. */
  35480. onTaskSuccess: (task: AbstractAssetTask) => void;
  35481. /**
  35482. * Callback called when a task had an error
  35483. */
  35484. onTaskError: (task: AbstractAssetTask) => void;
  35485. /**
  35486. * Callback called when a task is done (whatever the result is)
  35487. */
  35488. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  35489. /**
  35490. * Observable called when all tasks are processed
  35491. */
  35492. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  35493. /**
  35494. * Observable called when a task had an error
  35495. */
  35496. onTaskErrorObservable: Observable<AbstractAssetTask>;
  35497. /**
  35498. * Observable called when a task is successful
  35499. */
  35500. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  35501. /**
  35502. * Observable called when a task is done (whatever the result is)
  35503. */
  35504. onProgressObservable: Observable<IAssetsProgressEvent>;
  35505. /**
  35506. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  35507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35508. */
  35509. useDefaultLoadingScreen: boolean;
  35510. /**
  35511. * Creates a new AssetsManager
  35512. * @param scene defines the scene to work on
  35513. */
  35514. constructor(scene: Scene);
  35515. /**
  35516. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  35517. * @param taskName defines the name of the new task
  35518. * @param meshesNames defines the name of meshes to load
  35519. * @param rootUrl defines the root url to use to locate files
  35520. * @param sceneFilename defines the filename of the scene file
  35521. * @returns a new {BABYLON.MeshAssetTask} object
  35522. */
  35523. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  35524. /**
  35525. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  35526. * @param taskName defines the name of the new task
  35527. * @param url defines the url of the file to load
  35528. * @returns a new {BABYLON.TextFileAssetTask} object
  35529. */
  35530. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  35531. /**
  35532. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  35533. * @param taskName defines the name of the new task
  35534. * @param url defines the url of the file to load
  35535. * @returns a new {BABYLON.BinaryFileAssetTask} object
  35536. */
  35537. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  35538. /**
  35539. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  35540. * @param taskName defines the name of the new task
  35541. * @param url defines the url of the file to load
  35542. * @returns a new {BABYLON.ImageAssetTask} object
  35543. */
  35544. addImageTask(taskName: string, url: string): ImageAssetTask;
  35545. /**
  35546. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  35547. * @param taskName defines the name of the new task
  35548. * @param url defines the url of the file to load
  35549. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  35550. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  35551. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  35552. * @returns a new {BABYLON.TextureAssetTask} object
  35553. */
  35554. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  35555. /**
  35556. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  35557. * @param taskName defines the name of the new task
  35558. * @param url defines the url of the file to load
  35559. * @param extensions defines the extension to use to load the cube map (can be null)
  35560. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  35561. * @param files defines the list of files to load (can be null)
  35562. * @returns a new {BABYLON.CubeTextureAssetTask} object
  35563. */
  35564. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  35565. /**
  35566. *
  35567. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  35568. * @param taskName defines the name of the new task
  35569. * @param url defines the url of the file to load
  35570. * @param size defines the size you want for the cubemap (can be null)
  35571. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  35572. * @param generateHarmonics defines if you want to automatically generate (true by default)
  35573. * @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)
  35574. * @param reserved Internal use only
  35575. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  35576. */
  35577. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  35578. /**
  35579. * Remove a task from the assets manager.
  35580. * @param task the task to remove
  35581. */
  35582. removeTask(task: AbstractAssetTask): void;
  35583. private _decreaseWaitingTasksCount;
  35584. private _runTask;
  35585. /**
  35586. * Reset the {BABYLON.AssetsManager} and remove all tasks
  35587. * @return the current instance of the {BABYLON.AssetsManager}
  35588. */
  35589. reset(): AssetsManager;
  35590. /**
  35591. * Start the loading process
  35592. * @return the current instance of the {BABYLON.AssetsManager}
  35593. */
  35594. load(): AssetsManager;
  35595. }
  35596. }
  35597. declare module BABYLON {
  35598. /**
  35599. * Class used to enable access to IndexedDB
  35600. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  35601. */
  35602. class Database {
  35603. private callbackManifestChecked;
  35604. private currentSceneUrl;
  35605. private db;
  35606. private _enableSceneOffline;
  35607. private _enableTexturesOffline;
  35608. private manifestVersionFound;
  35609. private mustUpdateRessources;
  35610. private hasReachedQuota;
  35611. private isSupported;
  35612. private idbFactory;
  35613. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  35614. static IsUASupportingBlobStorage: boolean;
  35615. /** Gets a boolean indicating if Database storate is enabled */
  35616. static IDBStorageEnabled: boolean;
  35617. /**
  35618. * Gets a boolean indicating if scene must be saved in the database
  35619. */
  35620. readonly enableSceneOffline: boolean;
  35621. /**
  35622. * Gets a boolean indicating if textures must be saved in the database
  35623. */
  35624. readonly enableTexturesOffline: boolean;
  35625. /**
  35626. * Creates a new Database
  35627. * @param urlToScene defines the url to load the scene
  35628. * @param callbackManifestChecked defines the callback to use when manifest is checked
  35629. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  35630. */
  35631. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  35632. private static _ParseURL;
  35633. private static _ReturnFullUrlLocation;
  35634. private _checkManifestFile;
  35635. /**
  35636. * Open the database and make it available
  35637. * @param successCallback defines the callback to call on success
  35638. * @param errorCallback defines the callback to call on error
  35639. */
  35640. openAsync(successCallback: () => void, errorCallback: () => void): void;
  35641. /**
  35642. * Loads an image from the database
  35643. * @param url defines the url to load from
  35644. * @param image defines the target DOM image
  35645. */
  35646. loadImageFromDB(url: string, image: HTMLImageElement): void;
  35647. private _loadImageFromDBAsync;
  35648. private _saveImageIntoDBAsync;
  35649. private _checkVersionFromDB;
  35650. private _loadVersionFromDBAsync;
  35651. private _saveVersionIntoDBAsync;
  35652. /**
  35653. * Loads a file from database
  35654. * @param url defines the URL to load from
  35655. * @param sceneLoaded defines a callback to call on success
  35656. * @param progressCallBack defines a callback to call when progress changed
  35657. * @param errorCallback defines a callback to call on error
  35658. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  35659. */
  35660. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  35661. private _loadFileFromDBAsync;
  35662. private _saveFileIntoDBAsync;
  35663. }
  35664. }
  35665. declare module BABYLON {
  35666. /**
  35667. * Direct draw surface info
  35668. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  35669. */
  35670. interface DDSInfo {
  35671. /**
  35672. * Width of the texture
  35673. */
  35674. width: number;
  35675. /**
  35676. * Width of the texture
  35677. */
  35678. height: number;
  35679. /**
  35680. * Number of Mipmaps for the texture
  35681. * @see https://en.wikipedia.org/wiki/Mipmap
  35682. */
  35683. mipmapCount: number;
  35684. /**
  35685. * If the textures format is a known fourCC format
  35686. * @see https://www.fourcc.org/
  35687. */
  35688. isFourCC: boolean;
  35689. /**
  35690. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  35691. */
  35692. isRGB: boolean;
  35693. /**
  35694. * If the texture is a lumincance format
  35695. */
  35696. isLuminance: boolean;
  35697. /**
  35698. * If this is a cube texture
  35699. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  35700. */
  35701. isCube: boolean;
  35702. /**
  35703. * If the texture is a compressed format eg. FOURCC_DXT1
  35704. */
  35705. isCompressed: boolean;
  35706. /**
  35707. * The dxgiFormat of the texture
  35708. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  35709. */
  35710. dxgiFormat: number;
  35711. /**
  35712. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  35713. */
  35714. textureType: number;
  35715. /**
  35716. * Sphericle polynomial created for the dds texture
  35717. */
  35718. sphericalPolynomial?: SphericalPolynomial;
  35719. }
  35720. /**
  35721. * Class used to provide DDS decompression tools
  35722. */
  35723. class DDSTools {
  35724. /**
  35725. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  35726. */
  35727. static StoreLODInAlphaChannel: boolean;
  35728. /**
  35729. * Gets DDS information from an array buffer
  35730. * @param arrayBuffer defines the array buffer to read data from
  35731. * @returns the DDS information
  35732. */
  35733. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  35734. private static _FloatView;
  35735. private static _Int32View;
  35736. private static _ToHalfFloat;
  35737. private static _FromHalfFloat;
  35738. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  35739. private static _GetHalfFloatRGBAArrayBuffer;
  35740. private static _GetFloatRGBAArrayBuffer;
  35741. private static _GetFloatAsUIntRGBAArrayBuffer;
  35742. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  35743. private static _GetRGBAArrayBuffer;
  35744. private static _ExtractLongWordOrder;
  35745. private static _GetRGBArrayBuffer;
  35746. private static _GetLuminanceArrayBuffer;
  35747. /**
  35748. * Uploads DDS Levels to a Babylon Texture
  35749. * @hidden
  35750. */
  35751. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  35752. }
  35753. }
  35754. declare module BABYLON {
  35755. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35756. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35757. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35758. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35759. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35760. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35761. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35762. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35763. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35764. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35765. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35766. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35767. /**
  35768. * Decorator used to define property that can be serialized as reference to a camera
  35769. * @param sourceName defines the name of the property to decorate
  35770. */
  35771. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35772. class SerializationHelper {
  35773. static Serialize<T>(entity: T, serializationObject?: any): any;
  35774. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35775. static Clone<T>(creationFunction: () => T, source: T): T;
  35776. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35777. }
  35778. }
  35779. declare module BABYLON {
  35780. /**
  35781. * Wrapper class for promise with external resolve and reject.
  35782. */
  35783. class Deferred<T> {
  35784. /**
  35785. * The promise associated with this deferred object.
  35786. */
  35787. readonly promise: Promise<T>;
  35788. private _resolve;
  35789. private _reject;
  35790. /**
  35791. * The resolve method of the promise associated with this deferred object.
  35792. */
  35793. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  35794. /**
  35795. * The reject method of the promise associated with this deferred object.
  35796. */
  35797. readonly reject: (reason?: any) => void;
  35798. /**
  35799. * Constructor for this deferred object.
  35800. */
  35801. constructor();
  35802. }
  35803. }
  35804. declare module BABYLON {
  35805. /**
  35806. * Raw texture data and descriptor sufficient for WebGL texture upload
  35807. */
  35808. interface EnvironmentTextureInfo {
  35809. /**
  35810. * Version of the environment map
  35811. */
  35812. version: number;
  35813. /**
  35814. * Width of image
  35815. */
  35816. width: number;
  35817. /**
  35818. * Irradiance information stored in the file.
  35819. */
  35820. irradiance: any;
  35821. /**
  35822. * Specular information stored in the file.
  35823. */
  35824. specular: any;
  35825. }
  35826. /**
  35827. * Sets of helpers addressing the serialization and deserialization of environment texture
  35828. * stored in a BabylonJS env file.
  35829. * Those files are usually stored as .env files.
  35830. */
  35831. class EnvironmentTextureTools {
  35832. /**
  35833. * Magic number identifying the env file.
  35834. */
  35835. private static _MagicBytes;
  35836. /**
  35837. * Gets the environment info from an env file.
  35838. * @param data The array buffer containing the .env bytes.
  35839. * @returns the environment file info (the json header) if successfully parsed.
  35840. */
  35841. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  35842. /**
  35843. * Creates an environment texture from a loaded cube texture.
  35844. * @param texture defines the cube texture to convert in env file
  35845. * @return a promise containing the environment data if succesfull.
  35846. */
  35847. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  35848. /**
  35849. * Creates a JSON representation of the spherical data.
  35850. * @param texture defines the texture containing the polynomials
  35851. * @return the JSON representation of the spherical info
  35852. */
  35853. private static _CreateEnvTextureIrradiance;
  35854. /**
  35855. * Uploads the texture info contained in the env file to the GPU.
  35856. * @param texture defines the internal texture to upload to
  35857. * @param arrayBuffer defines the buffer cotaining the data to load
  35858. * @param info defines the texture info retrieved through the GetEnvInfo method
  35859. * @returns a promise
  35860. */
  35861. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  35862. /**
  35863. * Uploads the levels of image data to the GPU.
  35864. * @param texture defines the internal texture to upload to
  35865. * @param imageData defines the array buffer views of image data [mipmap][face]
  35866. * @returns a promise
  35867. */
  35868. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  35869. /**
  35870. * Uploads spherical polynomials information to the texture.
  35871. * @param texture defines the texture we are trying to upload the information to
  35872. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  35873. */
  35874. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  35875. }
  35876. }
  35877. declare module BABYLON {
  35878. /**
  35879. * Class used to help managing file picking and drag'n'drop
  35880. */
  35881. class FilesInput {
  35882. /**
  35883. * List of files ready to be loaded
  35884. */
  35885. static FilesToLoad: {
  35886. [key: string]: File;
  35887. };
  35888. /**
  35889. * Callback called when a file is processed
  35890. */
  35891. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  35892. private _engine;
  35893. private _currentScene;
  35894. private _sceneLoadedCallback;
  35895. private _progressCallback;
  35896. private _additionalRenderLoopLogicCallback;
  35897. private _textureLoadingCallback;
  35898. private _startingProcessingFilesCallback;
  35899. private _onReloadCallback;
  35900. private _errorCallback;
  35901. private _elementToMonitor;
  35902. private _sceneFileToLoad;
  35903. private _filesToLoad;
  35904. /**
  35905. * Creates a new FilesInput
  35906. * @param engine defines the rendering engine
  35907. * @param scene defines the hosting scene
  35908. * @param sceneLoadedCallback callback called when scene is loaded
  35909. * @param progressCallback callback called to track progress
  35910. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  35911. * @param textureLoadingCallback callback called when a texture is loading
  35912. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  35913. * @param onReloadCallback callback called when a reload is requested
  35914. * @param errorCallback callback call if an error occurs
  35915. */
  35916. 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);
  35917. private _dragEnterHandler;
  35918. private _dragOverHandler;
  35919. private _dropHandler;
  35920. /**
  35921. * Calls this function to listen to drag'n'drop events on a specific DOM element
  35922. * @param elementToMonitor defines the DOM element to track
  35923. */
  35924. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  35925. /**
  35926. * Release all associated resources
  35927. */
  35928. dispose(): void;
  35929. private renderFunction;
  35930. private drag;
  35931. private drop;
  35932. private _traverseFolder;
  35933. private _processFiles;
  35934. /**
  35935. * Load files from a drop event
  35936. * @param event defines the drop event to use as source
  35937. */
  35938. loadFiles(event: any): void;
  35939. private _processReload;
  35940. /**
  35941. * Reload the current scene from the loaded files
  35942. */
  35943. reload(): void;
  35944. }
  35945. }
  35946. declare module BABYLON {
  35947. /**
  35948. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  35949. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  35950. */
  35951. class KhronosTextureContainer {
  35952. /** contents of the KTX container file */
  35953. arrayBuffer: any;
  35954. private static HEADER_LEN;
  35955. private static COMPRESSED_2D;
  35956. private static COMPRESSED_3D;
  35957. private static TEX_2D;
  35958. private static TEX_3D;
  35959. /**
  35960. * Gets the openGL type
  35961. */
  35962. glType: number;
  35963. /**
  35964. * Gets the openGL type size
  35965. */
  35966. glTypeSize: number;
  35967. /**
  35968. * Gets the openGL format
  35969. */
  35970. glFormat: number;
  35971. /**
  35972. * Gets the openGL internal format
  35973. */
  35974. glInternalFormat: number;
  35975. /**
  35976. * Gets the base internal format
  35977. */
  35978. glBaseInternalFormat: number;
  35979. /**
  35980. * Gets image width in pixel
  35981. */
  35982. pixelWidth: number;
  35983. /**
  35984. * Gets image height in pixel
  35985. */
  35986. pixelHeight: number;
  35987. /**
  35988. * Gets image depth in pixels
  35989. */
  35990. pixelDepth: number;
  35991. /**
  35992. * Gets the number of array elements
  35993. */
  35994. numberOfArrayElements: number;
  35995. /**
  35996. * Gets the number of faces
  35997. */
  35998. numberOfFaces: number;
  35999. /**
  36000. * Gets the number of mipmap levels
  36001. */
  36002. numberOfMipmapLevels: number;
  36003. /**
  36004. * Gets the bytes of key value data
  36005. */
  36006. bytesOfKeyValueData: number;
  36007. /**
  36008. * Gets the load type
  36009. */
  36010. loadType: number;
  36011. /**
  36012. * Creates a new KhronosTextureContainer
  36013. * @param arrayBuffer contents of the KTX container file
  36014. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  36015. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  36016. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  36017. */
  36018. constructor(
  36019. /** contents of the KTX container file */
  36020. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  36021. /**
  36022. * Revert the endianness of a value.
  36023. * Not as fast hardware based, but will probably never need to use
  36024. * @param val defines the value to convert
  36025. * @returns the new value
  36026. */
  36027. switchEndianness(val: number): number;
  36028. /**
  36029. * Uploads KTX content to a Babylon Texture.
  36030. * It is assumed that the texture has already been created & is currently bound
  36031. * @hidden
  36032. */
  36033. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  36034. private _upload2DCompressedLevels;
  36035. }
  36036. }
  36037. declare module BABYLON {
  36038. /**
  36039. * A class serves as a medium between the observable and its observers
  36040. */
  36041. class EventState {
  36042. /**
  36043. * Create a new EventState
  36044. * @param mask defines the mask associated with this state
  36045. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  36046. * @param target defines the original target of the state
  36047. * @param currentTarget defines the current target of the state
  36048. */
  36049. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  36050. /**
  36051. * Initialize the current event state
  36052. * @param mask defines the mask associated with this state
  36053. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  36054. * @param target defines the original target of the state
  36055. * @param currentTarget defines the current target of the state
  36056. * @returns the current event state
  36057. */
  36058. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  36059. /**
  36060. * An Observer can set this property to true to prevent subsequent observers of being notified
  36061. */
  36062. skipNextObservers: boolean;
  36063. /**
  36064. * Get the mask value that were used to trigger the event corresponding to this EventState object
  36065. */
  36066. mask: number;
  36067. /**
  36068. * The object that originally notified the event
  36069. */
  36070. target?: any;
  36071. /**
  36072. * The current object in the bubbling phase
  36073. */
  36074. currentTarget?: any;
  36075. /**
  36076. * This will be populated with the return value of the last function that was executed.
  36077. * If it is the first function in the callback chain it will be the event data.
  36078. */
  36079. lastReturnValue?: any;
  36080. }
  36081. /**
  36082. * Represent an Observer registered to a given Observable object.
  36083. */
  36084. class Observer<T> {
  36085. /**
  36086. * Defines the callback to call when the observer is notified
  36087. */
  36088. callback: (eventData: T, eventState: EventState) => void;
  36089. /**
  36090. * Defines the mask of the observer (used to filter notifications)
  36091. */
  36092. mask: number;
  36093. /**
  36094. * Defines the current scope used to restore the JS context
  36095. */
  36096. scope: any;
  36097. /** @hidden */
  36098. _willBeUnregistered: boolean;
  36099. /**
  36100. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  36101. */
  36102. unregisterOnNextCall: boolean;
  36103. /**
  36104. * Creates a new observer
  36105. * @param callback defines the callback to call when the observer is notified
  36106. * @param mask defines the mask of the observer (used to filter notifications)
  36107. * @param scope defines the current scope used to restore the JS context
  36108. */
  36109. constructor(
  36110. /**
  36111. * Defines the callback to call when the observer is notified
  36112. */
  36113. callback: (eventData: T, eventState: EventState) => void,
  36114. /**
  36115. * Defines the mask of the observer (used to filter notifications)
  36116. */
  36117. mask: number,
  36118. /**
  36119. * Defines the current scope used to restore the JS context
  36120. */
  36121. scope?: any);
  36122. }
  36123. /**
  36124. * Represent a list of observers registered to multiple Observables object.
  36125. */
  36126. class MultiObserver<T> {
  36127. private _observers;
  36128. private _observables;
  36129. /**
  36130. * Release associated resources
  36131. */
  36132. dispose(): void;
  36133. /**
  36134. * Raise a callback when one of the observable will notify
  36135. * @param observables defines a list of observables to watch
  36136. * @param callback defines the callback to call on notification
  36137. * @param mask defines the mask used to filter notifications
  36138. * @param scope defines the current scope used to restore the JS context
  36139. * @returns the new MultiObserver
  36140. */
  36141. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  36142. }
  36143. /**
  36144. * The Observable class is a simple implementation of the Observable pattern.
  36145. *
  36146. * 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.
  36147. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  36148. * 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).
  36149. * 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.
  36150. */
  36151. class Observable<T> {
  36152. private _observers;
  36153. private _eventState;
  36154. private _onObserverAdded;
  36155. /**
  36156. * Creates a new observable
  36157. * @param onObserverAdded defines a callback to call when a new observer is added
  36158. */
  36159. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  36160. /**
  36161. * Create a new Observer with the specified callback
  36162. * @param callback the callback that will be executed for that Observer
  36163. * @param mask the mask used to filter observers
  36164. * @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.
  36165. * @param scope optional scope for the callback to be called from
  36166. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  36167. * @returns the new observer created for the callback
  36168. */
  36169. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  36170. /**
  36171. * Create a new Observer with the specified callback and unregisters after the next notification
  36172. * @param callback the callback that will be executed for that Observer
  36173. * @returns the new observer created for the callback
  36174. */
  36175. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  36176. /**
  36177. * Remove an Observer from the Observable object
  36178. * @param observer the instance of the Observer to remove
  36179. * @returns false if it doesn't belong to this Observable
  36180. */
  36181. remove(observer: Nullable<Observer<T>>): boolean;
  36182. /**
  36183. * Remove a callback from the Observable object
  36184. * @param callback the callback to remove
  36185. * @param scope optional scope. If used only the callbacks with this scope will be removed
  36186. * @returns false if it doesn't belong to this Observable
  36187. */
  36188. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  36189. private _deferUnregister;
  36190. private _remove;
  36191. /**
  36192. * Notify all Observers by calling their respective callback with the given data
  36193. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  36194. * @param eventData defines the data to send to all observers
  36195. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  36196. * @param target defines the original target of the state
  36197. * @param currentTarget defines the current target of the state
  36198. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  36199. */
  36200. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  36201. /**
  36202. * Calling this will execute each callback, expecting it to be a promise or return a value.
  36203. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  36204. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  36205. * and it is crucial that all callbacks will be executed.
  36206. * The order of the callbacks is kept, callbacks are not executed parallel.
  36207. *
  36208. * @param eventData The data to be sent to each callback
  36209. * @param mask is used to filter observers defaults to -1
  36210. * @param target defines the callback target (see EventState)
  36211. * @param currentTarget defines he current object in the bubbling phase
  36212. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  36213. */
  36214. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  36215. /**
  36216. * Notify a specific observer
  36217. * @param observer defines the observer to notify
  36218. * @param eventData defines the data to be sent to each callback
  36219. * @param mask is used to filter observers defaults to -1
  36220. */
  36221. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  36222. /**
  36223. * Gets a boolean indicating if the observable has at least one observer
  36224. * @returns true is the Observable has at least one Observer registered
  36225. */
  36226. hasObservers(): boolean;
  36227. /**
  36228. * Clear the list of observers
  36229. */
  36230. clear(): void;
  36231. /**
  36232. * Clone the current observable
  36233. * @returns a new observable
  36234. */
  36235. clone(): Observable<T>;
  36236. /**
  36237. * Does this observable handles observer registered with a given mask
  36238. * @param mask defines the mask to be tested
  36239. * @return whether or not one observer registered with the given mask is handeled
  36240. **/
  36241. hasSpecificMask(mask?: number): boolean;
  36242. }
  36243. }
  36244. declare module BABYLON {
  36245. /**
  36246. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36247. */
  36248. class PerformanceMonitor {
  36249. private _enabled;
  36250. private _rollingFrameTime;
  36251. private _lastFrameTimeMs;
  36252. /**
  36253. * constructor
  36254. * @param frameSampleSize The number of samples required to saturate the sliding window
  36255. */
  36256. constructor(frameSampleSize?: number);
  36257. /**
  36258. * Samples current frame
  36259. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36260. */
  36261. sampleFrame(timeMs?: number): void;
  36262. /**
  36263. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36264. */
  36265. readonly averageFrameTime: number;
  36266. /**
  36267. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36268. */
  36269. readonly averageFrameTimeVariance: number;
  36270. /**
  36271. * Returns the frame time of the most recent frame
  36272. */
  36273. readonly instantaneousFrameTime: number;
  36274. /**
  36275. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36276. */
  36277. readonly averageFPS: number;
  36278. /**
  36279. * Returns the average framerate in frames per second using the most recent frame time
  36280. */
  36281. readonly instantaneousFPS: number;
  36282. /**
  36283. * Returns true if enough samples have been taken to completely fill the sliding window
  36284. */
  36285. readonly isSaturated: boolean;
  36286. /**
  36287. * Enables contributions to the sliding window sample set
  36288. */
  36289. enable(): void;
  36290. /**
  36291. * Disables contributions to the sliding window sample set
  36292. * Samples will not be interpolated over the disabled period
  36293. */
  36294. disable(): void;
  36295. /**
  36296. * Returns true if sampling is enabled
  36297. */
  36298. readonly isEnabled: boolean;
  36299. /**
  36300. * Resets performance monitor
  36301. */
  36302. reset(): void;
  36303. }
  36304. /**
  36305. * RollingAverage
  36306. *
  36307. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36308. */
  36309. class RollingAverage {
  36310. /**
  36311. * Current average
  36312. */
  36313. average: number;
  36314. /**
  36315. * Current variance
  36316. */
  36317. variance: number;
  36318. protected _samples: Array<number>;
  36319. protected _sampleCount: number;
  36320. protected _pos: number;
  36321. protected _m2: number;
  36322. /**
  36323. * constructor
  36324. * @param length The number of samples required to saturate the sliding window
  36325. */
  36326. constructor(length: number);
  36327. /**
  36328. * Adds a sample to the sample set
  36329. * @param v The sample value
  36330. */
  36331. add(v: number): void;
  36332. /**
  36333. * Returns previously added values or null if outside of history or outside the sliding window domain
  36334. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36335. * @return Value previously recorded with add() or null if outside of range
  36336. */
  36337. history(i: number): number;
  36338. /**
  36339. * Returns true if enough samples have been taken to completely fill the sliding window
  36340. * @return true if sample-set saturated
  36341. */
  36342. isSaturated(): boolean;
  36343. /**
  36344. * Resets the rolling average (equivalent to 0 samples taken so far)
  36345. */
  36346. reset(): void;
  36347. /**
  36348. * Wraps a value around the sample range boundaries
  36349. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36350. * @return Wrapped position in sample range
  36351. */
  36352. protected _wrapPosition(i: number): number;
  36353. }
  36354. }
  36355. declare module BABYLON {
  36356. /**
  36357. * Helper class that provides a small promise polyfill
  36358. */
  36359. class PromisePolyfill {
  36360. /**
  36361. * Static function used to check if the polyfill is required
  36362. * If this is the case then the function will inject the polyfill to window.Promise
  36363. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36364. */
  36365. static Apply(force?: boolean): void;
  36366. }
  36367. }
  36368. declare module BABYLON {
  36369. /**
  36370. * Defines the root class used to create scene optimization to use with SceneOptimizer
  36371. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36372. */
  36373. class SceneOptimization {
  36374. /**
  36375. * Defines the priority of this optimization (0 by default which means first in the list)
  36376. */
  36377. priority: number;
  36378. /**
  36379. * Gets a string describing the action executed by the current optimization
  36380. * @returns description string
  36381. */
  36382. getDescription(): string;
  36383. /**
  36384. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36385. * @param scene defines the current scene where to apply this optimization
  36386. * @param optimizer defines the current optimizer
  36387. * @returns true if everything that can be done was applied
  36388. */
  36389. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36390. /**
  36391. * Creates the SceneOptimization object
  36392. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  36393. * @param desc defines the description associated with the optimization
  36394. */
  36395. constructor(
  36396. /**
  36397. * Defines the priority of this optimization (0 by default which means first in the list)
  36398. */
  36399. priority?: number);
  36400. }
  36401. /**
  36402. * Defines an optimization used to reduce the size of render target textures
  36403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36404. */
  36405. class TextureOptimization extends SceneOptimization {
  36406. /**
  36407. * Defines the priority of this optimization (0 by default which means first in the list)
  36408. */
  36409. priority: number;
  36410. /**
  36411. * 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
  36412. */
  36413. maximumSize: number;
  36414. /**
  36415. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  36416. */
  36417. step: number;
  36418. /**
  36419. * Gets a string describing the action executed by the current optimization
  36420. * @returns description string
  36421. */
  36422. getDescription(): string;
  36423. /**
  36424. * Creates the TextureOptimization object
  36425. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  36426. * @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
  36427. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  36428. */
  36429. constructor(
  36430. /**
  36431. * Defines the priority of this optimization (0 by default which means first in the list)
  36432. */
  36433. priority?: number,
  36434. /**
  36435. * 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
  36436. */
  36437. maximumSize?: number,
  36438. /**
  36439. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  36440. */
  36441. step?: number);
  36442. /**
  36443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36444. * @param scene defines the current scene where to apply this optimization
  36445. * @param optimizer defines the current optimizer
  36446. * @returns true if everything that can be done was applied
  36447. */
  36448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36449. }
  36450. /**
  36451. * Defines an optimization used to increase or decrease the rendering resolution
  36452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36453. */
  36454. class HardwareScalingOptimization extends SceneOptimization {
  36455. /**
  36456. * Defines the priority of this optimization (0 by default which means first in the list)
  36457. */
  36458. priority: number;
  36459. /**
  36460. * Defines the maximum scale to use (2 by default)
  36461. */
  36462. maximumScale: number;
  36463. /**
  36464. * Defines the step to use between two passes (0.5 by default)
  36465. */
  36466. step: number;
  36467. private _currentScale;
  36468. private _directionOffset;
  36469. /**
  36470. * Gets a string describing the action executed by the current optimization
  36471. * @return description string
  36472. */
  36473. getDescription(): string;
  36474. /**
  36475. * Creates the HardwareScalingOptimization object
  36476. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  36477. * @param maximumScale defines the maximum scale to use (2 by default)
  36478. * @param step defines the step to use between two passes (0.5 by default)
  36479. */
  36480. constructor(
  36481. /**
  36482. * Defines the priority of this optimization (0 by default which means first in the list)
  36483. */
  36484. priority?: number,
  36485. /**
  36486. * Defines the maximum scale to use (2 by default)
  36487. */
  36488. maximumScale?: number,
  36489. /**
  36490. * Defines the step to use between two passes (0.5 by default)
  36491. */
  36492. step?: number);
  36493. /**
  36494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36495. * @param scene defines the current scene where to apply this optimization
  36496. * @param optimizer defines the current optimizer
  36497. * @returns true if everything that can be done was applied
  36498. */
  36499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36500. }
  36501. /**
  36502. * Defines an optimization used to remove shadows
  36503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36504. */
  36505. class ShadowsOptimization extends SceneOptimization {
  36506. /**
  36507. * Gets a string describing the action executed by the current optimization
  36508. * @return description string
  36509. */
  36510. getDescription(): string;
  36511. /**
  36512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36513. * @param scene defines the current scene where to apply this optimization
  36514. * @param optimizer defines the current optimizer
  36515. * @returns true if everything that can be done was applied
  36516. */
  36517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36518. }
  36519. /**
  36520. * Defines an optimization used to turn post-processes off
  36521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36522. */
  36523. class PostProcessesOptimization extends SceneOptimization {
  36524. /**
  36525. * Gets a string describing the action executed by the current optimization
  36526. * @return description string
  36527. */
  36528. getDescription(): string;
  36529. /**
  36530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36531. * @param scene defines the current scene where to apply this optimization
  36532. * @param optimizer defines the current optimizer
  36533. * @returns true if everything that can be done was applied
  36534. */
  36535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36536. }
  36537. /**
  36538. * Defines an optimization used to turn lens flares off
  36539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36540. */
  36541. class LensFlaresOptimization extends SceneOptimization {
  36542. /**
  36543. * Gets a string describing the action executed by the current optimization
  36544. * @return description string
  36545. */
  36546. getDescription(): string;
  36547. /**
  36548. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36549. * @param scene defines the current scene where to apply this optimization
  36550. * @param optimizer defines the current optimizer
  36551. * @returns true if everything that can be done was applied
  36552. */
  36553. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36554. }
  36555. /**
  36556. * Defines an optimization based on user defined callback.
  36557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36558. */
  36559. class CustomOptimization extends SceneOptimization {
  36560. /**
  36561. * Callback called to apply the custom optimization.
  36562. */
  36563. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  36564. /**
  36565. * Callback called to get custom description
  36566. */
  36567. onGetDescription: () => string;
  36568. /**
  36569. * Gets a string describing the action executed by the current optimization
  36570. * @returns description string
  36571. */
  36572. getDescription(): string;
  36573. /**
  36574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36575. * @param scene defines the current scene where to apply this optimization
  36576. * @param optimizer defines the current optimizer
  36577. * @returns true if everything that can be done was applied
  36578. */
  36579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36580. }
  36581. /**
  36582. * Defines an optimization used to turn particles off
  36583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36584. */
  36585. class ParticlesOptimization extends SceneOptimization {
  36586. /**
  36587. * Gets a string describing the action executed by the current optimization
  36588. * @return description string
  36589. */
  36590. getDescription(): string;
  36591. /**
  36592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36593. * @param scene defines the current scene where to apply this optimization
  36594. * @param optimizer defines the current optimizer
  36595. * @returns true if everything that can be done was applied
  36596. */
  36597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36598. }
  36599. /**
  36600. * Defines an optimization used to turn render targets off
  36601. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36602. */
  36603. class RenderTargetsOptimization extends SceneOptimization {
  36604. /**
  36605. * Gets a string describing the action executed by the current optimization
  36606. * @return description string
  36607. */
  36608. getDescription(): string;
  36609. /**
  36610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36611. * @param scene defines the current scene where to apply this optimization
  36612. * @param optimizer defines the current optimizer
  36613. * @returns true if everything that can be done was applied
  36614. */
  36615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  36616. }
  36617. /**
  36618. * Defines an optimization used to merge meshes with compatible materials
  36619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36620. */
  36621. class MergeMeshesOptimization extends SceneOptimization {
  36622. private static _UpdateSelectionTree;
  36623. /**
  36624. * Gets or sets a boolean which defines if optimization octree has to be updated
  36625. */
  36626. /**
  36627. * Gets or sets a boolean which defines if optimization octree has to be updated
  36628. */
  36629. static UpdateSelectionTree: boolean;
  36630. /**
  36631. * Gets a string describing the action executed by the current optimization
  36632. * @return description string
  36633. */
  36634. getDescription(): string;
  36635. private _canBeMerged;
  36636. /**
  36637. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  36638. * @param scene defines the current scene where to apply this optimization
  36639. * @param optimizer defines the current optimizer
  36640. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  36641. * @returns true if everything that can be done was applied
  36642. */
  36643. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  36644. }
  36645. /**
  36646. * Defines a list of options used by SceneOptimizer
  36647. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36648. */
  36649. class SceneOptimizerOptions {
  36650. /**
  36651. * Defines the target frame rate to reach (60 by default)
  36652. */
  36653. targetFrameRate: number;
  36654. /**
  36655. * Defines the interval between two checkes (2000ms by default)
  36656. */
  36657. trackerDuration: number;
  36658. /**
  36659. * Gets the list of optimizations to apply
  36660. */
  36661. optimizations: SceneOptimization[];
  36662. /**
  36663. * Creates a new list of options used by SceneOptimizer
  36664. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  36665. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  36666. */
  36667. constructor(
  36668. /**
  36669. * Defines the target frame rate to reach (60 by default)
  36670. */
  36671. targetFrameRate?: number,
  36672. /**
  36673. * Defines the interval between two checkes (2000ms by default)
  36674. */
  36675. trackerDuration?: number);
  36676. /**
  36677. * Add a new optimization
  36678. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  36679. * @returns the current SceneOptimizerOptions
  36680. */
  36681. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  36682. /**
  36683. * Add a new custom optimization
  36684. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  36685. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  36686. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  36687. * @returns the current SceneOptimizerOptions
  36688. */
  36689. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  36690. /**
  36691. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  36692. * @param targetFrameRate defines the target frame rate (60 by default)
  36693. * @returns a SceneOptimizerOptions object
  36694. */
  36695. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  36696. /**
  36697. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  36698. * @param targetFrameRate defines the target frame rate (60 by default)
  36699. * @returns a SceneOptimizerOptions object
  36700. */
  36701. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  36702. /**
  36703. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  36704. * @param targetFrameRate defines the target frame rate (60 by default)
  36705. * @returns a SceneOptimizerOptions object
  36706. */
  36707. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  36708. }
  36709. /**
  36710. * Class used to run optimizations in order to reach a target frame rate
  36711. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  36712. */
  36713. class SceneOptimizer implements IDisposable {
  36714. private _isRunning;
  36715. private _options;
  36716. private _scene;
  36717. private _currentPriorityLevel;
  36718. private _targetFrameRate;
  36719. private _trackerDuration;
  36720. private _currentFrameRate;
  36721. private _sceneDisposeObserver;
  36722. private _improvementMode;
  36723. /**
  36724. * Defines an observable called when the optimizer reaches the target frame rate
  36725. */
  36726. onSuccessObservable: Observable<SceneOptimizer>;
  36727. /**
  36728. * Defines an observable called when the optimizer enables an optimization
  36729. */
  36730. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  36731. /**
  36732. * Defines an observable called when the optimizer is not able to reach the target frame rate
  36733. */
  36734. onFailureObservable: Observable<SceneOptimizer>;
  36735. /**
  36736. * Gets a boolean indicating if the optimizer is in improvement mode
  36737. */
  36738. readonly isInImprovementMode: boolean;
  36739. /**
  36740. * Gets the current priority level (0 at start)
  36741. */
  36742. readonly currentPriorityLevel: number;
  36743. /**
  36744. * Gets the current frame rate checked by the SceneOptimizer
  36745. */
  36746. readonly currentFrameRate: number;
  36747. /**
  36748. * Gets or sets the current target frame rate (60 by default)
  36749. */
  36750. /**
  36751. * Gets or sets the current target frame rate (60 by default)
  36752. */
  36753. targetFrameRate: number;
  36754. /**
  36755. * Gets or sets the current interval between two checks (every 2000ms by default)
  36756. */
  36757. /**
  36758. * Gets or sets the current interval between two checks (every 2000ms by default)
  36759. */
  36760. trackerDuration: number;
  36761. /**
  36762. * Gets the list of active optimizations
  36763. */
  36764. readonly optimizations: SceneOptimization[];
  36765. /**
  36766. * Creates a new SceneOptimizer
  36767. * @param scene defines the scene to work on
  36768. * @param options defines the options to use with the SceneOptimizer
  36769. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  36770. * @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)
  36771. */
  36772. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  36773. /**
  36774. * Stops the current optimizer
  36775. */
  36776. stop(): void;
  36777. /**
  36778. * Reset the optimizer to initial step (current priority level = 0)
  36779. */
  36780. reset(): void;
  36781. /**
  36782. * Start the optimizer. By default it will try to reach a specific framerate
  36783. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  36784. */
  36785. start(): void;
  36786. private _checkCurrentState;
  36787. /**
  36788. * Release all resources
  36789. */
  36790. dispose(): void;
  36791. /**
  36792. * Helper function to create a SceneOptimizer with one single line of code
  36793. * @param scene defines the scene to work on
  36794. * @param options defines the options to use with the SceneOptimizer
  36795. * @param onSuccess defines a callback to call on success
  36796. * @param onFailure defines a callback to call on failure
  36797. * @returns the new SceneOptimizer object
  36798. */
  36799. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  36800. }
  36801. }
  36802. declare module BABYLON {
  36803. /**
  36804. * Class used to serialize a scene into a string
  36805. */
  36806. class SceneSerializer {
  36807. /**
  36808. * Clear cache used by a previous serialization
  36809. */
  36810. static ClearCache(): void;
  36811. /**
  36812. * Serialize a scene into a JSON compatible object
  36813. * @param scene defines the scene to serialize
  36814. * @returns a JSON compatible object
  36815. */
  36816. static Serialize(scene: Scene): any;
  36817. /**
  36818. * Serialize a mesh into a JSON compatible object
  36819. * @param toSerialize defines the mesh to serialize
  36820. * @param withParents defines if parents must be serialized as well
  36821. * @param withChildren defines if children must be serialized as well
  36822. * @returns a JSON compatible object
  36823. */
  36824. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  36825. }
  36826. }
  36827. declare module BABYLON {
  36828. /**
  36829. * Defines an array and its length.
  36830. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  36831. */
  36832. interface ISmartArrayLike<T> {
  36833. /**
  36834. * The data of the array.
  36835. */
  36836. data: Array<T>;
  36837. /**
  36838. * The active length of the array.
  36839. */
  36840. length: number;
  36841. }
  36842. /**
  36843. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  36844. */
  36845. class SmartArray<T> implements ISmartArrayLike<T> {
  36846. /**
  36847. * The full set of data from the array.
  36848. */
  36849. data: Array<T>;
  36850. /**
  36851. * The active length of the array.
  36852. */
  36853. length: number;
  36854. protected _id: number;
  36855. /**
  36856. * Instantiates a Smart Array.
  36857. * @param capacity defines the default capacity of the array.
  36858. */
  36859. constructor(capacity: number);
  36860. /**
  36861. * Pushes a value at the end of the active data.
  36862. * @param value defines the object to push in the array.
  36863. */
  36864. push(value: T): void;
  36865. /**
  36866. * Iterates over the active data and apply the lambda to them.
  36867. * @param func defines the action to apply on each value.
  36868. */
  36869. forEach(func: (content: T) => void): void;
  36870. /**
  36871. * Sorts the full sets of data.
  36872. * @param compareFn defines the comparison function to apply.
  36873. */
  36874. sort(compareFn: (a: T, b: T) => number): void;
  36875. /**
  36876. * Resets the active data to an empty array.
  36877. */
  36878. reset(): void;
  36879. /**
  36880. * Releases all the data from the array as well as the array.
  36881. */
  36882. dispose(): void;
  36883. /**
  36884. * Concats the active data with a given array.
  36885. * @param array defines the data to concatenate with.
  36886. */
  36887. concat(array: any): void;
  36888. /**
  36889. * Returns the position of a value in the active data.
  36890. * @param value defines the value to find the index for
  36891. * @returns the index if found in the active data otherwise -1
  36892. */
  36893. indexOf(value: T): number;
  36894. /**
  36895. * Returns whether an element is part of the active data.
  36896. * @param value defines the value to look for
  36897. * @returns true if found in the active data otherwise false
  36898. */
  36899. contains(value: T): boolean;
  36900. private static _GlobalId;
  36901. }
  36902. /**
  36903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  36904. * The data in this array can only be present once
  36905. */
  36906. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  36907. private _duplicateId;
  36908. /**
  36909. * Pushes a value at the end of the active data.
  36910. * THIS DOES NOT PREVENT DUPPLICATE DATA
  36911. * @param value defines the object to push in the array.
  36912. */
  36913. push(value: T): void;
  36914. /**
  36915. * Pushes a value at the end of the active data.
  36916. * If the data is already present, it won t be added again
  36917. * @param value defines the object to push in the array.
  36918. * @returns true if added false if it was already present
  36919. */
  36920. pushNoDuplicate(value: T): boolean;
  36921. /**
  36922. * Resets the active data to an empty array.
  36923. */
  36924. reset(): void;
  36925. /**
  36926. * Concats the active data with a given array.
  36927. * This ensures no dupplicate will be present in the result.
  36928. * @param array defines the data to concatenate with.
  36929. */
  36930. concatWithNoDuplicate(array: any): void;
  36931. }
  36932. }
  36933. declare module BABYLON {
  36934. /**
  36935. * This class implement a typical dictionary using a string as key and the generic type T as value.
  36936. * The underlying implementation relies on an associative array to ensure the best performances.
  36937. * The value can be anything including 'null' but except 'undefined'
  36938. */
  36939. class StringDictionary<T> {
  36940. /**
  36941. * This will clear this dictionary and copy the content from the 'source' one.
  36942. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  36943. * @param source the dictionary to take the content from and copy to this dictionary
  36944. */
  36945. copyFrom(source: StringDictionary<T>): void;
  36946. /**
  36947. * Get a value based from its key
  36948. * @param key the given key to get the matching value from
  36949. * @return the value if found, otherwise undefined is returned
  36950. */
  36951. get(key: string): T | undefined;
  36952. /**
  36953. * Get a value from its key or add it if it doesn't exist.
  36954. * This method will ensure you that a given key/data will be present in the dictionary.
  36955. * @param key the given key to get the matching value from
  36956. * @param factory the factory that will create the value if the key is not present in the dictionary.
  36957. * The factory will only be invoked if there's no data for the given key.
  36958. * @return the value corresponding to the key.
  36959. */
  36960. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  36961. /**
  36962. * Get a value from its key if present in the dictionary otherwise add it
  36963. * @param key the key to get the value from
  36964. * @param val if there's no such key/value pair in the dictionary add it with this value
  36965. * @return the value corresponding to the key
  36966. */
  36967. getOrAdd(key: string, val: T): T;
  36968. /**
  36969. * Check if there's a given key in the dictionary
  36970. * @param key the key to check for
  36971. * @return true if the key is present, false otherwise
  36972. */
  36973. contains(key: string): boolean;
  36974. /**
  36975. * Add a new key and its corresponding value
  36976. * @param key the key to add
  36977. * @param value the value corresponding to the key
  36978. * @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
  36979. */
  36980. add(key: string, value: T): boolean;
  36981. set(key: string, value: T): boolean;
  36982. /**
  36983. * Get the element of the given key and remove it from the dictionary
  36984. * @param key
  36985. */
  36986. getAndRemove(key: string): Nullable<T>;
  36987. /**
  36988. * Remove a key/value from the dictionary.
  36989. * @param key the key to remove
  36990. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36991. */
  36992. remove(key: string): boolean;
  36993. /**
  36994. * Clear the whole content of the dictionary
  36995. */
  36996. clear(): void;
  36997. readonly count: number;
  36998. /**
  36999. * Execute a callback on each key/val of the dictionary.
  37000. * Note that you can remove any element in this dictionary in the callback implementation
  37001. * @param callback the callback to execute on a given key/value pair
  37002. */
  37003. forEach(callback: (key: string, val: T) => void): void;
  37004. /**
  37005. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37006. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37007. * Note that you can remove any element in this dictionary in the callback implementation
  37008. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37009. */
  37010. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37011. private _count;
  37012. private _data;
  37013. }
  37014. }
  37015. declare module BABYLON {
  37016. /**
  37017. * Class used to store custom tags
  37018. */
  37019. class Tags {
  37020. /**
  37021. * Adds support for tags on the given object
  37022. * @param obj defines the object to use
  37023. */
  37024. static EnableFor(obj: any): void;
  37025. /**
  37026. * Removes tags support
  37027. * @param obj defines the object to use
  37028. */
  37029. static DisableFor(obj: any): void;
  37030. /**
  37031. * Gets a boolean indicating if the given object has tags
  37032. * @param obj defines the object to use
  37033. * @returns a boolean
  37034. */
  37035. static HasTags(obj: any): boolean;
  37036. /**
  37037. * Gets the tags available on a given object
  37038. * @param obj defines the object to use
  37039. * @param asString defines if the tags must be returned as a string instead of an array of strings
  37040. * @returns the tags
  37041. */
  37042. static GetTags(obj: any, asString?: boolean): any;
  37043. /**
  37044. * Adds tags to an object
  37045. * @param obj defines the object to use
  37046. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  37047. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  37048. */
  37049. static AddTagsTo(obj: any, tagsString: string): void;
  37050. /**
  37051. * @hidden
  37052. */
  37053. static _AddTagTo(obj: any, tag: string): void;
  37054. /**
  37055. * Removes specific tags from a specific object
  37056. * @param obj defines the object to use
  37057. * @param tagsString defines the tags to remove
  37058. */
  37059. static RemoveTagsFrom(obj: any, tagsString: string): void;
  37060. /**
  37061. * @hidden
  37062. */
  37063. static _RemoveTagFrom(obj: any, tag: string): void;
  37064. /**
  37065. * Defines if tags hosted on an object match a given query
  37066. * @param obj defines the object to use
  37067. * @param tagsQuery defines the tag query
  37068. * @returns a boolean
  37069. */
  37070. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  37071. }
  37072. }
  37073. declare module BABYLON {
  37074. /**
  37075. * Class used to host texture specific utilities
  37076. */
  37077. class TextureTools {
  37078. /**
  37079. * Uses the GPU to create a copy texture rescaled at a given size
  37080. * @param texture Texture to copy from
  37081. * @param width defines the desired width
  37082. * @param height defines the desired height
  37083. * @param useBilinearMode defines if bilinear mode has to be used
  37084. * @return the generated texture
  37085. */
  37086. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  37087. /**
  37088. * Gets an environment BRDF texture for a given scene
  37089. * @param scene defines the hosting scene
  37090. * @returns the environment BRDF texture
  37091. */
  37092. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  37093. private static _environmentBRDFBase64Texture;
  37094. }
  37095. }
  37096. declare module BABYLON {
  37097. /**
  37098. * Based on jsTGALoader - Javascript loader for TGA file
  37099. * By Vincent Thibault
  37100. * @see http://blog.robrowser.com/javascript-tga-loader.html
  37101. */
  37102. class TGATools {
  37103. private static _TYPE_INDEXED;
  37104. private static _TYPE_RGB;
  37105. private static _TYPE_GREY;
  37106. private static _TYPE_RLE_INDEXED;
  37107. private static _TYPE_RLE_RGB;
  37108. private static _TYPE_RLE_GREY;
  37109. private static _ORIGIN_MASK;
  37110. private static _ORIGIN_SHIFT;
  37111. private static _ORIGIN_BL;
  37112. private static _ORIGIN_BR;
  37113. private static _ORIGIN_UL;
  37114. private static _ORIGIN_UR;
  37115. /**
  37116. * Gets the header of a TGA file
  37117. * @param data defines the TGA data
  37118. * @returns the header
  37119. */
  37120. static GetTGAHeader(data: Uint8Array): any;
  37121. /**
  37122. * Uploads TGA content to a Babylon Texture
  37123. * @hidden
  37124. */
  37125. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  37126. /** @hidden */
  37127. 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;
  37128. /** @hidden */
  37129. 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;
  37130. /** @hidden */
  37131. 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;
  37132. /** @hidden */
  37133. 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;
  37134. /** @hidden */
  37135. 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;
  37136. /** @hidden */
  37137. 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;
  37138. }
  37139. }
  37140. declare module BABYLON {
  37141. /**
  37142. * Interface containing an array of animations
  37143. */
  37144. interface IAnimatable {
  37145. /**
  37146. * Array of animations
  37147. */
  37148. animations: Array<Animation>;
  37149. }
  37150. /** Interface used by value gradients (color, factor, ...) */
  37151. interface IValueGradient {
  37152. /**
  37153. * Gets or sets the gradient value (between 0 and 1)
  37154. */
  37155. gradient: number;
  37156. }
  37157. /** Class used to store color4 gradient */
  37158. class ColorGradient implements IValueGradient {
  37159. /**
  37160. * Gets or sets the gradient value (between 0 and 1)
  37161. */
  37162. gradient: number;
  37163. /**
  37164. * Gets or sets first associated color
  37165. */
  37166. color1: Color4;
  37167. /**
  37168. * Gets or sets second associated color
  37169. */
  37170. color2?: Color4;
  37171. /**
  37172. * Will get a color picked randomly between color1 and color2.
  37173. * If color2 is undefined then color1 will be used
  37174. * @param result defines the target Color4 to store the result in
  37175. */
  37176. getColorToRef(result: Color4): void;
  37177. }
  37178. /** Class used to store color 3 gradient */
  37179. class Color3Gradient implements IValueGradient {
  37180. /**
  37181. * Gets or sets the gradient value (between 0 and 1)
  37182. */
  37183. gradient: number;
  37184. /**
  37185. * Gets or sets the associated color
  37186. */
  37187. color: Color3;
  37188. }
  37189. /** Class used to store factor gradient */
  37190. class FactorGradient implements IValueGradient {
  37191. /**
  37192. * Gets or sets the gradient value (between 0 and 1)
  37193. */
  37194. gradient: number;
  37195. /**
  37196. * Gets or sets first associated factor
  37197. */
  37198. factor1: number;
  37199. /**
  37200. * Gets or sets second associated factor
  37201. */
  37202. factor2?: number;
  37203. /**
  37204. * Will get a number picked randomly between factor1 and factor2.
  37205. * If factor2 is undefined then factor1 will be used
  37206. * @returns the picked number
  37207. */
  37208. getFactor(): number;
  37209. }
  37210. /**
  37211. * Application error to support additional information when loading a file
  37212. */
  37213. class LoadFileError extends Error {
  37214. request?: XMLHttpRequest | undefined;
  37215. private static _setPrototypeOf;
  37216. /**
  37217. * Creates a new LoadFileError
  37218. * @param message defines the message of the error
  37219. * @param request defines the optional XHR request
  37220. */
  37221. constructor(message: string, request?: XMLHttpRequest | undefined);
  37222. }
  37223. /**
  37224. * Class used to define a retry strategy when error happens while loading assets
  37225. */
  37226. class RetryStrategy {
  37227. /**
  37228. * Function used to defines an exponential back off strategy
  37229. * @param maxRetries defines the maximum number of retries (3 by default)
  37230. * @param baseInterval defines the interval between retries
  37231. * @returns the strategy function to use
  37232. */
  37233. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  37234. }
  37235. /**
  37236. * File request interface
  37237. */
  37238. interface IFileRequest {
  37239. /**
  37240. * Raised when the request is complete (success or error).
  37241. */
  37242. onCompleteObservable: Observable<IFileRequest>;
  37243. /**
  37244. * Aborts the request for a file.
  37245. */
  37246. abort: () => void;
  37247. }
  37248. /**
  37249. * Class containing a set of static utilities functions
  37250. */
  37251. class Tools {
  37252. /**
  37253. * Gets or sets the base URL to use to load assets
  37254. */
  37255. static BaseUrl: string;
  37256. /**
  37257. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37258. */
  37259. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  37260. /**
  37261. * Default behaviour for cors in the application.
  37262. * It can be a string if the expected behavior is identical in the entire app.
  37263. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37264. */
  37265. static CorsBehavior: string | ((url: string | string[]) => string);
  37266. /**
  37267. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37268. * @ignorenaming
  37269. */
  37270. static UseFallbackTexture: boolean;
  37271. /**
  37272. * Use this object to register external classes like custom textures or material
  37273. * to allow the laoders to instantiate them
  37274. */
  37275. static RegisteredExternalClasses: {
  37276. [key: string]: Object;
  37277. };
  37278. /**
  37279. * Texture content used if a texture cannot loaded
  37280. * @ignorenaming
  37281. */
  37282. static fallbackTexture: string;
  37283. /**
  37284. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37285. * @param u defines the coordinate on X axis
  37286. * @param v defines the coordinate on Y axis
  37287. * @param width defines the width of the source data
  37288. * @param height defines the height of the source data
  37289. * @param pixels defines the source byte array
  37290. * @param color defines the output color
  37291. */
  37292. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  37293. /**
  37294. * Interpolates between a and b via alpha
  37295. * @param a The lower value (returned when alpha = 0)
  37296. * @param b The upper value (returned when alpha = 1)
  37297. * @param alpha The interpolation-factor
  37298. * @return The mixed value
  37299. */
  37300. static Mix(a: number, b: number, alpha: number): number;
  37301. /**
  37302. * Tries to instantiate a new object from a given class name
  37303. * @param className defines the class name to instantiate
  37304. * @returns the new object or null if the system was not able to do the instantiation
  37305. */
  37306. static Instantiate(className: string): any;
  37307. /**
  37308. * Provides a slice function that will work even on IE
  37309. * @param data defines the array to slice
  37310. * @param start defines the start of the data (optional)
  37311. * @param end defines the end of the data (optional)
  37312. * @returns the new sliced array
  37313. */
  37314. static Slice<T>(data: T, start?: number, end?: number): T;
  37315. /**
  37316. * Polyfill for setImmediate
  37317. * @param action defines the action to execute after the current execution block
  37318. */
  37319. static SetImmediate(action: () => void): void;
  37320. /**
  37321. * Function indicating if a number is an exponent of 2
  37322. * @param value defines the value to test
  37323. * @returns true if the value is an exponent of 2
  37324. */
  37325. static IsExponentOfTwo(value: number): boolean;
  37326. private static _tmpFloatArray;
  37327. /**
  37328. * Returns the nearest 32-bit single precision float representation of a Number
  37329. * @param value A Number. If the parameter is of a different type, it will get converted
  37330. * to a number or to NaN if it cannot be converted
  37331. * @returns number
  37332. */
  37333. static FloatRound(value: number): number;
  37334. /**
  37335. * Find the next highest power of two.
  37336. * @param x Number to start search from.
  37337. * @return Next highest power of two.
  37338. */
  37339. static CeilingPOT(x: number): number;
  37340. /**
  37341. * Find the next lowest power of two.
  37342. * @param x Number to start search from.
  37343. * @return Next lowest power of two.
  37344. */
  37345. static FloorPOT(x: number): number;
  37346. /**
  37347. * Find the nearest power of two.
  37348. * @param x Number to start search from.
  37349. * @return Next nearest power of two.
  37350. */
  37351. static NearestPOT(x: number): number;
  37352. /**
  37353. * Get the closest exponent of two
  37354. * @param value defines the value to approximate
  37355. * @param max defines the maximum value to return
  37356. * @param mode defines how to define the closest value
  37357. * @returns closest exponent of two of the given value
  37358. */
  37359. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37360. /**
  37361. * Extracts the filename from a path
  37362. * @param path defines the path to use
  37363. * @returns the filename
  37364. */
  37365. static GetFilename(path: string): string;
  37366. /**
  37367. * Extracts the "folder" part of a path (everything before the filename).
  37368. * @param uri The URI to extract the info from
  37369. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37370. * @returns The "folder" part of the path
  37371. */
  37372. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37373. /**
  37374. * Extracts text content from a DOM element hierarchy
  37375. * @param element defines the root element
  37376. * @returns a string
  37377. */
  37378. static GetDOMTextContent(element: HTMLElement): string;
  37379. /**
  37380. * Convert an angle in radians to degrees
  37381. * @param angle defines the angle to convert
  37382. * @returns the angle in degrees
  37383. */
  37384. static ToDegrees(angle: number): number;
  37385. /**
  37386. * Convert an angle in degrees to radians
  37387. * @param angle defines the angle to convert
  37388. * @returns the angle in radians
  37389. */
  37390. static ToRadians(angle: number): number;
  37391. /**
  37392. * Encode a buffer to a base64 string
  37393. * @param buffer defines the buffer to encode
  37394. * @returns the encoded string
  37395. */
  37396. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  37397. /**
  37398. * Extracts minimum and maximum values from a list of indexed positions
  37399. * @param positions defines the positions to use
  37400. * @param indices defines the indices to the positions
  37401. * @param indexStart defines the start index
  37402. * @param indexCount defines the end index
  37403. * @param bias defines bias value to add to the result
  37404. * @return minimum and maximum values
  37405. */
  37406. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  37407. minimum: Vector3;
  37408. maximum: Vector3;
  37409. };
  37410. /**
  37411. * Extracts minimum and maximum values from a list of positions
  37412. * @param positions defines the positions to use
  37413. * @param start defines the start index in the positions array
  37414. * @param count defines the number of positions to handle
  37415. * @param bias defines bias value to add to the result
  37416. * @param stride defines the stride size to use (distance between two positions in the positions array)
  37417. * @return minimum and maximum values
  37418. */
  37419. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  37420. minimum: Vector3;
  37421. maximum: Vector3;
  37422. };
  37423. /**
  37424. * Returns an array if obj is not an array
  37425. * @param obj defines the object to evaluate as an array
  37426. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37427. * @returns either obj directly if obj is an array or a new array containing obj
  37428. */
  37429. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37430. /**
  37431. * Gets the pointer prefix to use
  37432. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37433. */
  37434. static GetPointerPrefix(): string;
  37435. /**
  37436. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37437. * @param func - the function to be called
  37438. * @param requester - the object that will request the next frame. Falls back to window.
  37439. * @returns frame number
  37440. */
  37441. static QueueNewFrame(func: () => void, requester?: any): number;
  37442. /**
  37443. * Ask the browser to promote the current element to fullscreen rendering mode
  37444. * @param element defines the DOM element to promote
  37445. */
  37446. static RequestFullscreen(element: HTMLElement): void;
  37447. /**
  37448. * Asks the browser to exit fullscreen mode
  37449. */
  37450. static ExitFullscreen(): void;
  37451. /**
  37452. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37453. * @param url define the url we are trying
  37454. * @param element define the dom element where to configure the cors policy
  37455. */
  37456. static SetCorsBehavior(url: string | string[], element: {
  37457. crossOrigin: string | null;
  37458. }): void;
  37459. /**
  37460. * Removes unwanted characters from an url
  37461. * @param url defines the url to clean
  37462. * @returns the cleaned url
  37463. */
  37464. static CleanUrl(url: string): string;
  37465. /**
  37466. * Gets or sets a function used to pre-process url before using them to load assets
  37467. */
  37468. static PreprocessUrl: (url: string) => string;
  37469. /**
  37470. * Loads an image as an HTMLImageElement.
  37471. * @param input url string, ArrayBuffer, or Blob to load
  37472. * @param onLoad callback called when the image successfully loads
  37473. * @param onError callback called when the image fails to load
  37474. * @param database database for caching
  37475. * @returns the HTMLImageElement of the loaded image
  37476. */
  37477. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  37478. /**
  37479. * Loads a file
  37480. * @param url url string, ArrayBuffer, or Blob to load
  37481. * @param onSuccess callback called when the file successfully loads
  37482. * @param onProgress callback called while file is loading (if the server supports this mode)
  37483. * @param database database for caching
  37484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37485. * @param onError callback called when the file fails to load
  37486. * @returns a file request object
  37487. */
  37488. 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;
  37489. /**
  37490. * Load a script (identified by an url). When the url returns, the
  37491. * content of this file is added into a new script element, attached to the DOM (body element)
  37492. * @param scriptUrl defines the url of the script to laod
  37493. * @param onSuccess defines the callback called when the script is loaded
  37494. * @param onError defines the callback to call if an error occurs
  37495. */
  37496. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  37497. /**
  37498. * Loads a file from a blob
  37499. * @param fileToLoad defines the blob to use
  37500. * @param callback defines the callback to call when data is loaded
  37501. * @param progressCallback defines the callback to call during loading process
  37502. * @returns a file request object
  37503. */
  37504. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37505. /**
  37506. * Loads a file
  37507. * @param fileToLoad defines the file to load
  37508. * @param callback defines the callback to call when data is loaded
  37509. * @param progressCallBack defines the callback to call during loading process
  37510. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37511. * @returns a file request object
  37512. */
  37513. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  37514. /**
  37515. * Creates a data url from a given string content
  37516. * @param content defines the content to convert
  37517. * @returns the new data url link
  37518. */
  37519. static FileAsURL(content: string): string;
  37520. /**
  37521. * Format the given number to a specific decimal format
  37522. * @param value defines the number to format
  37523. * @param decimals defines the number of decimals to use
  37524. * @returns the formatted string
  37525. */
  37526. static Format(value: number, decimals?: number): string;
  37527. /**
  37528. * Checks if a given vector is inside a specific range
  37529. * @param v defines the vector to test
  37530. * @param min defines the minimum range
  37531. * @param max defines the maximum range
  37532. */
  37533. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  37534. /**
  37535. * Tries to copy an object by duplicating every property
  37536. * @param source defines the source object
  37537. * @param destination defines the target object
  37538. * @param doNotCopyList defines a list of properties to avoid
  37539. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37540. */
  37541. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37542. /**
  37543. * Gets a boolean indicating if the given object has no own property
  37544. * @param obj defines the object to test
  37545. * @returns true if object has no own property
  37546. */
  37547. static IsEmpty(obj: any): boolean;
  37548. /**
  37549. * Function used to register events at window level
  37550. * @param events defines the events to register
  37551. */
  37552. static RegisterTopRootEvents(events: {
  37553. name: string;
  37554. handler: Nullable<(e: FocusEvent) => any>;
  37555. }[]): void;
  37556. /**
  37557. * Function used to unregister events from window level
  37558. * @param events defines the events to unregister
  37559. */
  37560. static UnregisterTopRootEvents(events: {
  37561. name: string;
  37562. handler: Nullable<(e: FocusEvent) => any>;
  37563. }[]): void;
  37564. /**
  37565. * Dumps the current bound framebuffer
  37566. * @param width defines the rendering width
  37567. * @param height defines the rendering height
  37568. * @param engine defines the hosting engine
  37569. * @param successCallback defines the callback triggered once the data are available
  37570. * @param mimeType defines the mime type of the result
  37571. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37572. */
  37573. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37574. /**
  37575. * Converts the canvas data to blob.
  37576. * This acts as a polyfill for browsers not supporting the to blob function.
  37577. * @param canvas Defines the canvas to extract the data from
  37578. * @param successCallback Defines the callback triggered once the data are available
  37579. * @param mimeType Defines the mime type of the result
  37580. */
  37581. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37582. /**
  37583. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37584. * @param successCallback defines the callback triggered once the data are available
  37585. * @param mimeType defines the mime type of the result
  37586. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37587. */
  37588. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37589. /**
  37590. * Downloads a blob in the browser
  37591. * @param blob defines the blob to download
  37592. * @param fileName defines the name of the downloaded file
  37593. */
  37594. static Download(blob: Blob, fileName: string): void;
  37595. /**
  37596. * Captures a screenshot of the current rendering
  37597. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37598. * @param engine defines the rendering engine
  37599. * @param camera defines the source camera
  37600. * @param size This parameter can be set to a single number or to an object with the
  37601. * following (optional) properties: precision, width, height. If a single number is passed,
  37602. * it will be used for both width and height. If an object is passed, the screenshot size
  37603. * will be derived from the parameters. The precision property is a multiplier allowing
  37604. * rendering at a higher or lower resolution
  37605. * @param successCallback defines the callback receives a single parameter which contains the
  37606. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37607. * src parameter of an <img> to display it
  37608. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37609. * Check your browser for supported MIME types
  37610. */
  37611. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  37612. /**
  37613. * Generates an image screenshot from the specified camera.
  37614. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37615. * @param engine The engine to use for rendering
  37616. * @param camera The camera to use for rendering
  37617. * @param size This parameter can be set to a single number or to an object with the
  37618. * following (optional) properties: precision, width, height. If a single number is passed,
  37619. * it will be used for both width and height. If an object is passed, the screenshot size
  37620. * will be derived from the parameters. The precision property is a multiplier allowing
  37621. * rendering at a higher or lower resolution
  37622. * @param successCallback The callback receives a single parameter which contains the
  37623. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37624. * src parameter of an <img> to display it
  37625. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37626. * Check your browser for supported MIME types
  37627. * @param samples Texture samples (default: 1)
  37628. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37629. * @param fileName A name for for the downloaded file.
  37630. */
  37631. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37632. /**
  37633. * Validates if xhr data is correct
  37634. * @param xhr defines the request to validate
  37635. * @param dataType defines the expected data type
  37636. * @returns true if data is correct
  37637. */
  37638. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  37639. /**
  37640. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37641. * Be aware Math.random() could cause collisions, but:
  37642. * "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"
  37643. * @returns a pseudo random id
  37644. */
  37645. static RandomId(): string;
  37646. /**
  37647. * Test if the given uri is a base64 string
  37648. * @param uri The uri to test
  37649. * @return True if the uri is a base64 string or false otherwise
  37650. */
  37651. static IsBase64(uri: string): boolean;
  37652. /**
  37653. * Decode the given base64 uri.
  37654. * @param uri The uri to decode
  37655. * @return The decoded base64 data.
  37656. */
  37657. static DecodeBase64(uri: string): ArrayBuffer;
  37658. /**
  37659. * No log
  37660. */
  37661. static readonly NoneLogLevel: number;
  37662. /**
  37663. * Only message logs
  37664. */
  37665. static readonly MessageLogLevel: number;
  37666. /**
  37667. * Only warning logs
  37668. */
  37669. static readonly WarningLogLevel: number;
  37670. /**
  37671. * Only error logs
  37672. */
  37673. static readonly ErrorLogLevel: number;
  37674. /**
  37675. * All logs
  37676. */
  37677. static readonly AllLogLevel: number;
  37678. private static _LogCache;
  37679. /**
  37680. * Gets a value indicating the number of loading errors
  37681. * @ignorenaming
  37682. */
  37683. static errorsCount: number;
  37684. /**
  37685. * Callback called when a new log is added
  37686. */
  37687. static OnNewCacheEntry: (entry: string) => void;
  37688. private static _AddLogEntry;
  37689. private static _FormatMessage;
  37690. private static _LogDisabled;
  37691. private static _LogEnabled;
  37692. private static _WarnDisabled;
  37693. private static _WarnEnabled;
  37694. private static _ErrorDisabled;
  37695. private static _ErrorEnabled;
  37696. /**
  37697. * Log a message to the console
  37698. */
  37699. static Log: (message: string) => void;
  37700. /**
  37701. * Write a warning message to the console
  37702. */
  37703. static Warn: (message: string) => void;
  37704. /**
  37705. * Write an error message to the console
  37706. */
  37707. static Error: (message: string) => void;
  37708. /**
  37709. * Gets current log cache (list of logs)
  37710. */
  37711. static readonly LogCache: string;
  37712. /**
  37713. * Clears the log cache
  37714. */
  37715. static ClearLogCache(): void;
  37716. /**
  37717. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37718. */
  37719. static LogLevels: number;
  37720. /**
  37721. * Checks if the loaded document was accessed via `file:`-Protocol.
  37722. * @returns boolean
  37723. */
  37724. static IsFileURL(): boolean;
  37725. /**
  37726. * Checks if the window object exists
  37727. * @returns true if the window object exists
  37728. */
  37729. static IsWindowObjectExist(): boolean;
  37730. /**
  37731. * No performance log
  37732. */
  37733. static readonly PerformanceNoneLogLevel: number;
  37734. /**
  37735. * Use user marks to log performance
  37736. */
  37737. static readonly PerformanceUserMarkLogLevel: number;
  37738. /**
  37739. * Log performance to the console
  37740. */
  37741. static readonly PerformanceConsoleLogLevel: number;
  37742. private static _performance;
  37743. /**
  37744. * Sets the current performance log level
  37745. */
  37746. static PerformanceLogLevel: number;
  37747. private static _StartPerformanceCounterDisabled;
  37748. private static _EndPerformanceCounterDisabled;
  37749. private static _StartUserMark;
  37750. private static _EndUserMark;
  37751. private static _StartPerformanceConsole;
  37752. private static _EndPerformanceConsole;
  37753. /**
  37754. * Starts a performance counter
  37755. */
  37756. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37757. /**
  37758. * Ends a specific performance coutner
  37759. */
  37760. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37761. /**
  37762. * Gets either window.performance.now() if supported or Date.now() else
  37763. */
  37764. static readonly Now: number;
  37765. /**
  37766. * This method will return the name of the class used to create the instance of the given object.
  37767. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37768. * @param object the object to get the class name from
  37769. * @param isType defines if the object is actually a type
  37770. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37771. */
  37772. static GetClassName(object: any, isType?: boolean): string;
  37773. /**
  37774. * Gets the first element of an array satisfying a given predicate
  37775. * @param array defines the array to browse
  37776. * @param predicate defines the predicate to use
  37777. * @returns null if not found or the element
  37778. */
  37779. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37780. /**
  37781. * This method will return the name of the full name of the class, including its owning module (if any).
  37782. * 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).
  37783. * @param object the object to get the class name from
  37784. * @param isType defines if the object is actually a type
  37785. * @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.
  37786. * @ignorenaming
  37787. */
  37788. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37789. /**
  37790. * Returns a promise that resolves after the given amount of time.
  37791. * @param delay Number of milliseconds to delay
  37792. * @returns Promise that resolves after the given amount of time
  37793. */
  37794. static DelayAsync(delay: number): Promise<void>;
  37795. /**
  37796. * Gets the current gradient from an array of IValueGradient
  37797. * @param ratio defines the current ratio to get
  37798. * @param gradients defines the array of IValueGradient
  37799. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  37800. */
  37801. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  37802. }
  37803. /**
  37804. * This class is used to track a performance counter which is number based.
  37805. * The user has access to many properties which give statistics of different nature.
  37806. *
  37807. * The implementer can track two kinds of Performance Counter: time and count.
  37808. * 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.
  37809. * 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.
  37810. */
  37811. class PerfCounter {
  37812. /**
  37813. * Gets or sets a global boolean to turn on and off all the counters
  37814. */
  37815. static Enabled: boolean;
  37816. /**
  37817. * Returns the smallest value ever
  37818. */
  37819. readonly min: number;
  37820. /**
  37821. * Returns the biggest value ever
  37822. */
  37823. readonly max: number;
  37824. /**
  37825. * Returns the average value since the performance counter is running
  37826. */
  37827. readonly average: number;
  37828. /**
  37829. * Returns the average value of the last second the counter was monitored
  37830. */
  37831. readonly lastSecAverage: number;
  37832. /**
  37833. * Returns the current value
  37834. */
  37835. readonly current: number;
  37836. /**
  37837. * Gets the accumulated total
  37838. */
  37839. readonly total: number;
  37840. /**
  37841. * Gets the total value count
  37842. */
  37843. readonly count: number;
  37844. /**
  37845. * Creates a new counter
  37846. */
  37847. constructor();
  37848. /**
  37849. * Call this method to start monitoring a new frame.
  37850. * 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.
  37851. */
  37852. fetchNewFrame(): void;
  37853. /**
  37854. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37855. * @param newCount the count value to add to the monitored count
  37856. * @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.
  37857. */
  37858. addCount(newCount: number, fetchResult: boolean): void;
  37859. /**
  37860. * Start monitoring this performance counter
  37861. */
  37862. beginMonitoring(): void;
  37863. /**
  37864. * Compute the time lapsed since the previous beginMonitoring() call.
  37865. * @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
  37866. */
  37867. endMonitoring(newFrame?: boolean): void;
  37868. private _fetchResult;
  37869. private _startMonitoringTime;
  37870. private _min;
  37871. private _max;
  37872. private _average;
  37873. private _current;
  37874. private _totalValueCount;
  37875. private _totalAccumulated;
  37876. private _lastSecAverage;
  37877. private _lastSecAccumulated;
  37878. private _lastSecTime;
  37879. private _lastSecValueCount;
  37880. }
  37881. /**
  37882. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37883. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37884. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37885. * @param name The name of the class, case should be preserved
  37886. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37887. */
  37888. function className(name: string, module?: string): (target: Object) => void;
  37889. /**
  37890. * An implementation of a loop for asynchronous functions.
  37891. */
  37892. class AsyncLoop {
  37893. /**
  37894. * Defines the number of iterations for the loop
  37895. */
  37896. iterations: number;
  37897. /**
  37898. * Defines the current index of the loop.
  37899. */
  37900. index: number;
  37901. private _done;
  37902. private _fn;
  37903. private _successCallback;
  37904. /**
  37905. * Constructor.
  37906. * @param iterations the number of iterations.
  37907. * @param func the function to run each iteration
  37908. * @param successCallback the callback that will be called upon succesful execution
  37909. * @param offset starting offset.
  37910. */
  37911. constructor(
  37912. /**
  37913. * Defines the number of iterations for the loop
  37914. */
  37915. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37916. /**
  37917. * Execute the next iteration. Must be called after the last iteration was finished.
  37918. */
  37919. executeNext(): void;
  37920. /**
  37921. * Break the loop and run the success callback.
  37922. */
  37923. breakLoop(): void;
  37924. /**
  37925. * Create and run an async loop.
  37926. * @param iterations the number of iterations.
  37927. * @param fn the function to run each iteration
  37928. * @param successCallback the callback that will be called upon succesful execution
  37929. * @param offset starting offset.
  37930. * @returns the created async loop object
  37931. */
  37932. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37933. /**
  37934. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37935. * @param iterations total number of iterations
  37936. * @param syncedIterations number of synchronous iterations in each async iteration.
  37937. * @param fn the function to call each iteration.
  37938. * @param callback a success call back that will be called when iterating stops.
  37939. * @param breakFunction a break condition (optional)
  37940. * @param timeout timeout settings for the setTimeout function. default - 0.
  37941. * @returns the created async loop object
  37942. */
  37943. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37944. }
  37945. }
  37946. interface HTMLCanvasElement {
  37947. /** Track wether a record is in progress */
  37948. isRecording: boolean;
  37949. /** Capture Stream method defined by some browsers */
  37950. captureStream(fps?: number): MediaStream;
  37951. }
  37952. interface MediaRecorder {
  37953. /** Starts recording */
  37954. start(timeSlice: number): void;
  37955. /** Stops recording */
  37956. stop(): void;
  37957. /** Event raised when an error arised. */
  37958. onerror: (event: ErrorEvent) => void;
  37959. /** Event raised when the recording stops. */
  37960. onstop: (event: Event) => void;
  37961. /** Event raised when a new chunk of data is available and should be tracked. */
  37962. ondataavailable: (event: Event) => void;
  37963. }
  37964. interface MediaRecorderOptions {
  37965. /** The mime type you want to use as the recording container for the new MediaRecorder */
  37966. mimeType?: string;
  37967. /** The chosen bitrate for the audio component of the media. */
  37968. audioBitsPerSecond?: number;
  37969. /** The chosen bitrate for the video component of the media. */
  37970. videoBitsPerSecond?: number;
  37971. /** 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. */
  37972. bitsPerSecond?: number;
  37973. }
  37974. interface MediaRecorderConstructor {
  37975. /**
  37976. * A reference to the prototype.
  37977. */
  37978. readonly prototype: MediaRecorder;
  37979. /**
  37980. * Creates a new MediaRecorder.
  37981. * @param stream Defines the stream to record.
  37982. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  37983. */
  37984. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  37985. }
  37986. /**
  37987. * MediaRecoreder object available in some browsers.
  37988. */
  37989. declare var MediaRecorder: MediaRecorderConstructor;
  37990. declare module BABYLON {
  37991. /**
  37992. * This represents the different options avilable for the video capture.
  37993. */
  37994. interface VideoRecorderOptions {
  37995. /** Defines the mime type of the video */
  37996. mimeType: string;
  37997. /** Defines the video the video should be recorded at */
  37998. fps: number;
  37999. /** Defines the chunk size for the recording data */
  38000. recordChunckSize: number;
  38001. }
  38002. /**
  38003. * This can helps recording videos from BabylonJS.
  38004. * This is based on the available WebRTC functionalities of the browser.
  38005. *
  38006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  38007. */
  38008. class VideoRecorder {
  38009. private static readonly _defaultOptions;
  38010. /**
  38011. * Returns wehther or not the VideoRecorder is available in your browser.
  38012. * @param engine Defines the Babylon Engine to check the support for
  38013. * @returns true if supported otherwise false
  38014. */
  38015. static IsSupported(engine: Engine): boolean;
  38016. private readonly _options;
  38017. private _canvas;
  38018. private _mediaRecorder;
  38019. private _recordedChunks;
  38020. private _fileName;
  38021. private _resolve;
  38022. private _reject;
  38023. /**
  38024. * True wether a recording is already in progress.
  38025. */
  38026. readonly isRecording: boolean;
  38027. /**
  38028. * Create a new VideoCapture object which can help converting what you see in Babylon to
  38029. * a video file.
  38030. * @param engine Defines the BabylonJS Engine you wish to record
  38031. * @param options Defines options that can be used to customized the capture
  38032. */
  38033. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  38034. /**
  38035. * Stops the current recording before the default capture timeout passed in the startRecording
  38036. * functions.
  38037. */
  38038. stopRecording(): void;
  38039. /**
  38040. * Starts recording the canvas for a max duration specified in parameters.
  38041. * @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.
  38042. * @param maxDuration Defines the maximum recording time in seconds.
  38043. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  38044. * @return a promise callback at the end of the recording with the video data in Blob.
  38045. */
  38046. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  38047. /**
  38048. * Releases internal resources used during the recording.
  38049. */
  38050. dispose(): void;
  38051. private _handleDataAvailable;
  38052. private _handleError;
  38053. private _handleStop;
  38054. }
  38055. }
  38056. declare module BABYLON {
  38057. /**
  38058. * Defines the potential axis of a Joystick
  38059. */
  38060. enum JoystickAxis {
  38061. /** X axis */
  38062. X = 0,
  38063. /** Y axis */
  38064. Y = 1,
  38065. /** Z axis */
  38066. Z = 2
  38067. }
  38068. /**
  38069. * Class used to define virtual joystick (used in touch mode)
  38070. */
  38071. class VirtualJoystick {
  38072. /**
  38073. * Gets or sets a boolean indicating that left and right values must be inverted
  38074. */
  38075. reverseLeftRight: boolean;
  38076. /**
  38077. * Gets or sets a boolean indicating that up and down values must be inverted
  38078. */
  38079. reverseUpDown: boolean;
  38080. /**
  38081. * Gets the offset value for the position (ie. the change of the position value)
  38082. */
  38083. deltaPosition: Vector3;
  38084. /**
  38085. * Gets a boolean indicating if the virtual joystick was pressed
  38086. */
  38087. pressed: boolean;
  38088. private static _globalJoystickIndex;
  38089. private static vjCanvas;
  38090. private static vjCanvasContext;
  38091. private static vjCanvasWidth;
  38092. private static vjCanvasHeight;
  38093. private static halfWidth;
  38094. private _action;
  38095. private _axisTargetedByLeftAndRight;
  38096. private _axisTargetedByUpAndDown;
  38097. private _joystickSensibility;
  38098. private _inversedSensibility;
  38099. private _joystickPointerID;
  38100. private _joystickColor;
  38101. private _joystickPointerPos;
  38102. private _joystickPreviousPointerPos;
  38103. private _joystickPointerStartPos;
  38104. private _deltaJoystickVector;
  38105. private _leftJoystick;
  38106. private _touches;
  38107. private _onPointerDownHandlerRef;
  38108. private _onPointerMoveHandlerRef;
  38109. private _onPointerUpHandlerRef;
  38110. private _onResize;
  38111. /**
  38112. * Creates a new virtual joystick
  38113. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38114. */
  38115. constructor(leftJoystick?: boolean);
  38116. /**
  38117. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38118. * @param newJoystickSensibility defines the new sensibility
  38119. */
  38120. setJoystickSensibility(newJoystickSensibility: number): void;
  38121. private _onPointerDown;
  38122. private _onPointerMove;
  38123. private _onPointerUp;
  38124. /**
  38125. * Change the color of the virtual joystick
  38126. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38127. */
  38128. setJoystickColor(newColor: string): void;
  38129. /**
  38130. * Defines a callback to call when the joystick is touched
  38131. * @param action defines the callback
  38132. */
  38133. setActionOnTouch(action: () => any): void;
  38134. /**
  38135. * Defines which axis you'd like to control for left & right
  38136. * @param axis defines the axis to use
  38137. */
  38138. setAxisForLeftRight(axis: JoystickAxis): void;
  38139. /**
  38140. * Defines which axis you'd like to control for up & down
  38141. * @param axis defines the axis to use
  38142. */
  38143. setAxisForUpDown(axis: JoystickAxis): void;
  38144. private _drawVirtualJoystick;
  38145. /**
  38146. * Release internal HTML canvas
  38147. */
  38148. releaseCanvas(): void;
  38149. }
  38150. }
  38151. declare module BABYLON {
  38152. /**
  38153. * Helper class to push actions to a pool of workers.
  38154. */
  38155. class WorkerPool implements IDisposable {
  38156. private _workerInfos;
  38157. private _pendingActions;
  38158. /**
  38159. * Constructor
  38160. * @param workers Array of workers to use for actions
  38161. */
  38162. constructor(workers: Array<Worker>);
  38163. /**
  38164. * Terminates all workers and clears any pending actions.
  38165. */
  38166. dispose(): void;
  38167. /**
  38168. * Pushes an action to the worker pool. If all the workers are active, the action will be
  38169. * pended until a worker has completed its action.
  38170. * @param action The action to perform. Call onComplete when the action is complete.
  38171. */
  38172. push(action: (worker: Worker, onComplete: () => void) => void): void;
  38173. private _execute;
  38174. }
  38175. }
  38176. declare module BABYLON {
  38177. /**
  38178. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38179. */
  38180. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  38181. private ui;
  38182. /**
  38183. * The name of the behavior
  38184. */
  38185. name: string;
  38186. /**
  38187. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38188. */
  38189. distanceAwayFromFace: number;
  38190. /**
  38191. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38192. */
  38193. distanceAwayFromBottomOfFace: number;
  38194. private _faceVectors;
  38195. private _target;
  38196. private _scene;
  38197. private _onRenderObserver;
  38198. private _tmpMatrix;
  38199. private _tmpVector;
  38200. /**
  38201. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38202. * @param ui The transform node that should be attched to the mesh
  38203. */
  38204. constructor(ui: BABYLON.TransformNode);
  38205. /**
  38206. * Initializes the behavior
  38207. */
  38208. init(): void;
  38209. private _closestFace;
  38210. private _zeroVector;
  38211. private _lookAtTmpMatrix;
  38212. private _lookAtToRef;
  38213. /**
  38214. * Attaches the AttachToBoxBehavior to the passed in mesh
  38215. * @param target The mesh that the specified node will be attached to
  38216. */
  38217. attach(target: BABYLON.Mesh): void;
  38218. /**
  38219. * Detaches the behavior from the mesh
  38220. */
  38221. detach(): void;
  38222. }
  38223. }
  38224. declare module BABYLON {
  38225. /**
  38226. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38227. */
  38228. class FadeInOutBehavior implements Behavior<Mesh> {
  38229. /**
  38230. * Time in milliseconds to delay before fading in (Default: 0)
  38231. */
  38232. delay: number;
  38233. /**
  38234. * Time in milliseconds for the mesh to fade in (Default: 300)
  38235. */
  38236. fadeInTime: number;
  38237. private _millisecondsPerFrame;
  38238. private _hovered;
  38239. private _hoverValue;
  38240. private _ownerNode;
  38241. /**
  38242. * Instatiates the FadeInOutBehavior
  38243. */
  38244. constructor();
  38245. /**
  38246. * The name of the behavior
  38247. */
  38248. readonly name: string;
  38249. /**
  38250. * Initializes the behavior
  38251. */
  38252. init(): void;
  38253. /**
  38254. * Attaches the fade behavior on the passed in mesh
  38255. * @param ownerNode The mesh that will be faded in/out once attached
  38256. */
  38257. attach(ownerNode: Mesh): void;
  38258. /**
  38259. * Detaches the behavior from the mesh
  38260. */
  38261. detach(): void;
  38262. /**
  38263. * Triggers the mesh to begin fading in or out
  38264. * @param value if the object should fade in or out (true to fade in)
  38265. */
  38266. fadeIn(value: boolean): void;
  38267. private _update;
  38268. private _setAllVisibility;
  38269. }
  38270. }
  38271. declare module BABYLON {
  38272. /**
  38273. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38274. */
  38275. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38276. private _dragBehaviorA;
  38277. private _dragBehaviorB;
  38278. private _startDistance;
  38279. private _initialScale;
  38280. private _targetScale;
  38281. private _ownerNode;
  38282. private _sceneRenderObserver;
  38283. /**
  38284. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38285. */
  38286. constructor();
  38287. /**
  38288. * The name of the behavior
  38289. */
  38290. readonly name: string;
  38291. /**
  38292. * Initializes the behavior
  38293. */
  38294. init(): void;
  38295. private _getCurrentDistance;
  38296. /**
  38297. * Attaches the scale behavior the passed in mesh
  38298. * @param ownerNode The mesh that will be scaled around once attached
  38299. */
  38300. attach(ownerNode: Mesh): void;
  38301. /**
  38302. * Detaches the behavior from the mesh
  38303. */
  38304. detach(): void;
  38305. }
  38306. }
  38307. declare module BABYLON {
  38308. /**
  38309. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38310. */
  38311. class PointerDragBehavior implements Behavior<Mesh> {
  38312. private static _AnyMouseID;
  38313. private _attachedNode;
  38314. private _dragPlane;
  38315. private _scene;
  38316. private _pointerObserver;
  38317. private _beforeRenderObserver;
  38318. private static _planeScene;
  38319. /**
  38320. * 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)
  38321. */
  38322. maxDragAngle: number;
  38323. /**
  38324. * @hidden
  38325. */
  38326. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38327. /**
  38328. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38329. */
  38330. currentDraggingPointerID: number;
  38331. /**
  38332. * The last position where the pointer hit the drag plane in world space
  38333. */
  38334. lastDragPosition: Vector3;
  38335. /**
  38336. * If the behavior is currently in a dragging state
  38337. */
  38338. dragging: boolean;
  38339. /**
  38340. * 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)
  38341. */
  38342. dragDeltaRatio: number;
  38343. /**
  38344. * If the drag plane orientation should be updated during the dragging (Default: true)
  38345. */
  38346. updateDragPlane: boolean;
  38347. private _debugMode;
  38348. private _moving;
  38349. /**
  38350. * Fires each time the attached mesh is dragged with the pointer
  38351. * * delta between last drag position and current drag position in world space
  38352. * * dragDistance along the drag axis
  38353. * * dragPlaneNormal normal of the current drag plane used during the drag
  38354. * * dragPlanePoint in world space where the drag intersects the drag plane
  38355. */
  38356. onDragObservable: Observable<{
  38357. delta: Vector3;
  38358. dragPlanePoint: Vector3;
  38359. dragPlaneNormal: Vector3;
  38360. dragDistance: number;
  38361. pointerId: number;
  38362. }>;
  38363. /**
  38364. * Fires each time a drag begins (eg. mouse down on mesh)
  38365. */
  38366. onDragStartObservable: Observable<{
  38367. dragPlanePoint: Vector3;
  38368. pointerId: number;
  38369. }>;
  38370. /**
  38371. * Fires each time a drag ends (eg. mouse release after drag)
  38372. */
  38373. onDragEndObservable: Observable<{
  38374. dragPlanePoint: Vector3;
  38375. pointerId: number;
  38376. }>;
  38377. /**
  38378. * If the attached mesh should be moved when dragged
  38379. */
  38380. moveAttached: boolean;
  38381. /**
  38382. * If the drag behavior will react to drag events (Default: true)
  38383. */
  38384. enabled: boolean;
  38385. /**
  38386. * If camera controls should be detached during the drag
  38387. */
  38388. detachCameraControls: boolean;
  38389. /**
  38390. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38391. */
  38392. useObjectOrienationForDragging: boolean;
  38393. private _options;
  38394. /**
  38395. * Creates a pointer drag behavior that can be attached to a mesh
  38396. * @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)
  38397. */
  38398. constructor(options?: {
  38399. dragAxis?: Vector3;
  38400. dragPlaneNormal?: Vector3;
  38401. });
  38402. /**
  38403. * The name of the behavior
  38404. */
  38405. readonly name: string;
  38406. /**
  38407. * Initializes the behavior
  38408. */
  38409. init(): void;
  38410. private _tmpVector;
  38411. private _alternatePickedPoint;
  38412. private _worldDragAxis;
  38413. private _targetPosition;
  38414. private _attachedElement;
  38415. /**
  38416. * Attaches the drag behavior the passed in mesh
  38417. * @param ownerNode The mesh that will be dragged around once attached
  38418. */
  38419. attach(ownerNode: Mesh): void;
  38420. /**
  38421. * Force relase the drag action by code.
  38422. */
  38423. releaseDrag(): void;
  38424. private _startDragRay;
  38425. private _lastPointerRay;
  38426. /**
  38427. * Simulates the start of a pointer drag event on the behavior
  38428. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38429. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38430. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38431. */
  38432. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38433. private _startDrag;
  38434. private _dragDelta;
  38435. private _moveDrag;
  38436. private _pickWithRayOnDragPlane;
  38437. private _pointA;
  38438. private _pointB;
  38439. private _pointC;
  38440. private _lineA;
  38441. private _lineB;
  38442. private _localAxis;
  38443. private _lookAt;
  38444. private _updateDragPlanePosition;
  38445. /**
  38446. * Detaches the behavior from the mesh
  38447. */
  38448. detach(): void;
  38449. }
  38450. }
  38451. declare module BABYLON {
  38452. /**
  38453. * 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
  38454. */
  38455. class SixDofDragBehavior implements Behavior<Mesh> {
  38456. private static _virtualScene;
  38457. private _ownerNode;
  38458. private _sceneRenderObserver;
  38459. private _scene;
  38460. private _targetPosition;
  38461. private _virtualOriginMesh;
  38462. private _virtualDragMesh;
  38463. private _pointerObserver;
  38464. private _moving;
  38465. private _startingOrientation;
  38466. /**
  38467. * 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)
  38468. */
  38469. private zDragFactor;
  38470. /**
  38471. * If the behavior is currently in a dragging state
  38472. */
  38473. dragging: boolean;
  38474. /**
  38475. * 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)
  38476. */
  38477. dragDeltaRatio: number;
  38478. /**
  38479. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38480. */
  38481. currentDraggingPointerID: number;
  38482. /**
  38483. * If camera controls should be detached during the drag
  38484. */
  38485. detachCameraControls: boolean;
  38486. /**
  38487. * Fires each time a drag starts
  38488. */
  38489. onDragStartObservable: Observable<{}>;
  38490. /**
  38491. * Fires each time a drag ends (eg. mouse release after drag)
  38492. */
  38493. onDragEndObservable: Observable<{}>;
  38494. /**
  38495. * 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
  38496. */
  38497. constructor();
  38498. /**
  38499. * The name of the behavior
  38500. */
  38501. readonly name: string;
  38502. /**
  38503. * Initializes the behavior
  38504. */
  38505. init(): void;
  38506. /**
  38507. * Attaches the scale behavior the passed in mesh
  38508. * @param ownerNode The mesh that will be scaled around once attached
  38509. */
  38510. attach(ownerNode: Mesh): void;
  38511. /**
  38512. * Detaches the behavior from the mesh
  38513. */
  38514. detach(): void;
  38515. }
  38516. }
  38517. declare module BABYLON {
  38518. /**
  38519. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38520. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38521. */
  38522. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38523. /**
  38524. * Gets the name of the behavior.
  38525. */
  38526. readonly name: string;
  38527. private _zoomStopsAnimation;
  38528. private _idleRotationSpeed;
  38529. private _idleRotationWaitTime;
  38530. private _idleRotationSpinupTime;
  38531. /**
  38532. * Sets the flag that indicates if user zooming should stop animation.
  38533. */
  38534. /**
  38535. * Gets the flag that indicates if user zooming should stop animation.
  38536. */
  38537. zoomStopsAnimation: boolean;
  38538. /**
  38539. * Sets the default speed at which the camera rotates around the model.
  38540. */
  38541. /**
  38542. * Gets the default speed at which the camera rotates around the model.
  38543. */
  38544. idleRotationSpeed: number;
  38545. /**
  38546. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38547. */
  38548. /**
  38549. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38550. */
  38551. idleRotationWaitTime: number;
  38552. /**
  38553. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38554. */
  38555. /**
  38556. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38557. */
  38558. idleRotationSpinupTime: number;
  38559. /**
  38560. * Gets a value indicating if the camera is currently rotating because of this behavior
  38561. */
  38562. readonly rotationInProgress: boolean;
  38563. private _onPrePointerObservableObserver;
  38564. private _onAfterCheckInputsObserver;
  38565. private _attachedCamera;
  38566. private _isPointerDown;
  38567. private _lastFrameTime;
  38568. private _lastInteractionTime;
  38569. private _cameraRotationSpeed;
  38570. /**
  38571. * Initializes the behavior.
  38572. */
  38573. init(): void;
  38574. /**
  38575. * Attaches the behavior to its arc rotate camera.
  38576. * @param camera Defines the camera to attach the behavior to
  38577. */
  38578. attach(camera: ArcRotateCamera): void;
  38579. /**
  38580. * Detaches the behavior from its current arc rotate camera.
  38581. */
  38582. detach(): void;
  38583. /**
  38584. * Returns true if user is scrolling.
  38585. * @return true if user is scrolling.
  38586. */
  38587. private _userIsZooming;
  38588. private _lastFrameRadius;
  38589. private _shouldAnimationStopForInteraction;
  38590. /**
  38591. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38592. */
  38593. private _applyUserInteraction;
  38594. private _userIsMoving;
  38595. }
  38596. }
  38597. declare module BABYLON {
  38598. /**
  38599. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38600. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38601. */
  38602. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38603. /**
  38604. * Gets the name of the behavior.
  38605. */
  38606. readonly name: string;
  38607. /**
  38608. * The easing function used by animations
  38609. */
  38610. static EasingFunction: BackEase;
  38611. /**
  38612. * The easing mode used by animations
  38613. */
  38614. static EasingMode: number;
  38615. /**
  38616. * The duration of the animation, in milliseconds
  38617. */
  38618. transitionDuration: number;
  38619. /**
  38620. * Length of the distance animated by the transition when lower radius is reached
  38621. */
  38622. lowerRadiusTransitionRange: number;
  38623. /**
  38624. * Length of the distance animated by the transition when upper radius is reached
  38625. */
  38626. upperRadiusTransitionRange: number;
  38627. private _autoTransitionRange;
  38628. /**
  38629. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38630. */
  38631. /**
  38632. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38633. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38634. */
  38635. autoTransitionRange: boolean;
  38636. private _attachedCamera;
  38637. private _onAfterCheckInputsObserver;
  38638. private _onMeshTargetChangedObserver;
  38639. /**
  38640. * Initializes the behavior.
  38641. */
  38642. init(): void;
  38643. /**
  38644. * Attaches the behavior to its arc rotate camera.
  38645. * @param camera Defines the camera to attach the behavior to
  38646. */
  38647. attach(camera: ArcRotateCamera): void;
  38648. /**
  38649. * Detaches the behavior from its current arc rotate camera.
  38650. */
  38651. detach(): void;
  38652. private _radiusIsAnimating;
  38653. private _radiusBounceTransition;
  38654. private _animatables;
  38655. private _cachedWheelPrecision;
  38656. /**
  38657. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38658. * @param radiusLimit The limit to check against.
  38659. * @return Bool to indicate if at limit.
  38660. */
  38661. private _isRadiusAtLimit;
  38662. /**
  38663. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38664. * @param radiusDelta The delta by which to animate to. Can be negative.
  38665. */
  38666. private _applyBoundRadiusAnimation;
  38667. /**
  38668. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38669. */
  38670. protected _clearAnimationLocks(): void;
  38671. /**
  38672. * Stops and removes all animations that have been applied to the camera
  38673. */
  38674. stopAllAnimations(): void;
  38675. }
  38676. }
  38677. declare module BABYLON {
  38678. /**
  38679. * 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.
  38680. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38681. */
  38682. class FramingBehavior implements Behavior<ArcRotateCamera> {
  38683. /**
  38684. * Gets the name of the behavior.
  38685. */
  38686. readonly name: string;
  38687. private _mode;
  38688. private _radiusScale;
  38689. private _positionScale;
  38690. private _defaultElevation;
  38691. private _elevationReturnTime;
  38692. private _elevationReturnWaitTime;
  38693. private _zoomStopsAnimation;
  38694. private _framingTime;
  38695. /**
  38696. * The easing function used by animations
  38697. */
  38698. static EasingFunction: ExponentialEase;
  38699. /**
  38700. * The easing mode used by animations
  38701. */
  38702. static EasingMode: number;
  38703. /**
  38704. * Sets the current mode used by the behavior
  38705. */
  38706. /**
  38707. * Gets current mode used by the behavior.
  38708. */
  38709. mode: number;
  38710. /**
  38711. * Sets the scale applied to the radius (1 by default)
  38712. */
  38713. /**
  38714. * Gets the scale applied to the radius
  38715. */
  38716. radiusScale: number;
  38717. /**
  38718. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38719. */
  38720. /**
  38721. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38722. */
  38723. positionScale: number;
  38724. /**
  38725. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38726. * behaviour is triggered, in radians.
  38727. */
  38728. /**
  38729. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38730. * behaviour is triggered, in radians.
  38731. */
  38732. defaultElevation: number;
  38733. /**
  38734. * Sets the time (in milliseconds) taken to return to the default beta position.
  38735. * Negative value indicates camera should not return to default.
  38736. */
  38737. /**
  38738. * Gets the time (in milliseconds) taken to return to the default beta position.
  38739. * Negative value indicates camera should not return to default.
  38740. */
  38741. elevationReturnTime: number;
  38742. /**
  38743. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38744. */
  38745. /**
  38746. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38747. */
  38748. elevationReturnWaitTime: number;
  38749. /**
  38750. * Sets the flag that indicates if user zooming should stop animation.
  38751. */
  38752. /**
  38753. * Gets the flag that indicates if user zooming should stop animation.
  38754. */
  38755. zoomStopsAnimation: boolean;
  38756. /**
  38757. * Sets the transition time when framing the mesh, in milliseconds
  38758. */
  38759. /**
  38760. * Gets the transition time when framing the mesh, in milliseconds
  38761. */
  38762. framingTime: number;
  38763. /**
  38764. * Define if the behavior should automatically change the configured
  38765. * camera limits and sensibilities.
  38766. */
  38767. autoCorrectCameraLimitsAndSensibility: boolean;
  38768. private _onPrePointerObservableObserver;
  38769. private _onAfterCheckInputsObserver;
  38770. private _onMeshTargetChangedObserver;
  38771. private _attachedCamera;
  38772. private _isPointerDown;
  38773. private _lastInteractionTime;
  38774. /**
  38775. * Initializes the behavior.
  38776. */
  38777. init(): void;
  38778. /**
  38779. * Attaches the behavior to its arc rotate camera.
  38780. * @param camera Defines the camera to attach the behavior to
  38781. */
  38782. attach(camera: ArcRotateCamera): void;
  38783. /**
  38784. * Detaches the behavior from its current arc rotate camera.
  38785. */
  38786. detach(): void;
  38787. private _animatables;
  38788. private _betaIsAnimating;
  38789. private _betaTransition;
  38790. private _radiusTransition;
  38791. private _vectorTransition;
  38792. /**
  38793. * Targets the given mesh and updates zoom level accordingly.
  38794. * @param mesh The mesh to target.
  38795. * @param radius Optional. If a cached radius position already exists, overrides default.
  38796. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38797. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38798. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38799. */
  38800. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38801. /**
  38802. * Targets the given mesh with its children and updates zoom level accordingly.
  38803. * @param mesh The mesh to target.
  38804. * @param radius Optional. If a cached radius position already exists, overrides default.
  38805. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38806. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38807. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38808. */
  38809. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38810. /**
  38811. * Targets the given meshes with their children and updates zoom level accordingly.
  38812. * @param meshes The mesh to target.
  38813. * @param radius Optional. If a cached radius position already exists, overrides default.
  38814. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38815. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38816. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38817. */
  38818. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38819. /**
  38820. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38821. * @param minimumWorld Determines the smaller position of the bounding box extend
  38822. * @param maximumWorld Determines the bigger position of the bounding box extend
  38823. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38824. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38825. */
  38826. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38827. /**
  38828. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38829. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38830. * frustum width.
  38831. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38832. * to fully enclose the mesh in the viewing frustum.
  38833. */
  38834. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38835. /**
  38836. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38837. * is automatically returned to its default position (expected to be above ground plane).
  38838. */
  38839. private _maintainCameraAboveGround;
  38840. /**
  38841. * Returns the frustum slope based on the canvas ratio and camera FOV
  38842. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38843. */
  38844. private _getFrustumSlope;
  38845. /**
  38846. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38847. */
  38848. private _clearAnimationLocks;
  38849. /**
  38850. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38851. */
  38852. private _applyUserInteraction;
  38853. /**
  38854. * Stops and removes all animations that have been applied to the camera
  38855. */
  38856. stopAllAnimations(): void;
  38857. /**
  38858. * Gets a value indicating if the user is moving the camera
  38859. */
  38860. readonly isUserIsMoving: boolean;
  38861. /**
  38862. * The camera can move all the way towards the mesh.
  38863. */
  38864. static IgnoreBoundsSizeMode: number;
  38865. /**
  38866. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38867. */
  38868. static FitFrustumSidesMode: number;
  38869. }
  38870. }
  38871. declare module BABYLON {
  38872. /**
  38873. * Manage the gamepad inputs to control an arc rotate camera.
  38874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38875. */
  38876. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38877. /**
  38878. * Defines the camera the input is attached to.
  38879. */
  38880. camera: ArcRotateCamera;
  38881. /**
  38882. * Defines the gamepad the input is gathering event from.
  38883. */
  38884. gamepad: Nullable<Gamepad>;
  38885. /**
  38886. * Defines the gamepad rotation sensiblity.
  38887. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38888. */
  38889. gamepadRotationSensibility: number;
  38890. /**
  38891. * Defines the gamepad move sensiblity.
  38892. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38893. */
  38894. gamepadMoveSensibility: number;
  38895. private _onGamepadConnectedObserver;
  38896. private _onGamepadDisconnectedObserver;
  38897. /**
  38898. * Attach the input controls to a specific dom element to get the input from.
  38899. * @param element Defines the element the controls should be listened from
  38900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38901. */
  38902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38903. /**
  38904. * Detach the current controls from the specified dom element.
  38905. * @param element Defines the element to stop listening the inputs from
  38906. */
  38907. detachControl(element: Nullable<HTMLElement>): void;
  38908. /**
  38909. * Update the current camera state depending on the inputs that have been used this frame.
  38910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38911. */
  38912. checkInputs(): void;
  38913. /**
  38914. * Gets the class name of the current intput.
  38915. * @returns the class name
  38916. */
  38917. getClassName(): string;
  38918. /**
  38919. * Get the friendly name associated with the input class.
  38920. * @returns the input friendly name
  38921. */
  38922. getSimpleName(): string;
  38923. }
  38924. }
  38925. declare module BABYLON {
  38926. /**
  38927. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38928. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38929. */
  38930. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38931. /**
  38932. * Defines the camera the input is attached to.
  38933. */
  38934. camera: ArcRotateCamera;
  38935. /**
  38936. * Defines the list of key codes associated with the up action (increase alpha)
  38937. */
  38938. keysUp: number[];
  38939. /**
  38940. * Defines the list of key codes associated with the down action (decrease alpha)
  38941. */
  38942. keysDown: number[];
  38943. /**
  38944. * Defines the list of key codes associated with the left action (increase beta)
  38945. */
  38946. keysLeft: number[];
  38947. /**
  38948. * Defines the list of key codes associated with the right action (decrease beta)
  38949. */
  38950. keysRight: number[];
  38951. /**
  38952. * Defines the list of key codes associated with the reset action.
  38953. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38954. */
  38955. keysReset: number[];
  38956. /**
  38957. * Defines the panning sensibility of the inputs.
  38958. * (How fast is the camera paning)
  38959. */
  38960. panningSensibility: number;
  38961. /**
  38962. * Defines the zooming sensibility of the inputs.
  38963. * (How fast is the camera zooming)
  38964. */
  38965. zoomingSensibility: number;
  38966. /**
  38967. * Defines wether maintaining the alt key down switch the movement mode from
  38968. * orientation to zoom.
  38969. */
  38970. useAltToZoom: boolean;
  38971. /**
  38972. * Rotation speed of the camera
  38973. */
  38974. angularSpeed: number;
  38975. private _keys;
  38976. private _ctrlPressed;
  38977. private _altPressed;
  38978. private _onCanvasBlurObserver;
  38979. private _onKeyboardObserver;
  38980. private _engine;
  38981. private _scene;
  38982. /**
  38983. * Attach the input controls to a specific dom element to get the input from.
  38984. * @param element Defines the element the controls should be listened from
  38985. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38986. */
  38987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38988. /**
  38989. * Detach the current controls from the specified dom element.
  38990. * @param element Defines the element to stop listening the inputs from
  38991. */
  38992. detachControl(element: Nullable<HTMLElement>): void;
  38993. /**
  38994. * Update the current camera state depending on the inputs that have been used this frame.
  38995. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38996. */
  38997. checkInputs(): void;
  38998. /**
  38999. * Gets the class name of the current intput.
  39000. * @returns the class name
  39001. */
  39002. getClassName(): string;
  39003. /**
  39004. * Get the friendly name associated with the input class.
  39005. * @returns the input friendly name
  39006. */
  39007. getSimpleName(): string;
  39008. }
  39009. }
  39010. declare module BABYLON {
  39011. /**
  39012. * Manage the mouse wheel inputs to control an arc rotate camera.
  39013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39014. */
  39015. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39016. /**
  39017. * Defines the camera the input is attached to.
  39018. */
  39019. camera: ArcRotateCamera;
  39020. /**
  39021. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39022. */
  39023. wheelPrecision: number;
  39024. /**
  39025. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39026. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39027. */
  39028. wheelDeltaPercentage: number;
  39029. private _wheel;
  39030. private _observer;
  39031. /**
  39032. * Attach the input controls to a specific dom element to get the input from.
  39033. * @param element Defines the element the controls should be listened from
  39034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39035. */
  39036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39037. /**
  39038. * Detach the current controls from the specified dom element.
  39039. * @param element Defines the element to stop listening the inputs from
  39040. */
  39041. detachControl(element: Nullable<HTMLElement>): void;
  39042. /**
  39043. * Gets the class name of the current intput.
  39044. * @returns the class name
  39045. */
  39046. getClassName(): string;
  39047. /**
  39048. * Get the friendly name associated with the input class.
  39049. * @returns the input friendly name
  39050. */
  39051. getSimpleName(): string;
  39052. }
  39053. }
  39054. declare module BABYLON {
  39055. /**
  39056. * Manage the pointers inputs to control an arc rotate camera.
  39057. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39058. */
  39059. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  39060. /**
  39061. * Defines the camera the input is attached to.
  39062. */
  39063. camera: ArcRotateCamera;
  39064. /**
  39065. * Defines the buttons associated with the input to handle camera move.
  39066. */
  39067. buttons: number[];
  39068. /**
  39069. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39070. */
  39071. angularSensibilityX: number;
  39072. /**
  39073. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39074. */
  39075. angularSensibilityY: number;
  39076. /**
  39077. * Defines the pointer pinch precision or how fast is the camera zooming.
  39078. */
  39079. pinchPrecision: number;
  39080. /**
  39081. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  39082. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39083. */
  39084. pinchDeltaPercentage: number;
  39085. /**
  39086. * Defines the pointer panning sensibility or how fast is the camera moving.
  39087. */
  39088. panningSensibility: number;
  39089. /**
  39090. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39091. */
  39092. multiTouchPanning: boolean;
  39093. /**
  39094. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  39095. */
  39096. multiTouchPanAndZoom: boolean;
  39097. /**
  39098. * Revers pinch action direction.
  39099. */
  39100. pinchInwards: boolean;
  39101. private _isPanClick;
  39102. private _pointerInput;
  39103. private _observer;
  39104. private _onMouseMove;
  39105. private _onGestureStart;
  39106. private _onGesture;
  39107. private _MSGestureHandler;
  39108. private _onLostFocus;
  39109. private _onContextMenu;
  39110. /**
  39111. * Attach the input controls to a specific dom element to get the input from.
  39112. * @param element Defines the element the controls should be listened from
  39113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39114. */
  39115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39116. /**
  39117. * Detach the current controls from the specified dom element.
  39118. * @param element Defines the element to stop listening the inputs from
  39119. */
  39120. detachControl(element: Nullable<HTMLElement>): void;
  39121. /**
  39122. * Gets the class name of the current intput.
  39123. * @returns the class name
  39124. */
  39125. getClassName(): string;
  39126. /**
  39127. * Get the friendly name associated with the input class.
  39128. * @returns the input friendly name
  39129. */
  39130. getSimpleName(): string;
  39131. }
  39132. }
  39133. declare module BABYLON {
  39134. /**
  39135. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39137. */
  39138. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39139. /**
  39140. * Defines the camera the input is attached to.
  39141. */
  39142. camera: ArcRotateCamera;
  39143. /**
  39144. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39145. */
  39146. alphaCorrection: number;
  39147. /**
  39148. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  39149. */
  39150. betaCorrection: number;
  39151. /**
  39152. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39153. */
  39154. gammaCorrection: number;
  39155. private _alpha;
  39156. private _gamma;
  39157. private _dirty;
  39158. private _deviceOrientationHandler;
  39159. /**
  39160. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39161. */
  39162. constructor();
  39163. /**
  39164. * Attach the input controls to a specific dom element to get the input from.
  39165. * @param element Defines the element the controls should be listened from
  39166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39167. */
  39168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39169. /** @hidden */
  39170. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39171. /**
  39172. * Update the current camera state depending on the inputs that have been used this frame.
  39173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39174. */
  39175. checkInputs(): void;
  39176. /**
  39177. * Detach the current controls from the specified dom element.
  39178. * @param element Defines the element to stop listening the inputs from
  39179. */
  39180. detachControl(element: Nullable<HTMLElement>): void;
  39181. /**
  39182. * Gets the class name of the current intput.
  39183. * @returns the class name
  39184. */
  39185. getClassName(): string;
  39186. /**
  39187. * Get the friendly name associated with the input class.
  39188. * @returns the input friendly name
  39189. */
  39190. getSimpleName(): string;
  39191. }
  39192. }
  39193. declare module BABYLON {
  39194. /**
  39195. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39196. * Screen rotation is taken into account.
  39197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39198. */
  39199. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39200. private _camera;
  39201. private _screenOrientationAngle;
  39202. private _constantTranform;
  39203. private _screenQuaternion;
  39204. private _alpha;
  39205. private _beta;
  39206. private _gamma;
  39207. /**
  39208. * Instantiates a new input
  39209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39210. */
  39211. constructor();
  39212. /**
  39213. * Define the camera controlled by the input.
  39214. */
  39215. camera: FreeCamera;
  39216. /**
  39217. * Attach the input controls to a specific dom element to get the input from.
  39218. * @param element Defines the element the controls should be listened from
  39219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39220. */
  39221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39222. private _orientationChanged;
  39223. private _deviceOrientation;
  39224. /**
  39225. * Detach the current controls from the specified dom element.
  39226. * @param element Defines the element to stop listening the inputs from
  39227. */
  39228. detachControl(element: Nullable<HTMLElement>): void;
  39229. /**
  39230. * Update the current camera state depending on the inputs that have been used this frame.
  39231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39232. */
  39233. checkInputs(): void;
  39234. /**
  39235. * Gets the class name of the current intput.
  39236. * @returns the class name
  39237. */
  39238. getClassName(): string;
  39239. /**
  39240. * Get the friendly name associated with the input class.
  39241. * @returns the input friendly name
  39242. */
  39243. getSimpleName(): string;
  39244. }
  39245. }
  39246. declare module BABYLON {
  39247. /**
  39248. * Manage the gamepad inputs to control a free camera.
  39249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39250. */
  39251. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39252. /**
  39253. * Define the camera the input is attached to.
  39254. */
  39255. camera: FreeCamera;
  39256. /**
  39257. * Define the Gamepad controlling the input
  39258. */
  39259. gamepad: Nullable<Gamepad>;
  39260. /**
  39261. * Defines the gamepad rotation sensiblity.
  39262. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39263. */
  39264. gamepadAngularSensibility: number;
  39265. /**
  39266. * Defines the gamepad move sensiblity.
  39267. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39268. */
  39269. gamepadMoveSensibility: number;
  39270. private _onGamepadConnectedObserver;
  39271. private _onGamepadDisconnectedObserver;
  39272. private _cameraTransform;
  39273. private _deltaTransform;
  39274. private _vector3;
  39275. private _vector2;
  39276. /**
  39277. * Attach the input controls to a specific dom element to get the input from.
  39278. * @param element Defines the element the controls should be listened from
  39279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39280. */
  39281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39282. /**
  39283. * Detach the current controls from the specified dom element.
  39284. * @param element Defines the element to stop listening the inputs from
  39285. */
  39286. detachControl(element: Nullable<HTMLElement>): void;
  39287. /**
  39288. * Update the current camera state depending on the inputs that have been used this frame.
  39289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39290. */
  39291. checkInputs(): void;
  39292. /**
  39293. * Gets the class name of the current intput.
  39294. * @returns the class name
  39295. */
  39296. getClassName(): string;
  39297. /**
  39298. * Get the friendly name associated with the input class.
  39299. * @returns the input friendly name
  39300. */
  39301. getSimpleName(): string;
  39302. }
  39303. }
  39304. declare module BABYLON {
  39305. /**
  39306. * Manage the keyboard inputs to control the movement of a free camera.
  39307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39308. */
  39309. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  39310. /**
  39311. * Defines the camera the input is attached to.
  39312. */
  39313. camera: FreeCamera;
  39314. /**
  39315. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  39316. */
  39317. keysUp: number[];
  39318. /**
  39319. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  39320. */
  39321. keysDown: number[];
  39322. /**
  39323. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  39324. */
  39325. keysLeft: number[];
  39326. /**
  39327. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  39328. */
  39329. keysRight: number[];
  39330. private _keys;
  39331. private _onCanvasBlurObserver;
  39332. private _onKeyboardObserver;
  39333. private _engine;
  39334. private _scene;
  39335. /**
  39336. * Attach the input controls to a specific dom element to get the input from.
  39337. * @param element Defines the element the controls should be listened from
  39338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39339. */
  39340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39341. /**
  39342. * Detach the current controls from the specified dom element.
  39343. * @param element Defines the element to stop listening the inputs from
  39344. */
  39345. detachControl(element: Nullable<HTMLElement>): void;
  39346. /**
  39347. * Update the current camera state depending on the inputs that have been used this frame.
  39348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39349. */
  39350. checkInputs(): void;
  39351. /**
  39352. * Gets the class name of the current intput.
  39353. * @returns the class name
  39354. */
  39355. getClassName(): string;
  39356. /** @hidden */
  39357. _onLostFocus(e: FocusEvent): void;
  39358. /**
  39359. * Get the friendly name associated with the input class.
  39360. * @returns the input friendly name
  39361. */
  39362. getSimpleName(): string;
  39363. }
  39364. }
  39365. declare module BABYLON {
  39366. /**
  39367. * Manage the mouse inputs to control the movement of a free camera.
  39368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39369. */
  39370. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  39371. /**
  39372. * Define if touch is enabled in the mouse input
  39373. */
  39374. touchEnabled: boolean;
  39375. /**
  39376. * Defines the camera the input is attached to.
  39377. */
  39378. camera: FreeCamera;
  39379. /**
  39380. * Defines the buttons associated with the input to handle camera move.
  39381. */
  39382. buttons: number[];
  39383. /**
  39384. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  39385. */
  39386. angularSensibility: number;
  39387. private _pointerInput;
  39388. private _onMouseMove;
  39389. private _observer;
  39390. private previousPosition;
  39391. /**
  39392. * Manage the mouse inputs to control the movement of a free camera.
  39393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39394. * @param touchEnabled Defines if touch is enabled or not
  39395. */
  39396. constructor(
  39397. /**
  39398. * Define if touch is enabled in the mouse input
  39399. */
  39400. touchEnabled?: boolean);
  39401. /**
  39402. * Attach the input controls to a specific dom element to get the input from.
  39403. * @param element Defines the element the controls should be listened from
  39404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39405. */
  39406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39407. /**
  39408. * Detach the current controls from the specified dom element.
  39409. * @param element Defines the element to stop listening the inputs from
  39410. */
  39411. detachControl(element: Nullable<HTMLElement>): void;
  39412. /**
  39413. * Gets the class name of the current intput.
  39414. * @returns the class name
  39415. */
  39416. getClassName(): string;
  39417. /**
  39418. * Get the friendly name associated with the input class.
  39419. * @returns the input friendly name
  39420. */
  39421. getSimpleName(): string;
  39422. }
  39423. }
  39424. declare module BABYLON {
  39425. /**
  39426. * Manage the touch inputs to control the movement of a free camera.
  39427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39428. */
  39429. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  39430. /**
  39431. * Defines the camera the input is attached to.
  39432. */
  39433. camera: FreeCamera;
  39434. /**
  39435. * Defines the touch sensibility for rotation.
  39436. * The higher the faster.
  39437. */
  39438. touchAngularSensibility: number;
  39439. /**
  39440. * Defines the touch sensibility for move.
  39441. * The higher the faster.
  39442. */
  39443. touchMoveSensibility: number;
  39444. private _offsetX;
  39445. private _offsetY;
  39446. private _pointerPressed;
  39447. private _pointerInput;
  39448. private _observer;
  39449. private _onLostFocus;
  39450. /**
  39451. * Attach the input controls to a specific dom element to get the input from.
  39452. * @param element Defines the element the controls should be listened from
  39453. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39454. */
  39455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39456. /**
  39457. * Detach the current controls from the specified dom element.
  39458. * @param element Defines the element to stop listening the inputs from
  39459. */
  39460. detachControl(element: Nullable<HTMLElement>): void;
  39461. /**
  39462. * Update the current camera state depending on the inputs that have been used this frame.
  39463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39464. */
  39465. checkInputs(): void;
  39466. /**
  39467. * Gets the class name of the current intput.
  39468. * @returns the class name
  39469. */
  39470. getClassName(): string;
  39471. /**
  39472. * Get the friendly name associated with the input class.
  39473. * @returns the input friendly name
  39474. */
  39475. getSimpleName(): string;
  39476. }
  39477. }
  39478. declare module BABYLON {
  39479. /**
  39480. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39482. */
  39483. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39484. /**
  39485. * Defines the camera the input is attached to.
  39486. */
  39487. camera: FreeCamera;
  39488. private _leftjoystick;
  39489. private _rightjoystick;
  39490. /**
  39491. * Gets the left stick of the virtual joystick.
  39492. * @returns The virtual Joystick
  39493. */
  39494. getLeftJoystick(): VirtualJoystick;
  39495. /**
  39496. * Gets the right stick of the virtual joystick.
  39497. * @returns The virtual Joystick
  39498. */
  39499. getRightJoystick(): VirtualJoystick;
  39500. /**
  39501. * Update the current camera state depending on the inputs that have been used this frame.
  39502. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39503. */
  39504. checkInputs(): void;
  39505. /**
  39506. * Attach the input controls to a specific dom element to get the input from.
  39507. * @param element Defines the element the controls should be listened from
  39508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39509. */
  39510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39511. /**
  39512. * Detach the current controls from the specified dom element.
  39513. * @param element Defines the element to stop listening the inputs from
  39514. */
  39515. detachControl(element: Nullable<HTMLElement>): void;
  39516. /**
  39517. * Gets the class name of the current intput.
  39518. * @returns the class name
  39519. */
  39520. getClassName(): string;
  39521. /**
  39522. * Get the friendly name associated with the input class.
  39523. * @returns the input friendly name
  39524. */
  39525. getSimpleName(): string;
  39526. }
  39527. }
  39528. declare module BABYLON {
  39529. /**
  39530. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39531. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39532. */
  39533. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39534. /**
  39535. * Creates a new AnaglyphArcRotateCamera
  39536. * @param name defines camera name
  39537. * @param alpha defines alpha angle (in radians)
  39538. * @param beta defines beta angle (in radians)
  39539. * @param radius defines radius
  39540. * @param target defines camera target
  39541. * @param interaxialDistance defines distance between each color axis
  39542. * @param scene defines the hosting scene
  39543. */
  39544. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39545. /**
  39546. * Gets camera class name
  39547. * @returns AnaglyphArcRotateCamera
  39548. */
  39549. getClassName(): string;
  39550. }
  39551. }
  39552. declare module BABYLON {
  39553. /**
  39554. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39555. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39556. */
  39557. class AnaglyphFreeCamera extends FreeCamera {
  39558. /**
  39559. * Creates a new AnaglyphFreeCamera
  39560. * @param name defines camera name
  39561. * @param position defines initial position
  39562. * @param interaxialDistance defines distance between each color axis
  39563. * @param scene defines the hosting scene
  39564. */
  39565. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39566. /**
  39567. * Gets camera class name
  39568. * @returns AnaglyphFreeCamera
  39569. */
  39570. getClassName(): string;
  39571. }
  39572. }
  39573. declare module BABYLON {
  39574. /**
  39575. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39576. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39577. */
  39578. class AnaglyphGamepadCamera extends GamepadCamera {
  39579. /**
  39580. * Creates a new AnaglyphGamepadCamera
  39581. * @param name defines camera name
  39582. * @param position defines initial position
  39583. * @param interaxialDistance defines distance between each color axis
  39584. * @param scene defines the hosting scene
  39585. */
  39586. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39587. /**
  39588. * Gets camera class name
  39589. * @returns AnaglyphGamepadCamera
  39590. */
  39591. getClassName(): string;
  39592. }
  39593. }
  39594. declare module BABYLON {
  39595. /**
  39596. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39597. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39598. */
  39599. class AnaglyphUniversalCamera extends UniversalCamera {
  39600. /**
  39601. * Creates a new AnaglyphUniversalCamera
  39602. * @param name defines camera name
  39603. * @param position defines initial position
  39604. * @param interaxialDistance defines distance between each color axis
  39605. * @param scene defines the hosting scene
  39606. */
  39607. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39608. /**
  39609. * Gets camera class name
  39610. * @returns AnaglyphUniversalCamera
  39611. */
  39612. getClassName(): string;
  39613. }
  39614. }
  39615. declare module BABYLON {
  39616. /**
  39617. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39618. * @see http://doc.babylonjs.com/features/cameras
  39619. */
  39620. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39621. /**
  39622. * Creates a new StereoscopicArcRotateCamera
  39623. * @param name defines camera name
  39624. * @param alpha defines alpha angle (in radians)
  39625. * @param beta defines beta angle (in radians)
  39626. * @param radius defines radius
  39627. * @param target defines camera target
  39628. * @param interaxialDistance defines distance between each color axis
  39629. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39630. * @param scene defines the hosting scene
  39631. */
  39632. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39633. /**
  39634. * Gets camera class name
  39635. * @returns StereoscopicArcRotateCamera
  39636. */
  39637. getClassName(): string;
  39638. }
  39639. }
  39640. declare module BABYLON {
  39641. /**
  39642. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39643. * @see http://doc.babylonjs.com/features/cameras
  39644. */
  39645. class StereoscopicFreeCamera extends FreeCamera {
  39646. /**
  39647. * Creates a new StereoscopicFreeCamera
  39648. * @param name defines camera name
  39649. * @param position defines initial position
  39650. * @param interaxialDistance defines distance between each color axis
  39651. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39652. * @param scene defines the hosting scene
  39653. */
  39654. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39655. /**
  39656. * Gets camera class name
  39657. * @returns StereoscopicFreeCamera
  39658. */
  39659. getClassName(): string;
  39660. }
  39661. }
  39662. declare module BABYLON {
  39663. /**
  39664. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39665. * @see http://doc.babylonjs.com/features/cameras
  39666. */
  39667. class StereoscopicGamepadCamera extends GamepadCamera {
  39668. /**
  39669. * Creates a new StereoscopicGamepadCamera
  39670. * @param name defines camera name
  39671. * @param position defines initial position
  39672. * @param interaxialDistance defines distance between each color axis
  39673. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39674. * @param scene defines the hosting scene
  39675. */
  39676. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39677. /**
  39678. * Gets camera class name
  39679. * @returns StereoscopicGamepadCamera
  39680. */
  39681. getClassName(): string;
  39682. }
  39683. }
  39684. declare module BABYLON {
  39685. /**
  39686. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39687. * @see http://doc.babylonjs.com/features/cameras
  39688. */
  39689. class StereoscopicUniversalCamera extends UniversalCamera {
  39690. /**
  39691. * Creates a new StereoscopicUniversalCamera
  39692. * @param name defines camera name
  39693. * @param position defines initial position
  39694. * @param interaxialDistance defines distance between each color axis
  39695. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39696. * @param scene defines the hosting scene
  39697. */
  39698. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39699. /**
  39700. * Gets camera class name
  39701. * @returns StereoscopicUniversalCamera
  39702. */
  39703. getClassName(): string;
  39704. }
  39705. }
  39706. declare module BABYLON {
  39707. /**
  39708. * This represents all the required metrics to create a VR camera.
  39709. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39710. */
  39711. class VRCameraMetrics {
  39712. /**
  39713. * Define the horizontal resolution off the screen.
  39714. */
  39715. hResolution: number;
  39716. /**
  39717. * Define the vertical resolution off the screen.
  39718. */
  39719. vResolution: number;
  39720. /**
  39721. * Define the horizontal screen size.
  39722. */
  39723. hScreenSize: number;
  39724. /**
  39725. * Define the vertical screen size.
  39726. */
  39727. vScreenSize: number;
  39728. /**
  39729. * Define the vertical screen center position.
  39730. */
  39731. vScreenCenter: number;
  39732. /**
  39733. * Define the distance of the eyes to the screen.
  39734. */
  39735. eyeToScreenDistance: number;
  39736. /**
  39737. * Define the distance between both lenses
  39738. */
  39739. lensSeparationDistance: number;
  39740. /**
  39741. * Define the distance between both viewer's eyes.
  39742. */
  39743. interpupillaryDistance: number;
  39744. /**
  39745. * Define the distortion factor of the VR postprocess.
  39746. * Please, touch with care.
  39747. */
  39748. distortionK: number[];
  39749. /**
  39750. * Define the chromatic aberration correction factors for the VR post process.
  39751. */
  39752. chromaAbCorrection: number[];
  39753. /**
  39754. * Define the scale factor of the post process.
  39755. * The smaller the better but the slower.
  39756. */
  39757. postProcessScaleFactor: number;
  39758. /**
  39759. * Define an offset for the lens center.
  39760. */
  39761. lensCenterOffset: number;
  39762. /**
  39763. * Define if the current vr camera should compensate the distortion of the lense or not.
  39764. */
  39765. compensateDistortion: boolean;
  39766. /**
  39767. * Gets the rendering aspect ratio based on the provided resolutions.
  39768. */
  39769. readonly aspectRatio: number;
  39770. /**
  39771. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39772. */
  39773. readonly aspectRatioFov: number;
  39774. /**
  39775. * @hidden
  39776. */
  39777. readonly leftHMatrix: Matrix;
  39778. /**
  39779. * @hidden
  39780. */
  39781. readonly rightHMatrix: Matrix;
  39782. /**
  39783. * @hidden
  39784. */
  39785. readonly leftPreViewMatrix: Matrix;
  39786. /**
  39787. * @hidden
  39788. */
  39789. readonly rightPreViewMatrix: Matrix;
  39790. /**
  39791. * Get the default VRMetrics based on the most generic setup.
  39792. * @returns the default vr metrics
  39793. */
  39794. static GetDefault(): VRCameraMetrics;
  39795. }
  39796. }
  39797. declare module BABYLON {
  39798. /**
  39799. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39800. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39801. */
  39802. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39803. /**
  39804. * Creates a new VRDeviceOrientationArcRotateCamera
  39805. * @param name defines camera name
  39806. * @param alpha defines the camera rotation along the logitudinal axis
  39807. * @param beta defines the camera rotation along the latitudinal axis
  39808. * @param radius defines the camera distance from its target
  39809. * @param target defines the camera target
  39810. * @param scene defines the scene the camera belongs to
  39811. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39812. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39813. */
  39814. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39815. /**
  39816. * Gets camera class name
  39817. * @returns VRDeviceOrientationArcRotateCamera
  39818. */
  39819. getClassName(): string;
  39820. }
  39821. }
  39822. declare module BABYLON {
  39823. /**
  39824. * Camera used to simulate VR rendering (based on FreeCamera)
  39825. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39826. */
  39827. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39828. /**
  39829. * Creates a new VRDeviceOrientationFreeCamera
  39830. * @param name defines camera name
  39831. * @param position defines the start position of the camera
  39832. * @param scene defines the scene the camera belongs to
  39833. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39834. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39835. */
  39836. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39837. /**
  39838. * Gets camera class name
  39839. * @returns VRDeviceOrientationFreeCamera
  39840. */
  39841. getClassName(): string;
  39842. }
  39843. }
  39844. declare module BABYLON {
  39845. /**
  39846. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39847. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39848. */
  39849. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39850. /**
  39851. * Creates a new VRDeviceOrientationGamepadCamera
  39852. * @param name defines camera name
  39853. * @param position defines the start position of the camera
  39854. * @param scene defines the scene the camera belongs to
  39855. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39856. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39857. */
  39858. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39859. /**
  39860. * Gets camera class name
  39861. * @returns VRDeviceOrientationGamepadCamera
  39862. */
  39863. getClassName(): string;
  39864. }
  39865. }
  39866. declare module BABYLON {
  39867. /**
  39868. * Options to modify the vr teleportation behavior.
  39869. */
  39870. interface VRTeleportationOptions {
  39871. /**
  39872. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39873. */
  39874. floorMeshName?: string;
  39875. /**
  39876. * A list of meshes to be used as the teleportation floor. (default: empty)
  39877. */
  39878. floorMeshes?: Mesh[];
  39879. }
  39880. /**
  39881. * Options to modify the vr experience helper's behavior.
  39882. */
  39883. interface VRExperienceHelperOptions extends WebVROptions {
  39884. /**
  39885. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39886. */
  39887. createDeviceOrientationCamera?: boolean;
  39888. /**
  39889. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39890. */
  39891. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39892. /**
  39893. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39894. */
  39895. laserToggle?: boolean;
  39896. /**
  39897. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39898. */
  39899. floorMeshes?: Mesh[];
  39900. }
  39901. /**
  39902. * Helps to quickly add VR support to an existing scene.
  39903. * See http://doc.babylonjs.com/how_to/webvr_helper
  39904. */
  39905. class VRExperienceHelper {
  39906. /** Options to modify the vr experience helper's behavior. */
  39907. webVROptions: VRExperienceHelperOptions;
  39908. private _scene;
  39909. private _position;
  39910. private _btnVR;
  39911. private _btnVRDisplayed;
  39912. private _webVRsupported;
  39913. private _webVRready;
  39914. private _webVRrequesting;
  39915. private _webVRpresenting;
  39916. private _hasEnteredVR;
  39917. private _fullscreenVRpresenting;
  39918. private _canvas;
  39919. private _webVRCamera;
  39920. private _vrDeviceOrientationCamera;
  39921. private _deviceOrientationCamera;
  39922. private _existingCamera;
  39923. private _onKeyDown;
  39924. private _onVrDisplayPresentChange;
  39925. private _onVRDisplayChanged;
  39926. private _onVRRequestPresentStart;
  39927. private _onVRRequestPresentComplete;
  39928. /**
  39929. * Observable raised when entering VR.
  39930. */
  39931. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39932. /**
  39933. * Observable raised when exiting VR.
  39934. */
  39935. onExitingVRObservable: Observable<VRExperienceHelper>;
  39936. /**
  39937. * Observable raised when controller mesh is loaded.
  39938. */
  39939. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39940. /** Return this.onEnteringVRObservable
  39941. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39942. */
  39943. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39944. /** Return this.onExitingVRObservable
  39945. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39946. */
  39947. readonly onExitingVR: Observable<VRExperienceHelper>;
  39948. /** Return this.onControllerMeshLoadedObservable
  39949. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39950. */
  39951. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39952. private _rayLength;
  39953. private _useCustomVRButton;
  39954. private _teleportationRequested;
  39955. private _teleportActive;
  39956. private _floorMeshName;
  39957. private _floorMeshesCollection;
  39958. private _rotationAllowed;
  39959. private _teleportBackwardsVector;
  39960. private _teleportationTarget;
  39961. private _isDefaultTeleportationTarget;
  39962. private _postProcessMove;
  39963. private _teleportationFillColor;
  39964. private _teleportationBorderColor;
  39965. private _rotationAngle;
  39966. private _haloCenter;
  39967. private _cameraGazer;
  39968. private _padSensibilityUp;
  39969. private _padSensibilityDown;
  39970. private _leftController;
  39971. private _rightController;
  39972. /**
  39973. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39974. */
  39975. onNewMeshSelected: Observable<AbstractMesh>;
  39976. /**
  39977. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39978. */
  39979. onNewMeshPicked: Observable<PickingInfo>;
  39980. private _circleEase;
  39981. /**
  39982. * Observable raised before camera teleportation
  39983. */
  39984. onBeforeCameraTeleport: Observable<Vector3>;
  39985. /**
  39986. * Observable raised after camera teleportation
  39987. */
  39988. onAfterCameraTeleport: Observable<Vector3>;
  39989. /**
  39990. * Observable raised when current selected mesh gets unselected
  39991. */
  39992. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39993. private _raySelectionPredicate;
  39994. /**
  39995. * To be optionaly changed by user to define custom ray selection
  39996. */
  39997. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39998. /**
  39999. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40000. */
  40001. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40002. /**
  40003. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40004. */
  40005. teleportationEnabled: boolean;
  40006. private _defaultHeight;
  40007. private _teleportationInitialized;
  40008. private _interactionsEnabled;
  40009. private _interactionsRequested;
  40010. private _displayGaze;
  40011. private _displayLaserPointer;
  40012. /**
  40013. * The mesh used to display where the user is going to teleport.
  40014. */
  40015. /**
  40016. * Sets the mesh to be used to display where the user is going to teleport.
  40017. */
  40018. teleportationTarget: Mesh;
  40019. /**
  40020. * 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
  40021. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40022. * See http://doc.babylonjs.com/resources/baking_transformations
  40023. */
  40024. gazeTrackerMesh: Mesh;
  40025. /**
  40026. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40027. */
  40028. updateGazeTrackerScale: boolean;
  40029. /**
  40030. * The gaze tracking mesh corresponding to the left controller
  40031. */
  40032. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40033. /**
  40034. * The gaze tracking mesh corresponding to the right controller
  40035. */
  40036. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40037. /**
  40038. * If the ray of the gaze should be displayed.
  40039. */
  40040. /**
  40041. * Sets if the ray of the gaze should be displayed.
  40042. */
  40043. displayGaze: boolean;
  40044. /**
  40045. * If the ray of the LaserPointer should be displayed.
  40046. */
  40047. /**
  40048. * Sets if the ray of the LaserPointer should be displayed.
  40049. */
  40050. displayLaserPointer: boolean;
  40051. /**
  40052. * The deviceOrientationCamera used as the camera when not in VR.
  40053. */
  40054. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40055. /**
  40056. * Based on the current WebVR support, returns the current VR camera used.
  40057. */
  40058. readonly currentVRCamera: Nullable<Camera>;
  40059. /**
  40060. * The webVRCamera which is used when in VR.
  40061. */
  40062. readonly webVRCamera: WebVRFreeCamera;
  40063. /**
  40064. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40065. */
  40066. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40067. private readonly _teleportationRequestInitiated;
  40068. /**
  40069. * Instantiates a VRExperienceHelper.
  40070. * Helps to quickly add VR support to an existing scene.
  40071. * @param scene The scene the VRExperienceHelper belongs to.
  40072. * @param webVROptions Options to modify the vr experience helper's behavior.
  40073. */
  40074. constructor(scene: Scene,
  40075. /** Options to modify the vr experience helper's behavior. */
  40076. webVROptions?: VRExperienceHelperOptions);
  40077. private _onDefaultMeshLoaded;
  40078. private _onResize;
  40079. private _onFullscreenChange;
  40080. /**
  40081. * Gets a value indicating if we are currently in VR mode.
  40082. */
  40083. readonly isInVRMode: boolean;
  40084. private onVrDisplayPresentChange;
  40085. private onVRDisplayChanged;
  40086. private moveButtonToBottomRight;
  40087. private displayVRButton;
  40088. private updateButtonVisibility;
  40089. /**
  40090. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40091. * Otherwise, will use the fullscreen API.
  40092. */
  40093. enterVR(): void;
  40094. /**
  40095. * Attempt to exit VR, or fullscreen.
  40096. */
  40097. exitVR(): void;
  40098. /**
  40099. * The position of the vr experience helper.
  40100. */
  40101. /**
  40102. * Sets the position of the vr experience helper.
  40103. */
  40104. position: Vector3;
  40105. /**
  40106. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40107. */
  40108. enableInteractions(): void;
  40109. private readonly _noControllerIsActive;
  40110. private beforeRender;
  40111. private _isTeleportationFloor;
  40112. /**
  40113. * Adds a floor mesh to be used for teleportation.
  40114. * @param floorMesh the mesh to be used for teleportation.
  40115. */
  40116. addFloorMesh(floorMesh: Mesh): void;
  40117. /**
  40118. * Removes a floor mesh from being used for teleportation.
  40119. * @param floorMesh the mesh to be removed.
  40120. */
  40121. removeFloorMesh(floorMesh: Mesh): void;
  40122. /**
  40123. * Enables interactions and teleportation using the VR controllers and gaze.
  40124. * @param vrTeleportationOptions options to modify teleportation behavior.
  40125. */
  40126. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40127. private _onNewGamepadConnected;
  40128. private _tryEnableInteractionOnController;
  40129. private _onNewGamepadDisconnected;
  40130. private _enableInteractionOnController;
  40131. private _checkTeleportWithRay;
  40132. private _checkRotate;
  40133. private _checkTeleportBackwards;
  40134. private _enableTeleportationOnController;
  40135. private _createTeleportationCircles;
  40136. private _displayTeleportationTarget;
  40137. private _hideTeleportationTarget;
  40138. private _rotateCamera;
  40139. private _moveTeleportationSelectorTo;
  40140. private _workingVector;
  40141. private _workingQuaternion;
  40142. private _workingMatrix;
  40143. /**
  40144. * Teleports the users feet to the desired location
  40145. * @param location The location where the user's feet should be placed
  40146. */
  40147. teleportCamera(location: Vector3): void;
  40148. private _convertNormalToDirectionOfRay;
  40149. private _castRayAndSelectObject;
  40150. private _notifySelectedMeshUnselected;
  40151. /**
  40152. * Sets the color of the laser ray from the vr controllers.
  40153. * @param color new color for the ray.
  40154. */
  40155. changeLaserColor(color: Color3): void;
  40156. /**
  40157. * Sets the color of the ray from the vr headsets gaze.
  40158. * @param color new color for the ray.
  40159. */
  40160. changeGazeColor(color: Color3): void;
  40161. /**
  40162. * Exits VR and disposes of the vr experience helper
  40163. */
  40164. dispose(): void;
  40165. /**
  40166. * Gets the name of the VRExperienceHelper class
  40167. * @returns "VRExperienceHelper"
  40168. */
  40169. getClassName(): string;
  40170. }
  40171. }
  40172. declare module BABYLON {
  40173. /**
  40174. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  40175. * IMPORTANT!! The data is right-hand data.
  40176. * @export
  40177. * @interface DevicePose
  40178. */
  40179. interface DevicePose {
  40180. /**
  40181. * The position of the device, values in array are [x,y,z].
  40182. */
  40183. readonly position: Nullable<Float32Array>;
  40184. /**
  40185. * The linearVelocity of the device, values in array are [x,y,z].
  40186. */
  40187. readonly linearVelocity: Nullable<Float32Array>;
  40188. /**
  40189. * The linearAcceleration of the device, values in array are [x,y,z].
  40190. */
  40191. readonly linearAcceleration: Nullable<Float32Array>;
  40192. /**
  40193. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  40194. */
  40195. readonly orientation: Nullable<Float32Array>;
  40196. /**
  40197. * The angularVelocity of the device, values in array are [x,y,z].
  40198. */
  40199. readonly angularVelocity: Nullable<Float32Array>;
  40200. /**
  40201. * The angularAcceleration of the device, values in array are [x,y,z].
  40202. */
  40203. readonly angularAcceleration: Nullable<Float32Array>;
  40204. }
  40205. /**
  40206. * Interface representing a pose controlled object in Babylon.
  40207. * A pose controlled object has both regular pose values as well as pose values
  40208. * from an external device such as a VR head mounted display
  40209. */
  40210. interface PoseControlled {
  40211. /**
  40212. * The position of the object in babylon space.
  40213. */
  40214. position: Vector3;
  40215. /**
  40216. * The rotation quaternion of the object in babylon space.
  40217. */
  40218. rotationQuaternion: Quaternion;
  40219. /**
  40220. * The position of the device in babylon space.
  40221. */
  40222. devicePosition?: Vector3;
  40223. /**
  40224. * The rotation quaternion of the device in babylon space.
  40225. */
  40226. deviceRotationQuaternion: Quaternion;
  40227. /**
  40228. * The raw pose coming from the device.
  40229. */
  40230. rawPose: Nullable<DevicePose>;
  40231. /**
  40232. * The scale of the device to be used when translating from device space to babylon space.
  40233. */
  40234. deviceScaleFactor: number;
  40235. /**
  40236. * Updates the poseControlled values based on the input device pose.
  40237. * @param poseData the pose data to update the object with
  40238. */
  40239. updateFromDevice(poseData: DevicePose): void;
  40240. }
  40241. /**
  40242. * Set of options to customize the webVRCamera
  40243. */
  40244. interface WebVROptions {
  40245. /**
  40246. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  40247. */
  40248. trackPosition?: boolean;
  40249. /**
  40250. * Sets the scale of the vrDevice in babylon space. (default: 1)
  40251. */
  40252. positionScale?: number;
  40253. /**
  40254. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  40255. */
  40256. displayName?: string;
  40257. /**
  40258. * Should the native controller meshes be initialized. (default: true)
  40259. */
  40260. controllerMeshes?: boolean;
  40261. /**
  40262. * Creating a default HemiLight only on controllers. (default: true)
  40263. */
  40264. defaultLightingOnControllers?: boolean;
  40265. /**
  40266. * If you don't want to use the default VR button of the helper. (default: false)
  40267. */
  40268. useCustomVRButton?: boolean;
  40269. /**
  40270. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  40271. */
  40272. customVRButton?: HTMLButtonElement;
  40273. /**
  40274. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  40275. */
  40276. rayLength?: number;
  40277. /**
  40278. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  40279. */
  40280. defaultHeight?: number;
  40281. }
  40282. /**
  40283. * This represents a WebVR camera.
  40284. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  40285. * @example http://doc.babylonjs.com/how_to/webvr_camera
  40286. */
  40287. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  40288. private webVROptions;
  40289. /**
  40290. * @hidden
  40291. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  40292. */
  40293. _vrDevice: any;
  40294. /**
  40295. * The rawPose of the vrDevice.
  40296. */
  40297. rawPose: Nullable<DevicePose>;
  40298. private _onVREnabled;
  40299. private _specsVersion;
  40300. private _attached;
  40301. private _frameData;
  40302. protected _descendants: Array<Node>;
  40303. private _deviceRoomPosition;
  40304. /** @hidden */
  40305. _deviceRoomRotationQuaternion: Quaternion;
  40306. private _standingMatrix;
  40307. /**
  40308. * Represents device position in babylon space.
  40309. */
  40310. devicePosition: Vector3;
  40311. /**
  40312. * Represents device rotation in babylon space.
  40313. */
  40314. deviceRotationQuaternion: Quaternion;
  40315. /**
  40316. * The scale of the device to be used when translating from device space to babylon space.
  40317. */
  40318. deviceScaleFactor: number;
  40319. private _deviceToWorld;
  40320. private _worldToDevice;
  40321. /**
  40322. * References to the webVR controllers for the vrDevice.
  40323. */
  40324. controllers: Array<WebVRController>;
  40325. /**
  40326. * Emits an event when a controller is attached.
  40327. */
  40328. onControllersAttachedObservable: Observable<WebVRController[]>;
  40329. /**
  40330. * Emits an event when a controller's mesh has been loaded;
  40331. */
  40332. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40333. /**
  40334. * Emits an event when the HMD's pose has been updated.
  40335. */
  40336. onPoseUpdatedFromDeviceObservable: Observable<any>;
  40337. private _poseSet;
  40338. /**
  40339. * If the rig cameras be used as parent instead of this camera.
  40340. */
  40341. rigParenting: boolean;
  40342. private _lightOnControllers;
  40343. private _defaultHeight?;
  40344. /**
  40345. * Instantiates a WebVRFreeCamera.
  40346. * @param name The name of the WebVRFreeCamera
  40347. * @param position The starting anchor position for the camera
  40348. * @param scene The scene the camera belongs to
  40349. * @param webVROptions a set of customizable options for the webVRCamera
  40350. */
  40351. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  40352. /**
  40353. * Gets the device distance from the ground in meters.
  40354. * @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.
  40355. */
  40356. deviceDistanceToRoomGround(): number;
  40357. /**
  40358. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  40359. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  40360. */
  40361. useStandingMatrix(callback?: (bool: boolean) => void): void;
  40362. /**
  40363. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  40364. * @returns A promise with a boolean set to if the standing matrix is supported.
  40365. */
  40366. useStandingMatrixAsync(): Promise<boolean>;
  40367. /**
  40368. * Disposes the camera
  40369. */
  40370. dispose(): void;
  40371. /**
  40372. * Gets a vrController by name.
  40373. * @param name The name of the controller to retreive
  40374. * @returns the controller matching the name specified or null if not found
  40375. */
  40376. getControllerByName(name: string): Nullable<WebVRController>;
  40377. private _leftController;
  40378. /**
  40379. * The controller corrisponding to the users left hand.
  40380. */
  40381. readonly leftController: Nullable<WebVRController>;
  40382. private _rightController;
  40383. /**
  40384. * The controller corrisponding to the users right hand.
  40385. */
  40386. readonly rightController: Nullable<WebVRController>;
  40387. /**
  40388. * Casts a ray forward from the vrCamera's gaze.
  40389. * @param length Length of the ray (default: 100)
  40390. * @returns the ray corrisponding to the gaze
  40391. */
  40392. getForwardRay(length?: number): Ray;
  40393. /**
  40394. * @hidden
  40395. * Updates the camera based on device's frame data
  40396. */
  40397. _checkInputs(): void;
  40398. /**
  40399. * Updates the poseControlled values based on the input device pose.
  40400. * @param poseData Pose coming from the device
  40401. */
  40402. updateFromDevice(poseData: DevicePose): void;
  40403. private _htmlElementAttached;
  40404. private _detachIfAttached;
  40405. /**
  40406. * WebVR's attach control will start broadcasting frames to the device.
  40407. * Note that in certain browsers (chrome for example) this function must be called
  40408. * within a user-interaction callback. Example:
  40409. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  40410. *
  40411. * @param element html element to attach the vrDevice to
  40412. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  40413. */
  40414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40415. /**
  40416. * Detaches the camera from the html element and disables VR
  40417. *
  40418. * @param element html element to detach from
  40419. */
  40420. detachControl(element: HTMLElement): void;
  40421. /**
  40422. * @returns the name of this class
  40423. */
  40424. getClassName(): string;
  40425. /**
  40426. * Calls resetPose on the vrDisplay
  40427. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  40428. */
  40429. resetToCurrentRotation(): void;
  40430. /**
  40431. * @hidden
  40432. * Updates the rig cameras (left and right eye)
  40433. */
  40434. _updateRigCameras(): void;
  40435. private _workingVector;
  40436. private _oneVector;
  40437. private _workingMatrix;
  40438. private updateCacheCalled;
  40439. private _correctPositionIfNotTrackPosition;
  40440. /**
  40441. * @hidden
  40442. * Updates the cached values of the camera
  40443. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  40444. */
  40445. _updateCache(ignoreParentClass?: boolean): void;
  40446. /**
  40447. * @hidden
  40448. * Get current device position in babylon world
  40449. */
  40450. _computeDevicePosition(): void;
  40451. /**
  40452. * Updates the current device position and rotation in the babylon world
  40453. */
  40454. update(): void;
  40455. /**
  40456. * @hidden
  40457. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  40458. * @returns an identity matrix
  40459. */
  40460. _getViewMatrix(): Matrix;
  40461. private _tmpMatrix;
  40462. /**
  40463. * This function is called by the two RIG cameras.
  40464. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  40465. */
  40466. protected _getWebVRViewMatrix(): Matrix;
  40467. protected _getWebVRProjectionMatrix(): Matrix;
  40468. private _onGamepadConnectedObserver;
  40469. private _onGamepadDisconnectedObserver;
  40470. private _updateCacheWhenTrackingDisabledObserver;
  40471. /**
  40472. * Initializes the controllers and their meshes
  40473. */
  40474. initControllers(): void;
  40475. }
  40476. }
  40477. declare module BABYLON {
  40478. /** @hidden */
  40479. class _OcclusionDataStorage {
  40480. /** @hidden */
  40481. occlusionInternalRetryCounter: number;
  40482. /** @hidden */
  40483. isOcclusionQueryInProgress: boolean;
  40484. /** @hidden */
  40485. isOccluded: boolean;
  40486. /** @hidden */
  40487. occlusionRetryCount: number;
  40488. /** @hidden */
  40489. occlusionType: number;
  40490. /** @hidden */
  40491. occlusionQueryAlgorithmType: number;
  40492. }
  40493. interface Engine {
  40494. /**
  40495. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40496. * @return the new query
  40497. */
  40498. createQuery(): WebGLQuery;
  40499. /**
  40500. * Delete and release a webGL query
  40501. * @param query defines the query to delete
  40502. * @return the current engine
  40503. */
  40504. deleteQuery(query: WebGLQuery): Engine;
  40505. /**
  40506. * Check if a given query has resolved and got its value
  40507. * @param query defines the query to check
  40508. * @returns true if the query got its value
  40509. */
  40510. isQueryResultAvailable(query: WebGLQuery): boolean;
  40511. /**
  40512. * Gets the value of a given query
  40513. * @param query defines the query to check
  40514. * @returns the value of the query
  40515. */
  40516. getQueryResult(query: WebGLQuery): number;
  40517. /**
  40518. * Initiates an occlusion query
  40519. * @param algorithmType defines the algorithm to use
  40520. * @param query defines the query to use
  40521. * @returns the current engine
  40522. * @see http://doc.babylonjs.com/features/occlusionquery
  40523. */
  40524. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40525. /**
  40526. * Ends an occlusion query
  40527. * @see http://doc.babylonjs.com/features/occlusionquery
  40528. * @param algorithmType defines the algorithm to use
  40529. * @returns the current engine
  40530. */
  40531. endOcclusionQuery(algorithmType: number): Engine;
  40532. /**
  40533. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40534. * Please note that only one query can be issued at a time
  40535. * @returns a time token used to track the time span
  40536. */
  40537. startTimeQuery(): Nullable<_TimeToken>;
  40538. /**
  40539. * Ends a time query
  40540. * @param token defines the token used to measure the time span
  40541. * @returns the time spent (in ns)
  40542. */
  40543. endTimeQuery(token: _TimeToken): int;
  40544. /** @hidden */
  40545. _currentNonTimestampToken: Nullable<_TimeToken>;
  40546. /** @hidden */
  40547. _createTimeQuery(): WebGLQuery;
  40548. /** @hidden */
  40549. _deleteTimeQuery(query: WebGLQuery): void;
  40550. /** @hidden */
  40551. _getGlAlgorithmType(algorithmType: number): number;
  40552. /** @hidden */
  40553. _getTimeQueryResult(query: WebGLQuery): any;
  40554. /** @hidden */
  40555. _getTimeQueryAvailability(query: WebGLQuery): any;
  40556. }
  40557. interface AbstractMesh {
  40558. /**
  40559. * Backing filed
  40560. * @hidden
  40561. */
  40562. __occlusionDataStorage: _OcclusionDataStorage;
  40563. /**
  40564. * Access property
  40565. * @hidden
  40566. */
  40567. _occlusionDataStorage: _OcclusionDataStorage;
  40568. /**
  40569. * 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.
  40570. * The default value is -1 which means don't break the query and wait till the result
  40571. * @see http://doc.babylonjs.com/features/occlusionquery
  40572. */
  40573. occlusionRetryCount: number;
  40574. /**
  40575. * 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:
  40576. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40577. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40578. * * 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.
  40579. * @see http://doc.babylonjs.com/features/occlusionquery
  40580. */
  40581. occlusionType: number;
  40582. /**
  40583. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40584. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40585. * * 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.
  40586. * @see http://doc.babylonjs.com/features/occlusionquery
  40587. */
  40588. occlusionQueryAlgorithmType: number;
  40589. /**
  40590. * 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
  40591. * @see http://doc.babylonjs.com/features/occlusionquery
  40592. */
  40593. isOccluded: boolean;
  40594. /**
  40595. * Flag to check the progress status of the query
  40596. * @see http://doc.babylonjs.com/features/occlusionquery
  40597. */
  40598. isOcclusionQueryInProgress: boolean;
  40599. }
  40600. }
  40601. declare module BABYLON {
  40602. interface Engine {
  40603. /**
  40604. * Creates a webGL transform feedback object
  40605. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40606. * @returns the webGL transform feedback object
  40607. */
  40608. createTransformFeedback(): WebGLTransformFeedback;
  40609. /**
  40610. * Delete a webGL transform feedback object
  40611. * @param value defines the webGL transform feedback object to delete
  40612. */
  40613. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40614. /**
  40615. * Bind a webGL transform feedback object to the webgl context
  40616. * @param value defines the webGL transform feedback object to bind
  40617. */
  40618. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40619. /**
  40620. * Begins a transform feedback operation
  40621. * @param usePoints defines if points or triangles must be used
  40622. */
  40623. beginTransformFeedback(usePoints: boolean): void;
  40624. /**
  40625. * Ends a transform feedback operation
  40626. */
  40627. endTransformFeedback(): void;
  40628. /**
  40629. * Specify the varyings to use with transform feedback
  40630. * @param program defines the associated webGL program
  40631. * @param value defines the list of strings representing the varying names
  40632. */
  40633. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40634. /**
  40635. * Bind a webGL buffer for a transform feedback operation
  40636. * @param value defines the webGL buffer to bind
  40637. */
  40638. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40639. }
  40640. }
  40641. declare module BABYLON {
  40642. /**
  40643. * Contains an array of blocks representing the octree
  40644. */
  40645. interface IOctreeContainer<T> {
  40646. /**
  40647. * Blocks within the octree
  40648. */
  40649. blocks: Array<OctreeBlock<T>>;
  40650. }
  40651. /**
  40652. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40653. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40654. */
  40655. class Octree<T> {
  40656. /** 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.) */
  40657. maxDepth: number;
  40658. /**
  40659. * Blocks within the octree containing objects
  40660. */
  40661. blocks: Array<OctreeBlock<T>>;
  40662. /**
  40663. * Content stored in the octree
  40664. */
  40665. dynamicContent: T[];
  40666. private _maxBlockCapacity;
  40667. private _selectionContent;
  40668. private _creationFunc;
  40669. /**
  40670. * Creates a octree
  40671. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40672. * @param creationFunc function to be used to instatiate the octree
  40673. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40674. * @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.)
  40675. */
  40676. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40677. /** 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.) */
  40678. maxDepth?: number);
  40679. /**
  40680. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40681. * @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);
  40682. * @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);
  40683. * @param entries meshes to be added to the octree blocks
  40684. */
  40685. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40686. /**
  40687. * Adds a mesh to the octree
  40688. * @param entry Mesh to add to the octree
  40689. */
  40690. addMesh(entry: T): void;
  40691. /**
  40692. * Selects an array of meshes within the frustum
  40693. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40694. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40695. * @returns array of meshes within the frustum
  40696. */
  40697. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40698. /**
  40699. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40700. * @param sphereCenter defines the bounding sphere center
  40701. * @param sphereRadius defines the bounding sphere radius
  40702. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40703. * @returns an array of objects that intersect the sphere
  40704. */
  40705. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40706. /**
  40707. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40708. * @param ray defines the ray to test with
  40709. * @returns array of intersected objects
  40710. */
  40711. intersectsRay(ray: Ray): SmartArray<T>;
  40712. /**
  40713. * @hidden
  40714. */
  40715. 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;
  40716. /**
  40717. * Adds a mesh into the octree block if it intersects the block
  40718. */
  40719. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40720. /**
  40721. * Adds a submesh into the octree block if it intersects the block
  40722. */
  40723. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40724. }
  40725. }
  40726. declare module BABYLON {
  40727. /**
  40728. * Class used to store a cell in an octree
  40729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40730. */
  40731. class OctreeBlock<T> {
  40732. /**
  40733. * Gets the content of the current block
  40734. */
  40735. entries: T[];
  40736. /**
  40737. * Gets the list of block children
  40738. */
  40739. blocks: Array<OctreeBlock<T>>;
  40740. private _depth;
  40741. private _maxDepth;
  40742. private _capacity;
  40743. private _minPoint;
  40744. private _maxPoint;
  40745. private _boundingVectors;
  40746. private _creationFunc;
  40747. /**
  40748. * Creates a new block
  40749. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40750. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40751. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40752. * @param depth defines the current depth of this block in the octree
  40753. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40754. * @param creationFunc defines a callback to call when an element is added to the block
  40755. */
  40756. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40757. /**
  40758. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40759. */
  40760. readonly capacity: number;
  40761. /**
  40762. * Gets the minimum vector (in world space) of the block's bounding box
  40763. */
  40764. readonly minPoint: Vector3;
  40765. /**
  40766. * Gets the maximum vector (in world space) of the block's bounding box
  40767. */
  40768. readonly maxPoint: Vector3;
  40769. /**
  40770. * Add a new element to this block
  40771. * @param entry defines the element to add
  40772. */
  40773. addEntry(entry: T): void;
  40774. /**
  40775. * Add an array of elements to this block
  40776. * @param entries defines the array of elements to add
  40777. */
  40778. addEntries(entries: T[]): void;
  40779. /**
  40780. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40781. * @param frustumPlanes defines the frustum planes to test
  40782. * @param selection defines the array to store current content if selection is positive
  40783. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40784. */
  40785. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40786. /**
  40787. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40788. * @param sphereCenter defines the bounding sphere center
  40789. * @param sphereRadius defines the bounding sphere radius
  40790. * @param selection defines the array to store current content if selection is positive
  40791. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40792. */
  40793. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40794. /**
  40795. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40796. * @param ray defines the ray to test with
  40797. * @param selection defines the array to store current content if selection is positive
  40798. */
  40799. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40800. /**
  40801. * Subdivide the content into child blocks (this block will then be empty)
  40802. */
  40803. createInnerBlocks(): void;
  40804. }
  40805. }
  40806. declare module BABYLON {
  40807. interface Scene {
  40808. /**
  40809. * @hidden
  40810. * Backing Filed
  40811. */
  40812. _selectionOctree: Octree<AbstractMesh>;
  40813. /**
  40814. * Gets the octree used to boost mesh selection (picking)
  40815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40816. */
  40817. selectionOctree: Octree<AbstractMesh>;
  40818. /**
  40819. * Creates or updates the octree used to boost selection (picking)
  40820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40821. * @param maxCapacity defines the maximum capacity per leaf
  40822. * @param maxDepth defines the maximum depth of the octree
  40823. * @returns an octree of AbstractMesh
  40824. */
  40825. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40826. }
  40827. interface AbstractMesh {
  40828. /**
  40829. * @hidden
  40830. * Backing Field
  40831. */
  40832. _submeshesOctree: Octree<SubMesh>;
  40833. /**
  40834. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40835. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40836. * @param maxCapacity defines the maximum size of each block (64 by default)
  40837. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40838. * @returns the new octree
  40839. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40840. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40841. */
  40842. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40843. }
  40844. /**
  40845. * Defines the octree scene component responsible to manage any octrees
  40846. * in a given scene.
  40847. */
  40848. class OctreeSceneComponent {
  40849. /**
  40850. * The component name helpfull to identify the component in the list of scene components.
  40851. */
  40852. readonly name: string;
  40853. /**
  40854. * The scene the component belongs to.
  40855. */
  40856. scene: Scene;
  40857. /**
  40858. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40859. */
  40860. readonly checksIsEnabled: boolean;
  40861. /**
  40862. * Creates a new instance of the component for the given scene
  40863. * @param scene Defines the scene to register the component in
  40864. */
  40865. constructor(scene: Scene);
  40866. /**
  40867. * Registers the component in a given scene
  40868. */
  40869. register(): void;
  40870. /**
  40871. * Return the list of active meshes
  40872. * @returns the list of active meshes
  40873. */
  40874. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40875. /**
  40876. * Return the list of active sub meshes
  40877. * @param mesh The mesh to get the candidates sub meshes from
  40878. * @returns the list of active sub meshes
  40879. */
  40880. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40881. private _tempRay;
  40882. /**
  40883. * Return the list of sub meshes intersecting with a given local ray
  40884. * @param mesh defines the mesh to find the submesh for
  40885. * @param localRay defines the ray in local space
  40886. * @returns the list of intersecting sub meshes
  40887. */
  40888. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40889. /**
  40890. * Return the list of sub meshes colliding with a collider
  40891. * @param mesh defines the mesh to find the submesh for
  40892. * @param collider defines the collider to evaluate the collision against
  40893. * @returns the list of colliding sub meshes
  40894. */
  40895. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40896. /**
  40897. * Rebuilds the elements related to this component in case of
  40898. * context lost for instance.
  40899. */
  40900. rebuild(): void;
  40901. /**
  40902. * Disposes the component and the associated ressources.
  40903. */
  40904. dispose(): void;
  40905. }
  40906. }
  40907. declare module BABYLON {
  40908. /**
  40909. * Google Daydream controller
  40910. */
  40911. class DaydreamController extends WebVRController {
  40912. /**
  40913. * Base Url for the controller model.
  40914. */
  40915. static MODEL_BASE_URL: string;
  40916. /**
  40917. * File name for the controller model.
  40918. */
  40919. static MODEL_FILENAME: string;
  40920. /**
  40921. * Gamepad Id prefix used to identify Daydream Controller.
  40922. */
  40923. static readonly GAMEPAD_ID_PREFIX: string;
  40924. /**
  40925. * Creates a new DaydreamController from a gamepad
  40926. * @param vrGamepad the gamepad that the controller should be created from
  40927. */
  40928. constructor(vrGamepad: any);
  40929. /**
  40930. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40931. * @param scene scene in which to add meshes
  40932. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40933. */
  40934. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40935. /**
  40936. * Called once for each button that changed state since the last frame
  40937. * @param buttonIdx Which button index changed
  40938. * @param state New state of the button
  40939. * @param changes Which properties on the state changed since last frame
  40940. */
  40941. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40942. }
  40943. }
  40944. declare module BABYLON {
  40945. /**
  40946. * Gear VR Controller
  40947. */
  40948. class GearVRController extends WebVRController {
  40949. /**
  40950. * Base Url for the controller model.
  40951. */
  40952. static MODEL_BASE_URL: string;
  40953. /**
  40954. * File name for the controller model.
  40955. */
  40956. static MODEL_FILENAME: string;
  40957. /**
  40958. * Gamepad Id prefix used to identify this controller.
  40959. */
  40960. static readonly GAMEPAD_ID_PREFIX: string;
  40961. private readonly _buttonIndexToObservableNameMap;
  40962. /**
  40963. * Creates a new GearVRController from a gamepad
  40964. * @param vrGamepad the gamepad that the controller should be created from
  40965. */
  40966. constructor(vrGamepad: any);
  40967. /**
  40968. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40969. * @param scene scene in which to add meshes
  40970. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40971. */
  40972. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40973. /**
  40974. * Called once for each button that changed state since the last frame
  40975. * @param buttonIdx Which button index changed
  40976. * @param state New state of the button
  40977. * @param changes Which properties on the state changed since last frame
  40978. */
  40979. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40980. }
  40981. }
  40982. declare module BABYLON {
  40983. /**
  40984. * Generic Controller
  40985. */
  40986. class GenericController extends WebVRController {
  40987. /**
  40988. * Base Url for the controller model.
  40989. */
  40990. static readonly MODEL_BASE_URL: string;
  40991. /**
  40992. * File name for the controller model.
  40993. */
  40994. static readonly MODEL_FILENAME: string;
  40995. /**
  40996. * Creates a new GenericController from a gamepad
  40997. * @param vrGamepad the gamepad that the controller should be created from
  40998. */
  40999. constructor(vrGamepad: any);
  41000. /**
  41001. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41002. * @param scene scene in which to add meshes
  41003. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41004. */
  41005. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41006. /**
  41007. * Called once for each button that changed state since the last frame
  41008. * @param buttonIdx Which button index changed
  41009. * @param state New state of the button
  41010. * @param changes Which properties on the state changed since last frame
  41011. */
  41012. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41013. }
  41014. }
  41015. declare module BABYLON {
  41016. /**
  41017. * Oculus Touch Controller
  41018. */
  41019. class OculusTouchController extends WebVRController {
  41020. /**
  41021. * Base Url for the controller model.
  41022. */
  41023. static MODEL_BASE_URL: string;
  41024. /**
  41025. * File name for the left controller model.
  41026. */
  41027. static MODEL_LEFT_FILENAME: string;
  41028. /**
  41029. * File name for the right controller model.
  41030. */
  41031. static MODEL_RIGHT_FILENAME: string;
  41032. /**
  41033. * Fired when the secondary trigger on this controller is modified
  41034. */
  41035. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41036. /**
  41037. * Fired when the thumb rest on this controller is modified
  41038. */
  41039. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41040. /**
  41041. * Creates a new OculusTouchController from a gamepad
  41042. * @param vrGamepad the gamepad that the controller should be created from
  41043. */
  41044. constructor(vrGamepad: any);
  41045. /**
  41046. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41047. * @param scene scene in which to add meshes
  41048. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41049. */
  41050. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41051. /**
  41052. * Fired when the A button on this controller is modified
  41053. */
  41054. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41055. /**
  41056. * Fired when the B button on this controller is modified
  41057. */
  41058. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41059. /**
  41060. * Fired when the X button on this controller is modified
  41061. */
  41062. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41063. /**
  41064. * Fired when the Y button on this controller is modified
  41065. */
  41066. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41067. /**
  41068. * Called once for each button that changed state since the last frame
  41069. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41070. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41071. * 2) secondary trigger (same)
  41072. * 3) A (right) X (left), touch, pressed = value
  41073. * 4) B / Y
  41074. * 5) thumb rest
  41075. * @param buttonIdx Which button index changed
  41076. * @param state New state of the button
  41077. * @param changes Which properties on the state changed since last frame
  41078. */
  41079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41080. }
  41081. }
  41082. declare module BABYLON {
  41083. /**
  41084. * Defines the types of pose enabled controllers that are supported
  41085. */
  41086. enum PoseEnabledControllerType {
  41087. /**
  41088. * HTC Vive
  41089. */
  41090. VIVE = 0,
  41091. /**
  41092. * Oculus Rift
  41093. */
  41094. OCULUS = 1,
  41095. /**
  41096. * Windows mixed reality
  41097. */
  41098. WINDOWS = 2,
  41099. /**
  41100. * Samsung gear VR
  41101. */
  41102. GEAR_VR = 3,
  41103. /**
  41104. * Google Daydream
  41105. */
  41106. DAYDREAM = 4,
  41107. /**
  41108. * Generic
  41109. */
  41110. GENERIC = 5
  41111. }
  41112. /**
  41113. * Defines the MutableGamepadButton interface for the state of a gamepad button
  41114. */
  41115. interface MutableGamepadButton {
  41116. /**
  41117. * Value of the button/trigger
  41118. */
  41119. value: number;
  41120. /**
  41121. * If the button/trigger is currently touched
  41122. */
  41123. touched: boolean;
  41124. /**
  41125. * If the button/trigger is currently pressed
  41126. */
  41127. pressed: boolean;
  41128. }
  41129. /**
  41130. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  41131. * @hidden
  41132. */
  41133. interface ExtendedGamepadButton extends GamepadButton {
  41134. /**
  41135. * If the button/trigger is currently pressed
  41136. */
  41137. readonly pressed: boolean;
  41138. /**
  41139. * If the button/trigger is currently touched
  41140. */
  41141. readonly touched: boolean;
  41142. /**
  41143. * Value of the button/trigger
  41144. */
  41145. readonly value: number;
  41146. }
  41147. /**
  41148. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  41149. */
  41150. class PoseEnabledControllerHelper {
  41151. /**
  41152. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  41153. * @param vrGamepad the gamepad to initialized
  41154. * @returns a vr controller of the type the gamepad identified as
  41155. */
  41156. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  41157. }
  41158. /**
  41159. * Defines the PoseEnabledController object that contains state of a vr capable controller
  41160. */
  41161. class PoseEnabledController extends Gamepad implements PoseControlled {
  41162. private _deviceRoomPosition;
  41163. private _deviceRoomRotationQuaternion;
  41164. /**
  41165. * The device position in babylon space
  41166. */
  41167. devicePosition: Vector3;
  41168. /**
  41169. * The device rotation in babylon space
  41170. */
  41171. deviceRotationQuaternion: Quaternion;
  41172. /**
  41173. * The scale factor of the device in babylon space
  41174. */
  41175. deviceScaleFactor: number;
  41176. /**
  41177. * (Likely devicePosition should be used instead) The device position in its room space
  41178. */
  41179. position: Vector3;
  41180. /**
  41181. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  41182. */
  41183. rotationQuaternion: Quaternion;
  41184. /**
  41185. * The type of controller (Eg. Windows mixed reality)
  41186. */
  41187. controllerType: PoseEnabledControllerType;
  41188. protected _calculatedPosition: Vector3;
  41189. private _calculatedRotation;
  41190. /**
  41191. * The raw pose from the device
  41192. */
  41193. rawPose: DevicePose;
  41194. private _trackPosition;
  41195. private _maxRotationDistFromHeadset;
  41196. private _draggedRoomRotation;
  41197. /**
  41198. * @hidden
  41199. */
  41200. _disableTrackPosition(fixedPosition: Vector3): void;
  41201. /**
  41202. * Internal, the mesh attached to the controller
  41203. * @hidden
  41204. */
  41205. _mesh: Nullable<AbstractMesh>;
  41206. private _poseControlledCamera;
  41207. private _leftHandSystemQuaternion;
  41208. /**
  41209. * Internal, matrix used to convert room space to babylon space
  41210. * @hidden
  41211. */
  41212. _deviceToWorld: Matrix;
  41213. /**
  41214. * Node to be used when casting a ray from the controller
  41215. * @hidden
  41216. */
  41217. _pointingPoseNode: Nullable<AbstractMesh>;
  41218. /**
  41219. * Name of the child mesh that can be used to cast a ray from the controller
  41220. */
  41221. static readonly POINTING_POSE: string;
  41222. /**
  41223. * Creates a new PoseEnabledController from a gamepad
  41224. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  41225. */
  41226. constructor(browserGamepad: any);
  41227. private _workingMatrix;
  41228. /**
  41229. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  41230. */
  41231. update(): void;
  41232. /**
  41233. * Updates only the pose device and mesh without doing any button event checking
  41234. */
  41235. protected _updatePoseAndMesh(): void;
  41236. /**
  41237. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  41238. * @param poseData raw pose fromthe device
  41239. */
  41240. updateFromDevice(poseData: DevicePose): void;
  41241. /**
  41242. * @hidden
  41243. */
  41244. _meshAttachedObservable: Observable<AbstractMesh>;
  41245. /**
  41246. * Attaches a mesh to the controller
  41247. * @param mesh the mesh to be attached
  41248. */
  41249. attachToMesh(mesh: AbstractMesh): void;
  41250. /**
  41251. * Attaches the controllers mesh to a camera
  41252. * @param camera the camera the mesh should be attached to
  41253. */
  41254. attachToPoseControlledCamera(camera: TargetCamera): void;
  41255. /**
  41256. * Disposes of the controller
  41257. */
  41258. dispose(): void;
  41259. /**
  41260. * The mesh that is attached to the controller
  41261. */
  41262. readonly mesh: Nullable<AbstractMesh>;
  41263. /**
  41264. * Gets the ray of the controller in the direction the controller is pointing
  41265. * @param length the length the resulting ray should be
  41266. * @returns a ray in the direction the controller is pointing
  41267. */
  41268. getForwardRay(length?: number): Ray;
  41269. }
  41270. }
  41271. declare module BABYLON {
  41272. /**
  41273. * Vive Controller
  41274. */
  41275. class ViveController extends WebVRController {
  41276. /**
  41277. * Base Url for the controller model.
  41278. */
  41279. static MODEL_BASE_URL: string;
  41280. /**
  41281. * File name for the controller model.
  41282. */
  41283. static MODEL_FILENAME: string;
  41284. /**
  41285. * Creates a new ViveController from a gamepad
  41286. * @param vrGamepad the gamepad that the controller should be created from
  41287. */
  41288. constructor(vrGamepad: any);
  41289. /**
  41290. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41291. * @param scene scene in which to add meshes
  41292. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41293. */
  41294. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41295. /**
  41296. * Fired when the left button on this controller is modified
  41297. */
  41298. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41299. /**
  41300. * Fired when the right button on this controller is modified
  41301. */
  41302. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41303. /**
  41304. * Fired when the menu button on this controller is modified
  41305. */
  41306. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41307. /**
  41308. * Called once for each button that changed state since the last frame
  41309. * Vive mapping:
  41310. * 0: touchpad
  41311. * 1: trigger
  41312. * 2: left AND right buttons
  41313. * 3: menu button
  41314. * @param buttonIdx Which button index changed
  41315. * @param state New state of the button
  41316. * @param changes Which properties on the state changed since last frame
  41317. */
  41318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41319. }
  41320. }
  41321. declare module BABYLON {
  41322. /**
  41323. * Defines the WebVRController object that represents controllers tracked in 3D space
  41324. */
  41325. abstract class WebVRController extends PoseEnabledController {
  41326. /**
  41327. * Internal, the default controller model for the controller
  41328. */
  41329. protected _defaultModel: AbstractMesh;
  41330. /**
  41331. * Fired when the trigger state has changed
  41332. */
  41333. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41334. /**
  41335. * Fired when the main button state has changed
  41336. */
  41337. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41338. /**
  41339. * Fired when the secondary button state has changed
  41340. */
  41341. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41342. /**
  41343. * Fired when the pad state has changed
  41344. */
  41345. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  41346. /**
  41347. * Fired when controllers stick values have changed
  41348. */
  41349. onPadValuesChangedObservable: Observable<StickValues>;
  41350. /**
  41351. * Array of button availible on the controller
  41352. */
  41353. protected _buttons: Array<MutableGamepadButton>;
  41354. private _onButtonStateChange;
  41355. /**
  41356. * Fired when a controller button's state has changed
  41357. * @param callback the callback containing the button that was modified
  41358. */
  41359. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  41360. /**
  41361. * X and Y axis corrisponding to the controllers joystick
  41362. */
  41363. pad: StickValues;
  41364. /**
  41365. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  41366. */
  41367. hand: string;
  41368. /**
  41369. * The default controller model for the controller
  41370. */
  41371. readonly defaultModel: AbstractMesh;
  41372. /**
  41373. * Creates a new WebVRController from a gamepad
  41374. * @param vrGamepad the gamepad that the WebVRController should be created from
  41375. */
  41376. constructor(vrGamepad: any);
  41377. /**
  41378. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  41379. */
  41380. update(): void;
  41381. /**
  41382. * Function to be called when a button is modified
  41383. */
  41384. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41385. /**
  41386. * Loads a mesh and attaches it to the controller
  41387. * @param scene the scene the mesh should be added to
  41388. * @param meshLoaded callback for when the mesh has been loaded
  41389. */
  41390. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41391. private _setButtonValue;
  41392. private _changes;
  41393. private _checkChanges;
  41394. /**
  41395. * Disposes of th webVRCOntroller
  41396. */
  41397. dispose(): void;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * Defines the WindowsMotionController object that the state of the windows motion controller
  41403. */
  41404. class WindowsMotionController extends WebVRController {
  41405. /**
  41406. * The base url used to load the left and right controller models
  41407. */
  41408. static MODEL_BASE_URL: string;
  41409. /**
  41410. * The name of the left controller model file
  41411. */
  41412. static MODEL_LEFT_FILENAME: string;
  41413. /**
  41414. * The name of the right controller model file
  41415. */
  41416. static MODEL_RIGHT_FILENAME: string;
  41417. /**
  41418. * The controller name prefix for this controller type
  41419. */
  41420. static readonly GAMEPAD_ID_PREFIX: string;
  41421. /**
  41422. * The controller id pattern for this controller type
  41423. */
  41424. private static readonly GAMEPAD_ID_PATTERN;
  41425. private _loadedMeshInfo;
  41426. private readonly _mapping;
  41427. /**
  41428. * Fired when the trackpad on this controller is clicked
  41429. */
  41430. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41431. /**
  41432. * Fired when the trackpad on this controller is modified
  41433. */
  41434. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41435. /**
  41436. * The current x and y values of this controller's trackpad
  41437. */
  41438. trackpad: StickValues;
  41439. /**
  41440. * Creates a new WindowsMotionController from a gamepad
  41441. * @param vrGamepad the gamepad that the controller should be created from
  41442. */
  41443. constructor(vrGamepad: any);
  41444. /**
  41445. * Fired when the trigger on this controller is modified
  41446. */
  41447. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41448. /**
  41449. * Fired when the menu button on this controller is modified
  41450. */
  41451. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41452. /**
  41453. * Fired when the grip button on this controller is modified
  41454. */
  41455. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41456. /**
  41457. * Fired when the thumbstick button on this controller is modified
  41458. */
  41459. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41460. /**
  41461. * Fired when the touchpad button on this controller is modified
  41462. */
  41463. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41464. /**
  41465. * Fired when the touchpad values on this controller are modified
  41466. */
  41467. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41468. private _updateTrackpad;
  41469. /**
  41470. * Called once per frame by the engine.
  41471. */
  41472. update(): void;
  41473. /**
  41474. * Called once for each button that changed state since the last frame
  41475. * @param buttonIdx Which button index changed
  41476. * @param state New state of the button
  41477. * @param changes Which properties on the state changed since last frame
  41478. */
  41479. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41480. /**
  41481. * Moves the buttons on the controller mesh based on their current state
  41482. * @param buttonName the name of the button to move
  41483. * @param buttonValue the value of the button which determines the buttons new position
  41484. */
  41485. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41486. /**
  41487. * Moves the axis on the controller mesh based on its current state
  41488. * @param axis the index of the axis
  41489. * @param axisValue the value of the axis which determines the meshes new position
  41490. * @hidden
  41491. */
  41492. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41493. /**
  41494. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41495. * @param scene scene in which to add meshes
  41496. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41497. */
  41498. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41499. /**
  41500. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41501. * can be transformed by button presses and axes values, based on this._mapping.
  41502. *
  41503. * @param scene scene in which the meshes exist
  41504. * @param meshes list of meshes that make up the controller model to process
  41505. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41506. */
  41507. private processModel;
  41508. private createMeshInfo;
  41509. /**
  41510. * Gets the ray of the controller in the direction the controller is pointing
  41511. * @param length the length the resulting ray should be
  41512. * @returns a ray in the direction the controller is pointing
  41513. */
  41514. getForwardRay(length?: number): Ray;
  41515. /**
  41516. * Disposes of the controller
  41517. */
  41518. dispose(): void;
  41519. }
  41520. }
  41521. declare module BABYLON {
  41522. /**
  41523. * Interface to implement to create a shadow generator compatible with BJS.
  41524. */
  41525. interface IShadowGenerator {
  41526. /**
  41527. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  41528. * @returns The render target texture if present otherwise, null
  41529. */
  41530. getShadowMap(): Nullable<RenderTargetTexture>;
  41531. /**
  41532. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  41533. * @returns The render target texture if the shadow map is present otherwise, null
  41534. */
  41535. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  41536. /**
  41537. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  41538. * @param subMesh The submesh we want to render in the shadow map
  41539. * @param useInstances Defines wether will draw in the map using instances
  41540. * @returns true if ready otherwise, false
  41541. */
  41542. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  41543. /**
  41544. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  41545. * @param defines Defines of the material we want to update
  41546. * @param lightIndex Index of the light in the enabled light list of the material
  41547. */
  41548. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  41549. /**
  41550. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  41551. * defined in the generator but impacting the effect).
  41552. * It implies the unifroms available on the materials are the standard BJS ones.
  41553. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  41554. * @param effect The effect we are binfing the information for
  41555. */
  41556. bindShadowLight(lightIndex: string, effect: Effect): void;
  41557. /**
  41558. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  41559. * (eq to shadow prjection matrix * light transform matrix)
  41560. * @returns The transform matrix used to create the shadow map
  41561. */
  41562. getTransformMatrix(): Matrix;
  41563. /**
  41564. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  41565. * Cube and 2D textures for instance.
  41566. */
  41567. recreateShadowMap(): void;
  41568. /**
  41569. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  41570. * @param onCompiled Callback triggered at the and of the effects compilation
  41571. * @param options Sets of optional options forcing the compilation with different modes
  41572. */
  41573. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  41574. useInstances: boolean;
  41575. }>): void;
  41576. /**
  41577. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  41578. * @param options Sets of optional options forcing the compilation with different modes
  41579. * @returns A promise that resolves when the compilation completes
  41580. */
  41581. forceCompilationAsync(options?: Partial<{
  41582. useInstances: boolean;
  41583. }>): Promise<void>;
  41584. /**
  41585. * Serializes the shadow generator setup to a json object.
  41586. * @returns The serialized JSON object
  41587. */
  41588. serialize(): any;
  41589. /**
  41590. * Disposes the Shadow map and related Textures and effects.
  41591. */
  41592. dispose(): void;
  41593. }
  41594. /**
  41595. * Default implementation IShadowGenerator.
  41596. * This is the main object responsible of generating shadows in the framework.
  41597. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  41598. */
  41599. class ShadowGenerator implements IShadowGenerator {
  41600. /**
  41601. * Shadow generator mode None: no filtering applied.
  41602. */
  41603. static readonly FILTER_NONE: number;
  41604. /**
  41605. * Shadow generator mode ESM: Exponential Shadow Mapping.
  41606. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  41607. */
  41608. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  41609. /**
  41610. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  41611. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  41612. */
  41613. static readonly FILTER_POISSONSAMPLING: number;
  41614. /**
  41615. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  41616. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  41617. */
  41618. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  41619. /**
  41620. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  41621. * edge artifacts on steep falloff.
  41622. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  41623. */
  41624. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  41625. /**
  41626. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  41627. * edge artifacts on steep falloff.
  41628. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  41629. */
  41630. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  41631. /**
  41632. * Shadow generator mode PCF: Percentage Closer Filtering
  41633. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  41634. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  41635. */
  41636. static readonly FILTER_PCF: number;
  41637. /**
  41638. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  41639. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  41640. * Contact Hardening
  41641. */
  41642. static readonly FILTER_PCSS: number;
  41643. /**
  41644. * Reserved for PCF and PCSS
  41645. * Highest Quality.
  41646. *
  41647. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  41648. *
  41649. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  41650. */
  41651. static readonly QUALITY_HIGH: number;
  41652. /**
  41653. * Reserved for PCF and PCSS
  41654. * Good tradeoff for quality/perf cross devices
  41655. *
  41656. * Execute PCF on a 3*3 kernel.
  41657. *
  41658. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  41659. */
  41660. static readonly QUALITY_MEDIUM: number;
  41661. /**
  41662. * Reserved for PCF and PCSS
  41663. * The lowest quality but the fastest.
  41664. *
  41665. * Execute PCF on a 1*1 kernel.
  41666. *
  41667. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  41668. */
  41669. static readonly QUALITY_LOW: number;
  41670. private _bias;
  41671. /**
  41672. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  41673. */
  41674. /**
  41675. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  41676. */
  41677. bias: number;
  41678. private _normalBias;
  41679. /**
  41680. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  41681. */
  41682. /**
  41683. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  41684. */
  41685. normalBias: number;
  41686. private _blurBoxOffset;
  41687. /**
  41688. * Gets the blur box offset: offset applied during the blur pass.
  41689. * Only usefull if useKernelBlur = false
  41690. */
  41691. /**
  41692. * Sets the blur box offset: offset applied during the blur pass.
  41693. * Only usefull if useKernelBlur = false
  41694. */
  41695. blurBoxOffset: number;
  41696. private _blurScale;
  41697. /**
  41698. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  41699. * 2 means half of the size.
  41700. */
  41701. /**
  41702. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  41703. * 2 means half of the size.
  41704. */
  41705. blurScale: number;
  41706. private _blurKernel;
  41707. /**
  41708. * Gets the blur kernel: kernel size of the blur pass.
  41709. * Only usefull if useKernelBlur = true
  41710. */
  41711. /**
  41712. * Sets the blur kernel: kernel size of the blur pass.
  41713. * Only usefull if useKernelBlur = true
  41714. */
  41715. blurKernel: number;
  41716. private _useKernelBlur;
  41717. /**
  41718. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  41719. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  41720. */
  41721. /**
  41722. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  41723. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  41724. */
  41725. useKernelBlur: boolean;
  41726. private _depthScale;
  41727. /**
  41728. * Gets the depth scale used in ESM mode.
  41729. */
  41730. /**
  41731. * Sets the depth scale used in ESM mode.
  41732. * This can override the scale stored on the light.
  41733. */
  41734. depthScale: number;
  41735. private _filter;
  41736. /**
  41737. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  41738. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  41739. */
  41740. /**
  41741. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  41742. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  41743. */
  41744. filter: number;
  41745. /**
  41746. * Gets if the current filter is set to Poisson Sampling.
  41747. */
  41748. /**
  41749. * Sets the current filter to Poisson Sampling.
  41750. */
  41751. usePoissonSampling: boolean;
  41752. /**
  41753. * Gets if the current filter is set to VSM.
  41754. * DEPRECATED. Should use useExponentialShadowMap instead.
  41755. */
  41756. /**
  41757. * Sets the current filter is to VSM.
  41758. * DEPRECATED. Should use useExponentialShadowMap instead.
  41759. */
  41760. useVarianceShadowMap: boolean;
  41761. /**
  41762. * Gets if the current filter is set to blurred VSM.
  41763. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  41764. */
  41765. /**
  41766. * Sets the current filter is to blurred VSM.
  41767. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  41768. */
  41769. useBlurVarianceShadowMap: boolean;
  41770. /**
  41771. * Gets if the current filter is set to ESM.
  41772. */
  41773. /**
  41774. * Sets the current filter is to ESM.
  41775. */
  41776. useExponentialShadowMap: boolean;
  41777. /**
  41778. * Gets if the current filter is set to filtered ESM.
  41779. */
  41780. /**
  41781. * Gets if the current filter is set to filtered ESM.
  41782. */
  41783. useBlurExponentialShadowMap: boolean;
  41784. /**
  41785. * Gets if the current filter is set to "close ESM" (using the inverse of the
  41786. * exponential to prevent steep falloff artifacts).
  41787. */
  41788. /**
  41789. * Sets the current filter to "close ESM" (using the inverse of the
  41790. * exponential to prevent steep falloff artifacts).
  41791. */
  41792. useCloseExponentialShadowMap: boolean;
  41793. /**
  41794. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  41795. * exponential to prevent steep falloff artifacts).
  41796. */
  41797. /**
  41798. * Sets the current filter to filtered "close ESM" (using the inverse of the
  41799. * exponential to prevent steep falloff artifacts).
  41800. */
  41801. useBlurCloseExponentialShadowMap: boolean;
  41802. /**
  41803. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  41804. */
  41805. /**
  41806. * Sets the current filter to "PCF" (percentage closer filtering).
  41807. */
  41808. usePercentageCloserFiltering: boolean;
  41809. private _filteringQuality;
  41810. /**
  41811. * Gets the PCF or PCSS Quality.
  41812. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  41813. */
  41814. /**
  41815. * Sets the PCF or PCSS Quality.
  41816. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  41817. */
  41818. filteringQuality: number;
  41819. /**
  41820. * Gets if the current filter is set to "PCSS" (contact hardening).
  41821. */
  41822. /**
  41823. * Sets the current filter to "PCSS" (contact hardening).
  41824. */
  41825. useContactHardeningShadow: boolean;
  41826. private _contactHardeningLightSizeUVRatio;
  41827. /**
  41828. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  41829. * Using a ratio helps keeping shape stability independently of the map size.
  41830. *
  41831. * It does not account for the light projection as it was having too much
  41832. * instability during the light setup or during light position changes.
  41833. *
  41834. * Only valid if useContactHardeningShadow is true.
  41835. */
  41836. /**
  41837. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  41838. * Using a ratio helps keeping shape stability independently of the map size.
  41839. *
  41840. * It does not account for the light projection as it was having too much
  41841. * instability during the light setup or during light position changes.
  41842. *
  41843. * Only valid if useContactHardeningShadow is true.
  41844. */
  41845. contactHardeningLightSizeUVRatio: number;
  41846. private _darkness;
  41847. /**
  41848. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  41849. * 0 means strongest and 1 would means no shadow.
  41850. * @returns the darkness.
  41851. */
  41852. getDarkness(): number;
  41853. /**
  41854. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  41855. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  41856. * @returns the shadow generator allowing fluent coding.
  41857. */
  41858. setDarkness(darkness: number): ShadowGenerator;
  41859. private _transparencyShadow;
  41860. /**
  41861. * Sets the ability to have transparent shadow (boolean).
  41862. * @param transparent True if transparent else False
  41863. * @returns the shadow generator allowing fluent coding
  41864. */
  41865. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  41866. private _shadowMap;
  41867. private _shadowMap2;
  41868. /**
  41869. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  41870. * @returns The render target texture if present otherwise, null
  41871. */
  41872. getShadowMap(): Nullable<RenderTargetTexture>;
  41873. /**
  41874. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  41875. * @returns The render target texture if the shadow map is present otherwise, null
  41876. */
  41877. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  41878. /**
  41879. * Helper function to add a mesh and its descendants to the list of shadow casters.
  41880. * @param mesh Mesh to add
  41881. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  41882. * @returns the Shadow Generator itself
  41883. */
  41884. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  41885. /**
  41886. * Helper function to remove a mesh and its descendants from the list of shadow casters
  41887. * @param mesh Mesh to remove
  41888. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  41889. * @returns the Shadow Generator itself
  41890. */
  41891. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  41892. /**
  41893. * Controls the extent to which the shadows fade out at the edge of the frustum
  41894. * Used only by directionals and spots
  41895. */
  41896. frustumEdgeFalloff: number;
  41897. private _light;
  41898. /**
  41899. * Returns the associated light object.
  41900. * @returns the light generating the shadow
  41901. */
  41902. getLight(): IShadowLight;
  41903. /**
  41904. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  41905. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  41906. * It might on the other hand introduce peter panning.
  41907. */
  41908. forceBackFacesOnly: boolean;
  41909. private _scene;
  41910. private _lightDirection;
  41911. private _effect;
  41912. private _viewMatrix;
  41913. private _projectionMatrix;
  41914. private _transformMatrix;
  41915. private _cachedPosition;
  41916. private _cachedDirection;
  41917. private _cachedDefines;
  41918. private _currentRenderID;
  41919. private _boxBlurPostprocess;
  41920. private _kernelBlurXPostprocess;
  41921. private _kernelBlurYPostprocess;
  41922. private _blurPostProcesses;
  41923. private _mapSize;
  41924. private _currentFaceIndex;
  41925. private _currentFaceIndexCache;
  41926. private _textureType;
  41927. private _defaultTextureMatrix;
  41928. /**
  41929. * Creates a ShadowGenerator object.
  41930. * A ShadowGenerator is the required tool to use the shadows.
  41931. * Each light casting shadows needs to use its own ShadowGenerator.
  41932. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  41933. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  41934. * @param light The light object generating the shadows.
  41935. * @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.
  41936. */
  41937. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  41938. private _initializeGenerator;
  41939. private _initializeShadowMap;
  41940. private _initializeBlurRTTAndPostProcesses;
  41941. private _renderForShadowMap;
  41942. private _renderSubMeshForShadowMap;
  41943. private _applyFilterValues;
  41944. /**
  41945. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  41946. * @param onCompiled Callback triggered at the and of the effects compilation
  41947. * @param options Sets of optional options forcing the compilation with different modes
  41948. */
  41949. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  41950. useInstances: boolean;
  41951. }>): void;
  41952. /**
  41953. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  41954. * @param options Sets of optional options forcing the compilation with different modes
  41955. * @returns A promise that resolves when the compilation completes
  41956. */
  41957. forceCompilationAsync(options?: Partial<{
  41958. useInstances: boolean;
  41959. }>): Promise<void>;
  41960. /**
  41961. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  41962. * @param subMesh The submesh we want to render in the shadow map
  41963. * @param useInstances Defines wether will draw in the map using instances
  41964. * @returns true if ready otherwise, false
  41965. */
  41966. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  41967. /**
  41968. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  41969. * @param defines Defines of the material we want to update
  41970. * @param lightIndex Index of the light in the enabled light list of the material
  41971. */
  41972. prepareDefines(defines: any, lightIndex: number): void;
  41973. /**
  41974. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  41975. * defined in the generator but impacting the effect).
  41976. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  41977. * @param effect The effect we are binfing the information for
  41978. */
  41979. bindShadowLight(lightIndex: string, effect: Effect): void;
  41980. /**
  41981. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  41982. * (eq to shadow prjection matrix * light transform matrix)
  41983. * @returns The transform matrix used to create the shadow map
  41984. */
  41985. getTransformMatrix(): Matrix;
  41986. /**
  41987. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  41988. * Cube and 2D textures for instance.
  41989. */
  41990. recreateShadowMap(): void;
  41991. private _disposeBlurPostProcesses;
  41992. private _disposeRTTandPostProcesses;
  41993. /**
  41994. * Disposes the ShadowGenerator.
  41995. * Returns nothing.
  41996. */
  41997. dispose(): void;
  41998. /**
  41999. * Serializes the shadow generator setup to a json object.
  42000. * @returns The serialized JSON object
  42001. */
  42002. serialize(): any;
  42003. /**
  42004. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  42005. * @param parsedShadowGenerator The JSON object to parse
  42006. * @param scene The scene to create the shadow map for
  42007. * @returns The parsed shadow generator
  42008. */
  42009. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  42010. }
  42011. }
  42012. declare module BABYLON {
  42013. /**
  42014. * Defines the shadow generator component responsible to manage any shadow generators
  42015. * in a given scene.
  42016. */
  42017. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  42018. /**
  42019. * The component name helpfull to identify the component in the list of scene components.
  42020. */
  42021. readonly name: string;
  42022. /**
  42023. * The scene the component belongs to.
  42024. */
  42025. scene: Scene;
  42026. /**
  42027. * Creates a new instance of the component for the given scene
  42028. * @param scene Defines the scene to register the component in
  42029. */
  42030. constructor(scene: Scene);
  42031. /**
  42032. * Registers the component in a given scene
  42033. */
  42034. register(): void;
  42035. /**
  42036. * Rebuilds the elements related to this component in case of
  42037. * context lost for instance.
  42038. */
  42039. rebuild(): void;
  42040. /**
  42041. * Serializes the component data to the specified json object
  42042. * @param serializationObject The object to serialize to
  42043. */
  42044. serialize(serializationObject: any): void;
  42045. /**
  42046. * Adds all the element from the container to the scene
  42047. * @param container the container holding the elements
  42048. */
  42049. addFromContainer(container: AbstractScene): void;
  42050. /**
  42051. * Removes all the elements in the container from the scene
  42052. * @param container contains the elements to remove
  42053. */
  42054. removeFromContainer(container: AbstractScene): void;
  42055. /**
  42056. * Rebuilds the elements related to this component in case of
  42057. * context lost for instance.
  42058. */
  42059. dispose(): void;
  42060. private _gatherRenderTargets;
  42061. }
  42062. }
  42063. declare module BABYLON {
  42064. }
  42065. declare module BABYLON {
  42066. /**
  42067. * Background material used to create an efficient environement around your scene.
  42068. */
  42069. class BackgroundMaterial extends PushMaterial {
  42070. /**
  42071. * Standard reflectance value at parallel view angle.
  42072. */
  42073. static StandardReflectance0: number;
  42074. /**
  42075. * Standard reflectance value at grazing angle.
  42076. */
  42077. static StandardReflectance90: number;
  42078. protected _primaryColor: Color3;
  42079. /**
  42080. * Key light Color (multiply against the environement texture)
  42081. */
  42082. primaryColor: Color3;
  42083. protected __perceptualColor: Nullable<Color3>;
  42084. /**
  42085. * Experimental Internal Use Only.
  42086. *
  42087. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42088. * This acts as a helper to set the primary color to a more "human friendly" value.
  42089. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42090. * output color as close as possible from the chosen value.
  42091. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42092. * part of lighting setup.)
  42093. */
  42094. _perceptualColor: Nullable<Color3>;
  42095. protected _primaryColorShadowLevel: float;
  42096. /**
  42097. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42098. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42099. */
  42100. primaryColorShadowLevel: float;
  42101. protected _primaryColorHighlightLevel: float;
  42102. /**
  42103. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42104. * The primary color is used at the level chosen to define what the white area would look.
  42105. */
  42106. primaryColorHighlightLevel: float;
  42107. protected _reflectionTexture: Nullable<BaseTexture>;
  42108. /**
  42109. * Reflection Texture used in the material.
  42110. * Should be author in a specific way for the best result (refer to the documentation).
  42111. */
  42112. reflectionTexture: Nullable<BaseTexture>;
  42113. protected _reflectionBlur: float;
  42114. /**
  42115. * Reflection Texture level of blur.
  42116. *
  42117. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42118. * texture twice.
  42119. */
  42120. reflectionBlur: float;
  42121. protected _diffuseTexture: Nullable<BaseTexture>;
  42122. /**
  42123. * Diffuse Texture used in the material.
  42124. * Should be author in a specific way for the best result (refer to the documentation).
  42125. */
  42126. diffuseTexture: Nullable<BaseTexture>;
  42127. protected _shadowLights: Nullable<IShadowLight[]>;
  42128. /**
  42129. * Specify the list of lights casting shadow on the material.
  42130. * All scene shadow lights will be included if null.
  42131. */
  42132. shadowLights: Nullable<IShadowLight[]>;
  42133. protected _shadowLevel: float;
  42134. /**
  42135. * Helps adjusting the shadow to a softer level if required.
  42136. * 0 means black shadows and 1 means no shadows.
  42137. */
  42138. shadowLevel: float;
  42139. protected _sceneCenter: Vector3;
  42140. /**
  42141. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42142. * It is usually zero but might be interesting to modify according to your setup.
  42143. */
  42144. sceneCenter: Vector3;
  42145. protected _opacityFresnel: boolean;
  42146. /**
  42147. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42148. * This helps ensuring a nice transition when the camera goes under the ground.
  42149. */
  42150. opacityFresnel: boolean;
  42151. protected _reflectionFresnel: boolean;
  42152. /**
  42153. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42154. * This helps adding a mirror texture on the ground.
  42155. */
  42156. reflectionFresnel: boolean;
  42157. protected _reflectionFalloffDistance: number;
  42158. /**
  42159. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42160. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42161. */
  42162. reflectionFalloffDistance: number;
  42163. protected _reflectionAmount: number;
  42164. /**
  42165. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42166. */
  42167. reflectionAmount: number;
  42168. protected _reflectionReflectance0: number;
  42169. /**
  42170. * This specifies the weight of the reflection at grazing angle.
  42171. */
  42172. reflectionReflectance0: number;
  42173. protected _reflectionReflectance90: number;
  42174. /**
  42175. * This specifies the weight of the reflection at a perpendicular point of view.
  42176. */
  42177. reflectionReflectance90: number;
  42178. /**
  42179. * Sets the reflection reflectance fresnel values according to the default standard
  42180. * empirically know to work well :-)
  42181. */
  42182. reflectionStandardFresnelWeight: number;
  42183. protected _useRGBColor: boolean;
  42184. /**
  42185. * Helps to directly use the maps channels instead of their level.
  42186. */
  42187. useRGBColor: boolean;
  42188. protected _enableNoise: boolean;
  42189. /**
  42190. * This helps reducing the banding effect that could occur on the background.
  42191. */
  42192. enableNoise: boolean;
  42193. /**
  42194. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42195. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42196. * Recommended to be keep at 1.0 except for special cases.
  42197. */
  42198. fovMultiplier: number;
  42199. private _fovMultiplier;
  42200. /**
  42201. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42202. */
  42203. useEquirectangularFOV: boolean;
  42204. private _maxSimultaneousLights;
  42205. /**
  42206. * Number of Simultaneous lights allowed on the material.
  42207. */
  42208. maxSimultaneousLights: int;
  42209. /**
  42210. * Default configuration related to image processing available in the Background Material.
  42211. */
  42212. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42213. /**
  42214. * Keep track of the image processing observer to allow dispose and replace.
  42215. */
  42216. private _imageProcessingObserver;
  42217. /**
  42218. * Attaches a new image processing configuration to the PBR Material.
  42219. * @param configuration (if null the scene configuration will be use)
  42220. */
  42221. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42222. /**
  42223. * Gets the image processing configuration used either in this material.
  42224. */
  42225. /**
  42226. * Sets the Default image processing configuration used either in the this material.
  42227. *
  42228. * If sets to null, the scene one is in use.
  42229. */
  42230. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42231. /**
  42232. * Gets wether the color curves effect is enabled.
  42233. */
  42234. /**
  42235. * Sets wether the color curves effect is enabled.
  42236. */
  42237. cameraColorCurvesEnabled: boolean;
  42238. /**
  42239. * Gets wether the color grading effect is enabled.
  42240. */
  42241. /**
  42242. * Gets wether the color grading effect is enabled.
  42243. */
  42244. cameraColorGradingEnabled: boolean;
  42245. /**
  42246. * Gets wether tonemapping is enabled or not.
  42247. */
  42248. /**
  42249. * Sets wether tonemapping is enabled or not
  42250. */
  42251. cameraToneMappingEnabled: boolean;
  42252. /**
  42253. * The camera exposure used on this material.
  42254. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42255. * This corresponds to a photographic exposure.
  42256. */
  42257. /**
  42258. * The camera exposure used on this material.
  42259. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42260. * This corresponds to a photographic exposure.
  42261. */
  42262. cameraExposure: float;
  42263. /**
  42264. * Gets The camera contrast used on this material.
  42265. */
  42266. /**
  42267. * Sets The camera contrast used on this material.
  42268. */
  42269. cameraContrast: float;
  42270. /**
  42271. * Gets the Color Grading 2D Lookup Texture.
  42272. */
  42273. /**
  42274. * Sets the Color Grading 2D Lookup Texture.
  42275. */
  42276. cameraColorGradingTexture: Nullable<BaseTexture>;
  42277. /**
  42278. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42279. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42280. * 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;
  42281. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42282. */
  42283. /**
  42284. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42285. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42286. * 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;
  42287. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42288. */
  42289. cameraColorCurves: Nullable<ColorCurves>;
  42290. /**
  42291. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42292. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42293. */
  42294. switchToBGR: boolean;
  42295. private _renderTargets;
  42296. private _reflectionControls;
  42297. private _white;
  42298. private _primaryShadowColor;
  42299. private _primaryHighlightColor;
  42300. /**
  42301. * Instantiates a Background Material in the given scene
  42302. * @param name The friendly name of the material
  42303. * @param scene The scene to add the material to
  42304. */
  42305. constructor(name: string, scene: Scene);
  42306. /**
  42307. * Gets a boolean indicating that current material needs to register RTT
  42308. */
  42309. readonly hasRenderTargetTextures: boolean;
  42310. /**
  42311. * The entire material has been created in order to prevent overdraw.
  42312. * @returns false
  42313. */
  42314. needAlphaTesting(): boolean;
  42315. /**
  42316. * The entire material has been created in order to prevent overdraw.
  42317. * @returns true if blending is enable
  42318. */
  42319. needAlphaBlending(): boolean;
  42320. /**
  42321. * Checks wether the material is ready to be rendered for a given mesh.
  42322. * @param mesh The mesh to render
  42323. * @param subMesh The submesh to check against
  42324. * @param useInstances Specify wether or not the material is used with instances
  42325. * @returns true if all the dependencies are ready (Textures, Effects...)
  42326. */
  42327. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42328. /**
  42329. * Compute the primary color according to the chosen perceptual color.
  42330. */
  42331. private _computePrimaryColorFromPerceptualColor;
  42332. /**
  42333. * Compute the highlights and shadow colors according to their chosen levels.
  42334. */
  42335. private _computePrimaryColors;
  42336. /**
  42337. * Build the uniform buffer used in the material.
  42338. */
  42339. buildUniformLayout(): void;
  42340. /**
  42341. * Unbind the material.
  42342. */
  42343. unbind(): void;
  42344. /**
  42345. * Bind only the world matrix to the material.
  42346. * @param world The world matrix to bind.
  42347. */
  42348. bindOnlyWorldMatrix(world: Matrix): void;
  42349. /**
  42350. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42351. * @param world The world matrix to bind.
  42352. * @param subMesh The submesh to bind for.
  42353. */
  42354. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42355. /**
  42356. * Dispose the material.
  42357. * @param forceDisposeEffect Force disposal of the associated effect.
  42358. * @param forceDisposeTextures Force disposal of the associated textures.
  42359. */
  42360. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42361. /**
  42362. * Clones the material.
  42363. * @param name The cloned name.
  42364. * @returns The cloned material.
  42365. */
  42366. clone(name: string): BackgroundMaterial;
  42367. /**
  42368. * Serializes the current material to its JSON representation.
  42369. * @returns The JSON representation.
  42370. */
  42371. serialize(): any;
  42372. /**
  42373. * Gets the class name of the material
  42374. * @returns "BackgroundMaterial"
  42375. */
  42376. getClassName(): string;
  42377. /**
  42378. * Parse a JSON input to create back a background material.
  42379. * @param source The JSON data to parse
  42380. * @param scene The scene to create the parsed material in
  42381. * @param rootUrl The root url of the assets the material depends upon
  42382. * @returns the instantiated BackgroundMaterial.
  42383. */
  42384. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42385. }
  42386. }
  42387. declare module BABYLON {
  42388. /**
  42389. * The Physically based material base class of BJS.
  42390. *
  42391. * This offers the main features of a standard PBR material.
  42392. * For more information, please refer to the documentation :
  42393. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42394. */
  42395. abstract class PBRBaseMaterial extends PushMaterial {
  42396. /**
  42397. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  42398. */
  42399. static readonly LIGHTFALLOFF_PHYSICAL: number;
  42400. /**
  42401. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  42402. * to enhance interoperability with other engines.
  42403. */
  42404. static readonly LIGHTFALLOFF_GLTF: number;
  42405. /**
  42406. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  42407. * to enhance interoperability with other materials.
  42408. */
  42409. static readonly LIGHTFALLOFF_STANDARD: number;
  42410. /**
  42411. * Intensity of the direct lights e.g. the four lights available in your scene.
  42412. * This impacts both the direct diffuse and specular highlights.
  42413. */
  42414. protected _directIntensity: number;
  42415. /**
  42416. * Intensity of the emissive part of the material.
  42417. * This helps controlling the emissive effect without modifying the emissive color.
  42418. */
  42419. protected _emissiveIntensity: number;
  42420. /**
  42421. * Intensity of the environment e.g. how much the environment will light the object
  42422. * either through harmonics for rough material or through the refelction for shiny ones.
  42423. */
  42424. protected _environmentIntensity: number;
  42425. /**
  42426. * This is a special control allowing the reduction of the specular highlights coming from the
  42427. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42428. */
  42429. protected _specularIntensity: number;
  42430. /**
  42431. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  42432. */
  42433. private _lightingInfos;
  42434. /**
  42435. * Debug Control allowing disabling the bump map on this material.
  42436. */
  42437. protected _disableBumpMap: boolean;
  42438. /**
  42439. * AKA Diffuse Texture in standard nomenclature.
  42440. */
  42441. protected _albedoTexture: BaseTexture;
  42442. /**
  42443. * AKA Occlusion Texture in other nomenclature.
  42444. */
  42445. protected _ambientTexture: BaseTexture;
  42446. /**
  42447. * AKA Occlusion Texture Intensity in other nomenclature.
  42448. */
  42449. protected _ambientTextureStrength: number;
  42450. /**
  42451. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42452. * 1 means it completely occludes it
  42453. * 0 mean it has no impact
  42454. */
  42455. protected _ambientTextureImpactOnAnalyticalLights: number;
  42456. /**
  42457. * Stores the alpha values in a texture.
  42458. */
  42459. protected _opacityTexture: BaseTexture;
  42460. /**
  42461. * Stores the reflection values in a texture.
  42462. */
  42463. protected _reflectionTexture: BaseTexture;
  42464. /**
  42465. * Stores the refraction values in a texture.
  42466. */
  42467. protected _refractionTexture: BaseTexture;
  42468. /**
  42469. * Stores the emissive values in a texture.
  42470. */
  42471. protected _emissiveTexture: BaseTexture;
  42472. /**
  42473. * AKA Specular texture in other nomenclature.
  42474. */
  42475. protected _reflectivityTexture: BaseTexture;
  42476. /**
  42477. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42478. */
  42479. protected _metallicTexture: BaseTexture;
  42480. /**
  42481. * Specifies the metallic scalar of the metallic/roughness workflow.
  42482. * Can also be used to scale the metalness values of the metallic texture.
  42483. */
  42484. protected _metallic: Nullable<number>;
  42485. /**
  42486. * Specifies the roughness scalar of the metallic/roughness workflow.
  42487. * Can also be used to scale the roughness values of the metallic texture.
  42488. */
  42489. protected _roughness: Nullable<number>;
  42490. /**
  42491. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42492. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42493. */
  42494. protected _microSurfaceTexture: BaseTexture;
  42495. /**
  42496. * Stores surface normal data used to displace a mesh in a texture.
  42497. */
  42498. protected _bumpTexture: BaseTexture;
  42499. /**
  42500. * Stores the pre-calculated light information of a mesh in a texture.
  42501. */
  42502. protected _lightmapTexture: BaseTexture;
  42503. /**
  42504. * The color of a material in ambient lighting.
  42505. */
  42506. protected _ambientColor: Color3;
  42507. /**
  42508. * AKA Diffuse Color in other nomenclature.
  42509. */
  42510. protected _albedoColor: Color3;
  42511. /**
  42512. * AKA Specular Color in other nomenclature.
  42513. */
  42514. protected _reflectivityColor: Color3;
  42515. /**
  42516. * The color applied when light is reflected from a material.
  42517. */
  42518. protected _reflectionColor: Color3;
  42519. /**
  42520. * The color applied when light is emitted from a material.
  42521. */
  42522. protected _emissiveColor: Color3;
  42523. /**
  42524. * AKA Glossiness in other nomenclature.
  42525. */
  42526. protected _microSurface: number;
  42527. /**
  42528. * source material index of refraction (IOR)' / 'destination material IOR.
  42529. */
  42530. protected _indexOfRefraction: number;
  42531. /**
  42532. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  42533. */
  42534. protected _invertRefractionY: boolean;
  42535. /**
  42536. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42537. * Materials half opaque for instance using refraction could benefit from this control.
  42538. */
  42539. protected _linkRefractionWithTransparency: boolean;
  42540. /**
  42541. * Specifies that the material will use the light map as a show map.
  42542. */
  42543. protected _useLightmapAsShadowmap: boolean;
  42544. /**
  42545. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42546. * makes the reflect vector face the model (under horizon).
  42547. */
  42548. protected _useHorizonOcclusion: boolean;
  42549. /**
  42550. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42551. * too much the area relying on ambient texture to define their ambient occlusion.
  42552. */
  42553. protected _useRadianceOcclusion: boolean;
  42554. /**
  42555. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42556. */
  42557. protected _useAlphaFromAlbedoTexture: boolean;
  42558. /**
  42559. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  42560. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42561. */
  42562. protected _useSpecularOverAlpha: boolean;
  42563. /**
  42564. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42565. */
  42566. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42567. /**
  42568. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42569. */
  42570. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  42571. /**
  42572. * Specifies if the metallic texture contains the roughness information in its green channel.
  42573. */
  42574. protected _useRoughnessFromMetallicTextureGreen: boolean;
  42575. /**
  42576. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42577. */
  42578. protected _useMetallnessFromMetallicTextureBlue: boolean;
  42579. /**
  42580. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42581. */
  42582. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  42583. /**
  42584. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42585. */
  42586. protected _useAmbientInGrayScale: boolean;
  42587. /**
  42588. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42589. * The material will try to infer what glossiness each pixel should be.
  42590. */
  42591. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  42592. /**
  42593. * Defines the falloff type used in this material.
  42594. * It by default is Physical.
  42595. */
  42596. protected _lightFalloff: number;
  42597. /**
  42598. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42599. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42600. */
  42601. protected _useRadianceOverAlpha: boolean;
  42602. /**
  42603. * Allows using an object space normal map (instead of tangent space).
  42604. */
  42605. protected _useObjectSpaceNormalMap: boolean;
  42606. /**
  42607. * Allows using the bump map in parallax mode.
  42608. */
  42609. protected _useParallax: boolean;
  42610. /**
  42611. * Allows using the bump map in parallax occlusion mode.
  42612. */
  42613. protected _useParallaxOcclusion: boolean;
  42614. /**
  42615. * Controls the scale bias of the parallax mode.
  42616. */
  42617. protected _parallaxScaleBias: number;
  42618. /**
  42619. * If sets to true, disables all the lights affecting the material.
  42620. */
  42621. protected _disableLighting: boolean;
  42622. /**
  42623. * Number of Simultaneous lights allowed on the material.
  42624. */
  42625. protected _maxSimultaneousLights: number;
  42626. /**
  42627. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  42628. */
  42629. protected _invertNormalMapX: boolean;
  42630. /**
  42631. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  42632. */
  42633. protected _invertNormalMapY: boolean;
  42634. /**
  42635. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42636. */
  42637. protected _twoSidedLighting: boolean;
  42638. /**
  42639. * Defines the alpha limits in alpha test mode.
  42640. */
  42641. protected _alphaCutOff: number;
  42642. /**
  42643. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42644. */
  42645. protected _forceAlphaTest: boolean;
  42646. /**
  42647. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42648. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42649. */
  42650. protected _useAlphaFresnel: boolean;
  42651. /**
  42652. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42653. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42654. */
  42655. protected _useLinearAlphaFresnel: boolean;
  42656. /**
  42657. * The transparency mode of the material.
  42658. */
  42659. protected _transparencyMode: Nullable<number>;
  42660. /**
  42661. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  42662. * from cos thetav and roughness:
  42663. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  42664. */
  42665. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  42666. /**
  42667. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42668. */
  42669. protected _forceIrradianceInFragment: boolean;
  42670. /**
  42671. * Force normal to face away from face.
  42672. */
  42673. protected _forceNormalForward: boolean;
  42674. /**
  42675. * Enables specular anti aliasing in the PBR shader.
  42676. * It will both interacts on the Geometry for analytical and IBL lighting.
  42677. * It also prefilter the roughness map based on the bump values.
  42678. */
  42679. protected _enableSpecularAntiAliasing: boolean;
  42680. /**
  42681. * Default configuration related to image processing available in the PBR Material.
  42682. */
  42683. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42684. /**
  42685. * Keep track of the image processing observer to allow dispose and replace.
  42686. */
  42687. private _imageProcessingObserver;
  42688. /**
  42689. * Attaches a new image processing configuration to the PBR Material.
  42690. * @param configuration
  42691. */
  42692. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42693. /**
  42694. * Stores the available render targets.
  42695. */
  42696. private _renderTargets;
  42697. /**
  42698. * Sets the global ambient color for the material used in lighting calculations.
  42699. */
  42700. private _globalAmbientColor;
  42701. /**
  42702. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  42703. */
  42704. private _useLogarithmicDepth;
  42705. /**
  42706. * If set to true, no lighting calculations will be applied.
  42707. */
  42708. private _unlit;
  42709. /**
  42710. * Instantiates a new PBRMaterial instance.
  42711. *
  42712. * @param name The material name
  42713. * @param scene The scene the material will be use in.
  42714. */
  42715. constructor(name: string, scene: Scene);
  42716. /**
  42717. * Gets a boolean indicating that current material needs to register RTT
  42718. */
  42719. readonly hasRenderTargetTextures: boolean;
  42720. /**
  42721. * Gets the name of the material class.
  42722. */
  42723. getClassName(): string;
  42724. /**
  42725. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42726. */
  42727. /**
  42728. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42729. */
  42730. useLogarithmicDepth: boolean;
  42731. /**
  42732. * Gets the current transparency mode.
  42733. */
  42734. /**
  42735. * Sets the transparency mode of the material.
  42736. *
  42737. * | Value | Type | Description |
  42738. * | ----- | ----------------------------------- | ----------- |
  42739. * | 0 | OPAQUE | |
  42740. * | 1 | ALPHATEST | |
  42741. * | 2 | ALPHABLEND | |
  42742. * | 3 | ALPHATESTANDBLEND | |
  42743. *
  42744. */
  42745. transparencyMode: Nullable<number>;
  42746. /**
  42747. * Returns true if alpha blending should be disabled.
  42748. */
  42749. private readonly _disableAlphaBlending;
  42750. /**
  42751. * Specifies whether or not this material should be rendered in alpha blend mode.
  42752. */
  42753. needAlphaBlending(): boolean;
  42754. /**
  42755. * Specifies if the mesh will require alpha blending.
  42756. * @param mesh - BJS mesh.
  42757. */
  42758. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  42759. /**
  42760. * Specifies whether or not this material should be rendered in alpha test mode.
  42761. */
  42762. needAlphaTesting(): boolean;
  42763. /**
  42764. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  42765. */
  42766. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  42767. /**
  42768. * Gets the texture used for the alpha test.
  42769. */
  42770. getAlphaTestTexture(): BaseTexture;
  42771. /**
  42772. * Stores the reflectivity values based on metallic roughness workflow.
  42773. */
  42774. private static _scaledReflectivity;
  42775. /**
  42776. * Specifies that the submesh is ready to be used.
  42777. * @param mesh - BJS mesh.
  42778. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  42779. * @param useInstances - Specifies that instances should be used.
  42780. * @returns - boolean indicating that the submesh is ready or not.
  42781. */
  42782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42783. /**
  42784. * Specifies if the material uses metallic roughness workflow.
  42785. * @returns boolean specifiying if the material uses metallic roughness workflow.
  42786. */
  42787. isMetallicWorkflow(): boolean;
  42788. private _prepareEffect;
  42789. private _prepareDefines;
  42790. /**
  42791. * Force shader compilation
  42792. */
  42793. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  42794. clipPlane: boolean;
  42795. }>): void;
  42796. /**
  42797. * Initializes the uniform buffer layout for the shader.
  42798. */
  42799. buildUniformLayout(): void;
  42800. /**
  42801. * Unbinds the textures.
  42802. */
  42803. unbind(): void;
  42804. /**
  42805. * Binds the submesh data.
  42806. * @param world - The world matrix.
  42807. * @param mesh - The BJS mesh.
  42808. * @param subMesh - A submesh of the BJS mesh.
  42809. */
  42810. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42811. /**
  42812. * Returns the animatable textures.
  42813. * @returns - Array of animatable textures.
  42814. */
  42815. getAnimatables(): IAnimatable[];
  42816. /**
  42817. * Returns the texture used for reflections.
  42818. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  42819. */
  42820. private _getReflectionTexture;
  42821. /**
  42822. * Returns the texture used for refraction or null if none is used.
  42823. * @returns - Refection texture if present. If no refraction texture and refraction
  42824. * is linked with transparency, returns environment texture. Otherwise, returns null.
  42825. */
  42826. private _getRefractionTexture;
  42827. /**
  42828. * Disposes the resources of the material.
  42829. * @param forceDisposeEffect - Forces the disposal of effects.
  42830. * @param forceDisposeTextures - Forces the disposal of all textures.
  42831. */
  42832. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42833. }
  42834. }
  42835. declare module BABYLON {
  42836. /**
  42837. * The Physically based simple base material of BJS.
  42838. *
  42839. * This enables better naming and convention enforcements on top of the pbrMaterial.
  42840. * It is used as the base class for both the specGloss and metalRough conventions.
  42841. */
  42842. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  42843. /**
  42844. * Number of Simultaneous lights allowed on the material.
  42845. */
  42846. maxSimultaneousLights: number;
  42847. /**
  42848. * If sets to true, disables all the lights affecting the material.
  42849. */
  42850. disableLighting: boolean;
  42851. /**
  42852. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  42853. */
  42854. environmentTexture: BaseTexture;
  42855. /**
  42856. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42857. */
  42858. invertNormalMapX: boolean;
  42859. /**
  42860. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42861. */
  42862. invertNormalMapY: boolean;
  42863. /**
  42864. * Normal map used in the model.
  42865. */
  42866. normalTexture: BaseTexture;
  42867. /**
  42868. * Emissivie color used to self-illuminate the model.
  42869. */
  42870. emissiveColor: Color3;
  42871. /**
  42872. * Emissivie texture used to self-illuminate the model.
  42873. */
  42874. emissiveTexture: BaseTexture;
  42875. /**
  42876. * Occlusion Channel Strenght.
  42877. */
  42878. occlusionStrength: number;
  42879. /**
  42880. * Occlusion Texture of the material (adding extra occlusion effects).
  42881. */
  42882. occlusionTexture: BaseTexture;
  42883. /**
  42884. * Defines the alpha limits in alpha test mode.
  42885. */
  42886. alphaCutOff: number;
  42887. /**
  42888. * Gets the current double sided mode.
  42889. */
  42890. /**
  42891. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42892. */
  42893. doubleSided: boolean;
  42894. /**
  42895. * Stores the pre-calculated light information of a mesh in a texture.
  42896. */
  42897. lightmapTexture: BaseTexture;
  42898. /**
  42899. * If true, the light map contains occlusion information instead of lighting info.
  42900. */
  42901. useLightmapAsShadowmap: boolean;
  42902. /**
  42903. * Return the active textures of the material.
  42904. */
  42905. getActiveTextures(): BaseTexture[];
  42906. hasTexture(texture: BaseTexture): boolean;
  42907. /**
  42908. * Instantiates a new PBRMaterial instance.
  42909. *
  42910. * @param name The material name
  42911. * @param scene The scene the material will be use in.
  42912. */
  42913. constructor(name: string, scene: Scene);
  42914. getClassName(): string;
  42915. }
  42916. }
  42917. declare module BABYLON {
  42918. /**
  42919. * The Physically based material of BJS.
  42920. *
  42921. * This offers the main features of a standard PBR material.
  42922. * For more information, please refer to the documentation :
  42923. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42924. */
  42925. class PBRMaterial extends PBRBaseMaterial {
  42926. /**
  42927. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42928. */
  42929. static readonly PBRMATERIAL_OPAQUE: number;
  42930. /**
  42931. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42932. */
  42933. static readonly PBRMATERIAL_ALPHATEST: number;
  42934. /**
  42935. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42936. */
  42937. static readonly PBRMATERIAL_ALPHABLEND: number;
  42938. /**
  42939. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42940. * They are also discarded below the alpha cutoff threshold to improve performances.
  42941. */
  42942. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42943. /**
  42944. * Defines the default value of how much AO map is occluding the analytical lights
  42945. * (point spot...).
  42946. */
  42947. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42948. /**
  42949. * Intensity of the direct lights e.g. the four lights available in your scene.
  42950. * This impacts both the direct diffuse and specular highlights.
  42951. */
  42952. directIntensity: number;
  42953. /**
  42954. * Intensity of the emissive part of the material.
  42955. * This helps controlling the emissive effect without modifying the emissive color.
  42956. */
  42957. emissiveIntensity: number;
  42958. /**
  42959. * Intensity of the environment e.g. how much the environment will light the object
  42960. * either through harmonics for rough material or through the refelction for shiny ones.
  42961. */
  42962. environmentIntensity: number;
  42963. /**
  42964. * This is a special control allowing the reduction of the specular highlights coming from the
  42965. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42966. */
  42967. specularIntensity: number;
  42968. /**
  42969. * Debug Control allowing disabling the bump map on this material.
  42970. */
  42971. disableBumpMap: boolean;
  42972. /**
  42973. * AKA Diffuse Texture in standard nomenclature.
  42974. */
  42975. albedoTexture: BaseTexture;
  42976. /**
  42977. * AKA Occlusion Texture in other nomenclature.
  42978. */
  42979. ambientTexture: BaseTexture;
  42980. /**
  42981. * AKA Occlusion Texture Intensity in other nomenclature.
  42982. */
  42983. ambientTextureStrength: number;
  42984. /**
  42985. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42986. * 1 means it completely occludes it
  42987. * 0 mean it has no impact
  42988. */
  42989. ambientTextureImpactOnAnalyticalLights: number;
  42990. /**
  42991. * Stores the alpha values in a texture.
  42992. */
  42993. opacityTexture: BaseTexture;
  42994. /**
  42995. * Stores the reflection values in a texture.
  42996. */
  42997. reflectionTexture: Nullable<BaseTexture>;
  42998. /**
  42999. * Stores the emissive values in a texture.
  43000. */
  43001. emissiveTexture: BaseTexture;
  43002. /**
  43003. * AKA Specular texture in other nomenclature.
  43004. */
  43005. reflectivityTexture: BaseTexture;
  43006. /**
  43007. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43008. */
  43009. metallicTexture: BaseTexture;
  43010. /**
  43011. * Specifies the metallic scalar of the metallic/roughness workflow.
  43012. * Can also be used to scale the metalness values of the metallic texture.
  43013. */
  43014. metallic: Nullable<number>;
  43015. /**
  43016. * Specifies the roughness scalar of the metallic/roughness workflow.
  43017. * Can also be used to scale the roughness values of the metallic texture.
  43018. */
  43019. roughness: Nullable<number>;
  43020. /**
  43021. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43022. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43023. */
  43024. microSurfaceTexture: BaseTexture;
  43025. /**
  43026. * Stores surface normal data used to displace a mesh in a texture.
  43027. */
  43028. bumpTexture: BaseTexture;
  43029. /**
  43030. * Stores the pre-calculated light information of a mesh in a texture.
  43031. */
  43032. lightmapTexture: BaseTexture;
  43033. /**
  43034. * Stores the refracted light information in a texture.
  43035. */
  43036. refractionTexture: BaseTexture;
  43037. /**
  43038. * The color of a material in ambient lighting.
  43039. */
  43040. ambientColor: Color3;
  43041. /**
  43042. * AKA Diffuse Color in other nomenclature.
  43043. */
  43044. albedoColor: Color3;
  43045. /**
  43046. * AKA Specular Color in other nomenclature.
  43047. */
  43048. reflectivityColor: Color3;
  43049. /**
  43050. * The color reflected from the material.
  43051. */
  43052. reflectionColor: Color3;
  43053. /**
  43054. * The color emitted from the material.
  43055. */
  43056. emissiveColor: Color3;
  43057. /**
  43058. * AKA Glossiness in other nomenclature.
  43059. */
  43060. microSurface: number;
  43061. /**
  43062. * source material index of refraction (IOR)' / 'destination material IOR.
  43063. */
  43064. indexOfRefraction: number;
  43065. /**
  43066. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  43067. */
  43068. invertRefractionY: boolean;
  43069. /**
  43070. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43071. * Materials half opaque for instance using refraction could benefit from this control.
  43072. */
  43073. linkRefractionWithTransparency: boolean;
  43074. /**
  43075. * If true, the light map contains occlusion information instead of lighting info.
  43076. */
  43077. useLightmapAsShadowmap: boolean;
  43078. /**
  43079. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43080. */
  43081. useAlphaFromAlbedoTexture: boolean;
  43082. /**
  43083. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43084. */
  43085. forceAlphaTest: boolean;
  43086. /**
  43087. * Defines the alpha limits in alpha test mode.
  43088. */
  43089. alphaCutOff: number;
  43090. /**
  43091. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  43092. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43093. */
  43094. useSpecularOverAlpha: boolean;
  43095. /**
  43096. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43097. */
  43098. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43099. /**
  43100. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43101. */
  43102. useRoughnessFromMetallicTextureAlpha: boolean;
  43103. /**
  43104. * Specifies if the metallic texture contains the roughness information in its green channel.
  43105. */
  43106. useRoughnessFromMetallicTextureGreen: boolean;
  43107. /**
  43108. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43109. */
  43110. useMetallnessFromMetallicTextureBlue: boolean;
  43111. /**
  43112. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43113. */
  43114. useAmbientOcclusionFromMetallicTextureRed: boolean;
  43115. /**
  43116. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43117. */
  43118. useAmbientInGrayScale: boolean;
  43119. /**
  43120. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43121. * The material will try to infer what glossiness each pixel should be.
  43122. */
  43123. useAutoMicroSurfaceFromReflectivityMap: boolean;
  43124. /**
  43125. * BJS is using an harcoded light falloff based on a manually sets up range.
  43126. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43127. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43128. */
  43129. /**
  43130. * BJS is using an harcoded light falloff based on a manually sets up range.
  43131. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  43132. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  43133. */
  43134. usePhysicalLightFalloff: boolean;
  43135. /**
  43136. * In order to support the falloff compatibility with gltf, a special mode has been added
  43137. * to reproduce the gltf light falloff.
  43138. */
  43139. /**
  43140. * In order to support the falloff compatibility with gltf, a special mode has been added
  43141. * to reproduce the gltf light falloff.
  43142. */
  43143. useGLTFLightFalloff: boolean;
  43144. /**
  43145. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43146. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43147. */
  43148. useRadianceOverAlpha: boolean;
  43149. /**
  43150. * Allows using an object space normal map (instead of tangent space).
  43151. */
  43152. useObjectSpaceNormalMap: boolean;
  43153. /**
  43154. * Allows using the bump map in parallax mode.
  43155. */
  43156. useParallax: boolean;
  43157. /**
  43158. * Allows using the bump map in parallax occlusion mode.
  43159. */
  43160. useParallaxOcclusion: boolean;
  43161. /**
  43162. * Controls the scale bias of the parallax mode.
  43163. */
  43164. parallaxScaleBias: number;
  43165. /**
  43166. * If sets to true, disables all the lights affecting the material.
  43167. */
  43168. disableLighting: boolean;
  43169. /**
  43170. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43171. */
  43172. forceIrradianceInFragment: boolean;
  43173. /**
  43174. * Number of Simultaneous lights allowed on the material.
  43175. */
  43176. maxSimultaneousLights: number;
  43177. /**
  43178. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  43179. */
  43180. invertNormalMapX: boolean;
  43181. /**
  43182. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  43183. */
  43184. invertNormalMapY: boolean;
  43185. /**
  43186. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43187. */
  43188. twoSidedLighting: boolean;
  43189. /**
  43190. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43191. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43192. */
  43193. useAlphaFresnel: boolean;
  43194. /**
  43195. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43196. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43197. */
  43198. useLinearAlphaFresnel: boolean;
  43199. /**
  43200. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43201. * And/Or occlude the blended part.
  43202. */
  43203. environmentBRDFTexture: Nullable<BaseTexture>;
  43204. /**
  43205. * Force normal to face away from face.
  43206. */
  43207. forceNormalForward: boolean;
  43208. /**
  43209. * Enables specular anti aliasing in the PBR shader.
  43210. * It will both interacts on the Geometry for analytical and IBL lighting.
  43211. * It also prefilter the roughness map based on the bump values.
  43212. */
  43213. enableSpecularAntiAliasing: boolean;
  43214. /**
  43215. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43216. * makes the reflect vector face the model (under horizon).
  43217. */
  43218. useHorizonOcclusion: boolean;
  43219. /**
  43220. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43221. * too much the area relying on ambient texture to define their ambient occlusion.
  43222. */
  43223. useRadianceOcclusion: boolean;
  43224. /**
  43225. * If set to true, no lighting calculations will be applied.
  43226. */
  43227. unlit: boolean;
  43228. /**
  43229. * Gets the image processing configuration used either in this material.
  43230. */
  43231. /**
  43232. * Sets the Default image processing configuration used either in the this material.
  43233. *
  43234. * If sets to null, the scene one is in use.
  43235. */
  43236. imageProcessingConfiguration: ImageProcessingConfiguration;
  43237. /**
  43238. * Gets wether the color curves effect is enabled.
  43239. */
  43240. /**
  43241. * Sets wether the color curves effect is enabled.
  43242. */
  43243. cameraColorCurvesEnabled: boolean;
  43244. /**
  43245. * Gets wether the color grading effect is enabled.
  43246. */
  43247. /**
  43248. * Gets wether the color grading effect is enabled.
  43249. */
  43250. cameraColorGradingEnabled: boolean;
  43251. /**
  43252. * Gets wether tonemapping is enabled or not.
  43253. */
  43254. /**
  43255. * Sets wether tonemapping is enabled or not
  43256. */
  43257. cameraToneMappingEnabled: boolean;
  43258. /**
  43259. * The camera exposure used on this material.
  43260. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43261. * This corresponds to a photographic exposure.
  43262. */
  43263. /**
  43264. * The camera exposure used on this material.
  43265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43266. * This corresponds to a photographic exposure.
  43267. */
  43268. cameraExposure: number;
  43269. /**
  43270. * Gets The camera contrast used on this material.
  43271. */
  43272. /**
  43273. * Sets The camera contrast used on this material.
  43274. */
  43275. cameraContrast: number;
  43276. /**
  43277. * Gets the Color Grading 2D Lookup Texture.
  43278. */
  43279. /**
  43280. * Sets the Color Grading 2D Lookup Texture.
  43281. */
  43282. cameraColorGradingTexture: Nullable<BaseTexture>;
  43283. /**
  43284. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43285. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43286. * 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;
  43287. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43288. */
  43289. /**
  43290. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43291. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43292. * 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;
  43293. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43294. */
  43295. cameraColorCurves: Nullable<ColorCurves>;
  43296. /**
  43297. * Instantiates a new PBRMaterial instance.
  43298. *
  43299. * @param name The material name
  43300. * @param scene The scene the material will be use in.
  43301. */
  43302. constructor(name: string, scene: Scene);
  43303. /**
  43304. * Returns the name of this material class.
  43305. */
  43306. getClassName(): string;
  43307. /**
  43308. * Returns an array of the actively used textures.
  43309. * @returns - Array of BaseTextures
  43310. */
  43311. getActiveTextures(): BaseTexture[];
  43312. /**
  43313. * Checks to see if a texture is used in the material.
  43314. * @param texture - Base texture to use.
  43315. * @returns - Boolean specifying if a texture is used in the material.
  43316. */
  43317. hasTexture(texture: BaseTexture): boolean;
  43318. /**
  43319. * Makes a duplicate of the current material.
  43320. * @param name - name to use for the new material.
  43321. */
  43322. clone(name: string): PBRMaterial;
  43323. /**
  43324. * Serializes this PBR Material.
  43325. * @returns - An object with the serialized material.
  43326. */
  43327. serialize(): any;
  43328. /**
  43329. * Parses a PBR Material from a serialized object.
  43330. * @param source - Serialized object.
  43331. * @param scene - BJS scene instance.
  43332. * @param rootUrl - url for the scene object
  43333. * @returns - PBRMaterial
  43334. */
  43335. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  43336. }
  43337. }
  43338. declare module BABYLON {
  43339. /**
  43340. * The PBR material of BJS following the metal roughness convention.
  43341. *
  43342. * This fits to the PBR convention in the GLTF definition:
  43343. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  43344. */
  43345. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  43346. /**
  43347. * The base color has two different interpretations depending on the value of metalness.
  43348. * When the material is a metal, the base color is the specific measured reflectance value
  43349. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  43350. * of the material.
  43351. */
  43352. baseColor: Color3;
  43353. /**
  43354. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  43355. * well as opacity information in the alpha channel.
  43356. */
  43357. baseTexture: BaseTexture;
  43358. /**
  43359. * Specifies the metallic scalar value of the material.
  43360. * Can also be used to scale the metalness values of the metallic texture.
  43361. */
  43362. metallic: number;
  43363. /**
  43364. * Specifies the roughness scalar value of the material.
  43365. * Can also be used to scale the roughness values of the metallic texture.
  43366. */
  43367. roughness: number;
  43368. /**
  43369. * Texture containing both the metallic value in the B channel and the
  43370. * roughness value in the G channel to keep better precision.
  43371. */
  43372. metallicRoughnessTexture: BaseTexture;
  43373. /**
  43374. * Instantiates a new PBRMetalRoughnessMaterial instance.
  43375. *
  43376. * @param name The material name
  43377. * @param scene The scene the material will be use in.
  43378. */
  43379. constructor(name: string, scene: Scene);
  43380. /**
  43381. * Return the currrent class name of the material.
  43382. */
  43383. getClassName(): string;
  43384. /**
  43385. * Return the active textures of the material.
  43386. */
  43387. getActiveTextures(): BaseTexture[];
  43388. /**
  43389. * Checks to see if a texture is used in the material.
  43390. * @param texture - Base texture to use.
  43391. * @returns - Boolean specifying if a texture is used in the material.
  43392. */
  43393. hasTexture(texture: BaseTexture): boolean;
  43394. /**
  43395. * Makes a duplicate of the current material.
  43396. * @param name - name to use for the new material.
  43397. */
  43398. clone(name: string): PBRMetallicRoughnessMaterial;
  43399. /**
  43400. * Serialize the material to a parsable JSON object.
  43401. */
  43402. serialize(): any;
  43403. /**
  43404. * Parses a JSON object correponding to the serialize function.
  43405. */
  43406. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  43407. }
  43408. }
  43409. declare module BABYLON {
  43410. /**
  43411. * The PBR material of BJS following the specular glossiness convention.
  43412. *
  43413. * This fits to the PBR convention in the GLTF definition:
  43414. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  43415. */
  43416. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  43417. /**
  43418. * Specifies the diffuse color of the material.
  43419. */
  43420. diffuseColor: Color3;
  43421. /**
  43422. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  43423. * channel.
  43424. */
  43425. diffuseTexture: BaseTexture;
  43426. /**
  43427. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  43428. */
  43429. specularColor: Color3;
  43430. /**
  43431. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  43432. */
  43433. glossiness: number;
  43434. /**
  43435. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  43436. */
  43437. specularGlossinessTexture: BaseTexture;
  43438. /**
  43439. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  43440. *
  43441. * @param name The material name
  43442. * @param scene The scene the material will be use in.
  43443. */
  43444. constructor(name: string, scene: Scene);
  43445. /**
  43446. * Return the currrent class name of the material.
  43447. */
  43448. getClassName(): string;
  43449. /**
  43450. * Return the active textures of the material.
  43451. */
  43452. getActiveTextures(): BaseTexture[];
  43453. /**
  43454. * Checks to see if a texture is used in the material.
  43455. * @param texture - Base texture to use.
  43456. * @returns - Boolean specifying if a texture is used in the material.
  43457. */
  43458. hasTexture(texture: BaseTexture): boolean;
  43459. /**
  43460. * Makes a duplicate of the current material.
  43461. * @param name - name to use for the new material.
  43462. */
  43463. clone(name: string): PBRSpecularGlossinessMaterial;
  43464. /**
  43465. * Serialize the material to a parsable JSON object.
  43466. */
  43467. serialize(): any;
  43468. /**
  43469. * Parses a JSON object correponding to the serialize function.
  43470. */
  43471. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  43472. }
  43473. }
  43474. declare module BABYLON {
  43475. /**
  43476. * Base class of all the textures in babylon.
  43477. * It groups all the common properties the materials, post process, lights... might need
  43478. * in order to make a correct use of the texture.
  43479. */
  43480. class BaseTexture {
  43481. /**
  43482. * Default anisotropic filtering level for the application.
  43483. * It is set to 4 as a good tradeoff between perf and quality.
  43484. */
  43485. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  43486. /**
  43487. * Define the name of the texture.
  43488. */
  43489. name: string;
  43490. private _hasAlpha;
  43491. /**
  43492. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  43493. */
  43494. hasAlpha: boolean;
  43495. /**
  43496. * Defines if the alpha value should be determined via the rgb values.
  43497. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  43498. */
  43499. getAlphaFromRGB: boolean;
  43500. /**
  43501. * Intensity or strength of the texture.
  43502. * It is commonly used by materials to fine tune the intensity of the texture
  43503. */
  43504. level: number;
  43505. /**
  43506. * Define the UV chanel to use starting from 0 and defaulting to 0.
  43507. * This is part of the texture as textures usually maps to one uv set.
  43508. */
  43509. coordinatesIndex: number;
  43510. private _coordinatesMode;
  43511. /**
  43512. * How a texture is mapped.
  43513. *
  43514. * | Value | Type | Description |
  43515. * | ----- | ----------------------------------- | ----------- |
  43516. * | 0 | EXPLICIT_MODE | |
  43517. * | 1 | SPHERICAL_MODE | |
  43518. * | 2 | PLANAR_MODE | |
  43519. * | 3 | CUBIC_MODE | |
  43520. * | 4 | PROJECTION_MODE | |
  43521. * | 5 | SKYBOX_MODE | |
  43522. * | 6 | INVCUBIC_MODE | |
  43523. * | 7 | EQUIRECTANGULAR_MODE | |
  43524. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  43525. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  43526. */
  43527. coordinatesMode: number;
  43528. /**
  43529. * | Value | Type | Description |
  43530. * | ----- | ------------------ | ----------- |
  43531. * | 0 | CLAMP_ADDRESSMODE | |
  43532. * | 1 | WRAP_ADDRESSMODE | |
  43533. * | 2 | MIRROR_ADDRESSMODE | |
  43534. */
  43535. wrapU: number;
  43536. /**
  43537. * | Value | Type | Description |
  43538. * | ----- | ------------------ | ----------- |
  43539. * | 0 | CLAMP_ADDRESSMODE | |
  43540. * | 1 | WRAP_ADDRESSMODE | |
  43541. * | 2 | MIRROR_ADDRESSMODE | |
  43542. */
  43543. wrapV: number;
  43544. /**
  43545. * | Value | Type | Description |
  43546. * | ----- | ------------------ | ----------- |
  43547. * | 0 | CLAMP_ADDRESSMODE | |
  43548. * | 1 | WRAP_ADDRESSMODE | |
  43549. * | 2 | MIRROR_ADDRESSMODE | |
  43550. */
  43551. wrapR: number;
  43552. /**
  43553. * With compliant hardware and browser (supporting anisotropic filtering)
  43554. * this defines the level of anisotropic filtering in the texture.
  43555. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  43556. */
  43557. anisotropicFilteringLevel: number;
  43558. /**
  43559. * Define if the texture is a cube texture or if false a 2d texture.
  43560. */
  43561. isCube: boolean;
  43562. /**
  43563. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  43564. */
  43565. is3D: boolean;
  43566. /**
  43567. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  43568. * HDR texture are usually stored in linear space.
  43569. * This only impacts the PBR and Background materials
  43570. */
  43571. gammaSpace: boolean;
  43572. /**
  43573. * Gets whether or not the texture contains RGBD data.
  43574. */
  43575. readonly isRGBD: boolean;
  43576. /**
  43577. * Is Z inverted in the texture (useful in a cube texture).
  43578. */
  43579. invertZ: boolean;
  43580. /**
  43581. * @hidden
  43582. */
  43583. lodLevelInAlpha: boolean;
  43584. /**
  43585. * With prefiltered texture, defined the offset used during the prefiltering steps.
  43586. */
  43587. lodGenerationOffset: number;
  43588. /**
  43589. * With prefiltered texture, defined the scale used during the prefiltering steps.
  43590. */
  43591. lodGenerationScale: number;
  43592. /**
  43593. * Define if the texture is a render target.
  43594. */
  43595. isRenderTarget: boolean;
  43596. /**
  43597. * Define the unique id of the texture in the scene.
  43598. */
  43599. readonly uid: string;
  43600. /**
  43601. * Return a string representation of the texture.
  43602. * @returns the texture as a string
  43603. */
  43604. toString(): string;
  43605. /**
  43606. * Get the class name of the texture.
  43607. * @returns "BaseTexture"
  43608. */
  43609. getClassName(): string;
  43610. /**
  43611. * Define the list of animation attached to the texture.
  43612. */
  43613. animations: Animation[];
  43614. /**
  43615. * An event triggered when the texture is disposed.
  43616. */
  43617. onDisposeObservable: Observable<BaseTexture>;
  43618. private _onDisposeObserver;
  43619. /**
  43620. * Callback triggered when the texture has been disposed.
  43621. * Kept for back compatibility, you can use the onDisposeObservable instead.
  43622. */
  43623. onDispose: () => void;
  43624. /**
  43625. * Define the current state of the loading sequence when in delayed load mode.
  43626. */
  43627. delayLoadState: number;
  43628. private _scene;
  43629. /** @hidden */
  43630. _texture: Nullable<InternalTexture>;
  43631. private _uid;
  43632. /**
  43633. * Define if the texture is preventinga material to render or not.
  43634. * If not and the texture is not ready, the engine will use a default black texture instead.
  43635. */
  43636. readonly isBlocking: boolean;
  43637. /**
  43638. * Instantiates a new BaseTexture.
  43639. * Base class of all the textures in babylon.
  43640. * It groups all the common properties the materials, post process, lights... might need
  43641. * in order to make a correct use of the texture.
  43642. * @param scene Define the scene the texture blongs to
  43643. */
  43644. constructor(scene: Nullable<Scene>);
  43645. /**
  43646. * Get the scene the texture belongs to.
  43647. * @returns the scene or null if undefined
  43648. */
  43649. getScene(): Nullable<Scene>;
  43650. /**
  43651. * Get the texture transform matrix used to offset tile the texture for istance.
  43652. * @returns the transformation matrix
  43653. */
  43654. getTextureMatrix(): Matrix;
  43655. /**
  43656. * Get the texture reflection matrix used to rotate/transform the reflection.
  43657. * @returns the reflection matrix
  43658. */
  43659. getReflectionTextureMatrix(): Matrix;
  43660. /**
  43661. * Get the underlying lower level texture from Babylon.
  43662. * @returns the insternal texture
  43663. */
  43664. getInternalTexture(): Nullable<InternalTexture>;
  43665. /**
  43666. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  43667. * @returns true if ready or not blocking
  43668. */
  43669. isReadyOrNotBlocking(): boolean;
  43670. /**
  43671. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  43672. * @returns true if fully ready
  43673. */
  43674. isReady(): boolean;
  43675. private _cachedSize;
  43676. /**
  43677. * Get the size of the texture.
  43678. * @returns the texture size.
  43679. */
  43680. getSize(): ISize;
  43681. /**
  43682. * Get the base size of the texture.
  43683. * It can be different from the size if the texture has been resized for POT for instance
  43684. * @returns the base size
  43685. */
  43686. getBaseSize(): ISize;
  43687. /**
  43688. * Scales the texture if is `canRescale()`
  43689. * @param ratio the resize factor we want to use to rescale
  43690. */
  43691. scale(ratio: number): void;
  43692. /**
  43693. * Get if the texture can rescale.
  43694. */
  43695. readonly canRescale: boolean;
  43696. /** @hidden */
  43697. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  43698. /** @hidden */
  43699. _rebuild(): void;
  43700. /**
  43701. * Triggers the load sequence in delayed load mode.
  43702. */
  43703. delayLoad(): void;
  43704. /**
  43705. * Clones the texture.
  43706. * @returns the cloned texture
  43707. */
  43708. clone(): Nullable<BaseTexture>;
  43709. /**
  43710. * Get the texture underlying type (INT, FLOAT...)
  43711. */
  43712. readonly textureType: number;
  43713. /**
  43714. * Get the texture underlying format (RGB, RGBA...)
  43715. */
  43716. readonly textureFormat: number;
  43717. /**
  43718. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  43719. * This will returns an RGBA array buffer containing either in values (0-255) or
  43720. * float values (0-1) depending of the underlying buffer type.
  43721. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  43722. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  43723. * @param buffer defines a user defined buffer to fill with data (can be null)
  43724. * @returns The Array buffer containing the pixels data.
  43725. */
  43726. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  43727. /**
  43728. * Release and destroy the underlying lower level texture aka internalTexture.
  43729. */
  43730. releaseInternalTexture(): void;
  43731. /**
  43732. * Get the polynomial representation of the texture data.
  43733. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  43734. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  43735. */
  43736. sphericalPolynomial: Nullable<SphericalPolynomial>;
  43737. /** @hidden */
  43738. readonly _lodTextureHigh: Nullable<BaseTexture>;
  43739. /** @hidden */
  43740. readonly _lodTextureMid: Nullable<BaseTexture>;
  43741. /** @hidden */
  43742. readonly _lodTextureLow: Nullable<BaseTexture>;
  43743. /**
  43744. * Dispose the texture and release its associated resources.
  43745. */
  43746. dispose(): void;
  43747. /**
  43748. * Serialize the texture into a JSON representation that can be parsed later on.
  43749. * @returns the JSON representation of the texture
  43750. */
  43751. serialize(): any;
  43752. /**
  43753. * Helper function to be called back once a list of texture contains only ready textures.
  43754. * @param textures Define the list of textures to wait for
  43755. * @param callback Define the callback triggered once the entire list will be ready
  43756. */
  43757. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  43758. }
  43759. }
  43760. declare module BABYLON {
  43761. /**
  43762. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  43763. * It can help converting any input color in a desired output one. This can then be used to create effects
  43764. * from sepia, black and white to sixties or futuristic rendering...
  43765. *
  43766. * The only supported format is currently 3dl.
  43767. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  43768. */
  43769. class ColorGradingTexture extends BaseTexture {
  43770. /**
  43771. * The current texture matrix. (will always be identity in color grading texture)
  43772. */
  43773. private _textureMatrix;
  43774. /**
  43775. * The texture URL.
  43776. */
  43777. url: string;
  43778. /**
  43779. * Empty line regex stored for GC.
  43780. */
  43781. private static _noneEmptyLineRegex;
  43782. private _engine;
  43783. /**
  43784. * Instantiates a ColorGradingTexture from the following parameters.
  43785. *
  43786. * @param url The location of the color gradind data (currently only supporting 3dl)
  43787. * @param scene The scene the texture will be used in
  43788. */
  43789. constructor(url: string, scene: Scene);
  43790. /**
  43791. * Returns the texture matrix used in most of the material.
  43792. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  43793. */
  43794. getTextureMatrix(): Matrix;
  43795. /**
  43796. * Occurs when the file being loaded is a .3dl LUT file.
  43797. */
  43798. private load3dlTexture;
  43799. /**
  43800. * Starts the loading process of the texture.
  43801. */
  43802. private loadTexture;
  43803. /**
  43804. * Clones the color gradind texture.
  43805. */
  43806. clone(): ColorGradingTexture;
  43807. /**
  43808. * Called during delayed load for textures.
  43809. */
  43810. delayLoad(): void;
  43811. /**
  43812. * Parses a color grading texture serialized by Babylon.
  43813. * @param parsedTexture The texture information being parsedTexture
  43814. * @param scene The scene to load the texture in
  43815. * @param rootUrl The root url of the data assets to load
  43816. * @return A color gradind texture
  43817. */
  43818. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  43819. /**
  43820. * Serializes the LUT texture to json format.
  43821. */
  43822. serialize(): any;
  43823. }
  43824. }
  43825. declare module BABYLON {
  43826. /**
  43827. * Class for creating a cube texture
  43828. */
  43829. class CubeTexture extends BaseTexture {
  43830. /**
  43831. * The url of the texture
  43832. */
  43833. url: string;
  43834. /**
  43835. * Gets or sets the center of the bounding box associated with the cube texture.
  43836. * It must define where the camera used to render the texture was set
  43837. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  43838. */
  43839. boundingBoxPosition: Vector3;
  43840. private _boundingBoxSize;
  43841. /**
  43842. * Gets or sets the size of the bounding box associated with the cube texture
  43843. * When defined, the cubemap will switch to local mode
  43844. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  43845. * @example https://www.babylonjs-playground.com/#RNASML
  43846. */
  43847. /**
  43848. * Returns the bounding box size
  43849. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  43850. */
  43851. boundingBoxSize: Vector3;
  43852. protected _rotationY: number;
  43853. /**
  43854. * Sets texture matrix rotation angle around Y axis in radians.
  43855. */
  43856. /**
  43857. * Gets texture matrix rotation angle around Y axis radians.
  43858. */
  43859. rotationY: number;
  43860. private _noMipmap;
  43861. private _files;
  43862. private _extensions;
  43863. private _textureMatrix;
  43864. private _format;
  43865. private _createPolynomials;
  43866. /** @hidden */
  43867. readonly _prefiltered: boolean;
  43868. /**
  43869. * Creates a cube texture from an array of image urls
  43870. * @param files defines an array of image urls
  43871. * @param scene defines the hosting scene
  43872. * @param noMipmap specifies if mip maps are not used
  43873. * @returns a cube texture
  43874. */
  43875. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  43876. /**
  43877. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  43878. * @param url defines the url of the prefiltered texture
  43879. * @param scene defines the scene the texture is attached to
  43880. * @param forcedExtension defines the extension of the file if different from the url
  43881. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  43882. * @return the prefiltered texture
  43883. */
  43884. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  43885. /**
  43886. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  43887. * as prefiltered data.
  43888. * @param rootUrl defines the url of the texture or the root name of the six images
  43889. * @param scene defines the scene the texture is attached to
  43890. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  43891. * @param noMipmap defines if mipmaps should be created or not
  43892. * @param files defines the six files to load for the different faces
  43893. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  43894. * @param onError defines a callback triggered in case of error during load
  43895. * @param format defines the internal format to use for the texture once loaded
  43896. * @param prefiltered defines whether or not the texture is created from prefiltered data
  43897. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  43898. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  43899. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  43900. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  43901. * @return the cube texture
  43902. */
  43903. 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);
  43904. /**
  43905. * Delays loading of the cube texture
  43906. */
  43907. delayLoad(): void;
  43908. /**
  43909. * Returns the reflection texture matrix
  43910. * @returns the reflection texture matrix
  43911. */
  43912. getReflectionTextureMatrix(): Matrix;
  43913. /**
  43914. * Sets the reflection texture matrix
  43915. * @param value Reflection texture matrix
  43916. */
  43917. setReflectionTextureMatrix(value: Matrix): void;
  43918. /**
  43919. * Parses text to create a cube texture
  43920. * @param parsedTexture define the serialized text to read from
  43921. * @param scene defines the hosting scene
  43922. * @param rootUrl defines the root url of the cube texture
  43923. * @returns a cube texture
  43924. */
  43925. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  43926. /**
  43927. * Makes a clone, or deep copy, of the cube texture
  43928. * @returns a new cube texture
  43929. */
  43930. clone(): CubeTexture;
  43931. }
  43932. }
  43933. declare module BABYLON {
  43934. /**
  43935. * A class extending {BABYLON.Texture} allowing drawing on a texture
  43936. * @see http://doc.babylonjs.com/how_to/dynamictexture
  43937. */
  43938. class DynamicTexture extends Texture {
  43939. private _generateMipMaps;
  43940. private _canvas;
  43941. private _context;
  43942. private _engine;
  43943. /**
  43944. * Creates a {BABYLON.DynamicTexture}
  43945. * @param name defines the name of the texture
  43946. * @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
  43947. * @param scene defines the scene where you want the texture
  43948. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  43949. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  43950. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  43951. */
  43952. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  43953. /**
  43954. * Gets the current state of canRescale
  43955. */
  43956. readonly canRescale: boolean;
  43957. private _recreate;
  43958. /**
  43959. * Scales the texture
  43960. * @param ratio the scale factor to apply to both width and height
  43961. */
  43962. scale(ratio: number): void;
  43963. /**
  43964. * Resizes the texture
  43965. * @param width the new width
  43966. * @param height the new height
  43967. */
  43968. scaleTo(width: number, height: number): void;
  43969. /**
  43970. * Gets the context of the canvas used by the texture
  43971. * @returns the canvas context of the dynamic texture
  43972. */
  43973. getContext(): CanvasRenderingContext2D;
  43974. /**
  43975. * Clears the texture
  43976. */
  43977. clear(): void;
  43978. /**
  43979. * Updates the texture
  43980. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  43981. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  43982. */
  43983. update(invertY?: boolean, premulAlpha?: boolean): void;
  43984. /**
  43985. * Draws text onto the texture
  43986. * @param text defines the text to be drawn
  43987. * @param x defines the placement of the text from the left
  43988. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  43989. * @param font defines the font to be used with font-style, font-size, font-name
  43990. * @param color defines the color used for the text
  43991. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  43992. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  43993. * @param update defines whether texture is immediately update (default is true)
  43994. */
  43995. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  43996. /**
  43997. * Clones the texture
  43998. * @returns the clone of the texture.
  43999. */
  44000. clone(): DynamicTexture;
  44001. /**
  44002. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  44003. * @returns a serialized dynamic texture object
  44004. */
  44005. serialize(): any;
  44006. /** @hidden */
  44007. _rebuild(): void;
  44008. }
  44009. }
  44010. declare module BABYLON {
  44011. /**
  44012. * This represents a texture coming from an HDR input.
  44013. *
  44014. * The only supported format is currently panorama picture stored in RGBE format.
  44015. * Example of such files can be found on HDRLib: http://hdrlib.com/
  44016. */
  44017. class HDRCubeTexture extends BaseTexture {
  44018. private static _facesMapping;
  44019. private _generateHarmonics;
  44020. private _noMipmap;
  44021. private _textureMatrix;
  44022. private _size;
  44023. private _onLoad;
  44024. private _onError;
  44025. /**
  44026. * The texture URL.
  44027. */
  44028. url: string;
  44029. /**
  44030. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  44031. */
  44032. coordinatesMode: number;
  44033. protected _isBlocking: boolean;
  44034. /**
  44035. * Sets wether or not the texture is blocking during loading.
  44036. */
  44037. /**
  44038. * Gets wether or not the texture is blocking during loading.
  44039. */
  44040. isBlocking: boolean;
  44041. protected _rotationY: number;
  44042. /**
  44043. * Sets texture matrix rotation angle around Y axis in radians.
  44044. */
  44045. /**
  44046. * Gets texture matrix rotation angle around Y axis radians.
  44047. */
  44048. rotationY: number;
  44049. /**
  44050. * Gets or sets the center of the bounding box associated with the cube texture
  44051. * It must define where the camera used to render the texture was set
  44052. */
  44053. boundingBoxPosition: Vector3;
  44054. private _boundingBoxSize;
  44055. /**
  44056. * Gets or sets the size of the bounding box associated with the cube texture
  44057. * When defined, the cubemap will switch to local mode
  44058. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  44059. * @example https://www.babylonjs-playground.com/#RNASML
  44060. */
  44061. boundingBoxSize: Vector3;
  44062. /**
  44063. * Instantiates an HDRTexture from the following parameters.
  44064. *
  44065. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  44066. * @param scene The scene the texture will be used in
  44067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  44068. * @param noMipmap Forces to not generate the mipmap if true
  44069. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  44070. * @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)
  44071. * @param reserved Reserved flag for internal use.
  44072. */
  44073. 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>);
  44074. /**
  44075. * Occurs when the file is raw .hdr file.
  44076. */
  44077. private loadTexture;
  44078. clone(): HDRCubeTexture;
  44079. delayLoad(): void;
  44080. /**
  44081. * Get the texture reflection matrix used to rotate/transform the reflection.
  44082. * @returns the reflection matrix
  44083. */
  44084. getReflectionTextureMatrix(): Matrix;
  44085. /**
  44086. * Set the texture reflection matrix used to rotate/transform the reflection.
  44087. * @param value Define the reflection matrix to set
  44088. */
  44089. setReflectionTextureMatrix(value: Matrix): void;
  44090. /**
  44091. * Parses a JSON representation of an HDR Texture in order to create the texture
  44092. * @param parsedTexture Define the JSON representation
  44093. * @param scene Define the scene the texture should be created in
  44094. * @param rootUrl Define the root url in case we need to load relative dependencies
  44095. * @returns the newly created texture after parsing
  44096. */
  44097. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  44098. serialize(): any;
  44099. }
  44100. }
  44101. declare module BABYLON {
  44102. /**
  44103. * Class used to store data associated with WebGL texture data for the engine
  44104. * This class should not be used directly
  44105. */
  44106. class InternalTexture implements IInternalTextureTracker {
  44107. /**
  44108. * The source of the texture data is unknown
  44109. */
  44110. static DATASOURCE_UNKNOWN: number;
  44111. /**
  44112. * Texture data comes from an URL
  44113. */
  44114. static DATASOURCE_URL: number;
  44115. /**
  44116. * Texture data is only used for temporary storage
  44117. */
  44118. static DATASOURCE_TEMP: number;
  44119. /**
  44120. * Texture data comes from raw data (ArrayBuffer)
  44121. */
  44122. static DATASOURCE_RAW: number;
  44123. /**
  44124. * Texture content is dynamic (video or dynamic texture)
  44125. */
  44126. static DATASOURCE_DYNAMIC: number;
  44127. /**
  44128. * Texture content is generated by rendering to it
  44129. */
  44130. static DATASOURCE_RENDERTARGET: number;
  44131. /**
  44132. * Texture content is part of a multi render target process
  44133. */
  44134. static DATASOURCE_MULTIRENDERTARGET: number;
  44135. /**
  44136. * Texture data comes from a cube data file
  44137. */
  44138. static DATASOURCE_CUBE: number;
  44139. /**
  44140. * Texture data comes from a raw cube data
  44141. */
  44142. static DATASOURCE_CUBERAW: number;
  44143. /**
  44144. * Texture data come from a prefiltered cube data file
  44145. */
  44146. static DATASOURCE_CUBEPREFILTERED: number;
  44147. /**
  44148. * Texture content is raw 3D data
  44149. */
  44150. static DATASOURCE_RAW3D: number;
  44151. /**
  44152. * Texture content is a depth texture
  44153. */
  44154. static DATASOURCE_DEPTHTEXTURE: number;
  44155. /**
  44156. * Texture data comes from a raw cube data encoded with RGBD
  44157. */
  44158. static DATASOURCE_CUBERAW_RGBD: number;
  44159. /**
  44160. * Defines if the texture is ready
  44161. */
  44162. isReady: boolean;
  44163. /**
  44164. * Defines if the texture is a cube texture
  44165. */
  44166. isCube: boolean;
  44167. /**
  44168. * Defines if the texture contains 3D data
  44169. */
  44170. is3D: boolean;
  44171. /**
  44172. * Gets the URL used to load this texture
  44173. */
  44174. url: string;
  44175. /**
  44176. * Gets the sampling mode of the texture
  44177. */
  44178. samplingMode: number;
  44179. /**
  44180. * Gets a boolean indicating if the texture needs mipmaps generation
  44181. */
  44182. generateMipMaps: boolean;
  44183. /**
  44184. * Gets the number of samples used by the texture (WebGL2+ only)
  44185. */
  44186. samples: number;
  44187. /**
  44188. * Gets the type of the texture (int, float...)
  44189. */
  44190. type: number;
  44191. /**
  44192. * Gets the format of the texture (RGB, RGBA...)
  44193. */
  44194. format: number;
  44195. /**
  44196. * Observable called when the texture is loaded
  44197. */
  44198. onLoadedObservable: Observable<InternalTexture>;
  44199. /**
  44200. * Gets the width of the texture
  44201. */
  44202. width: number;
  44203. /**
  44204. * Gets the height of the texture
  44205. */
  44206. height: number;
  44207. /**
  44208. * Gets the depth of the texture
  44209. */
  44210. depth: number;
  44211. /**
  44212. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  44213. */
  44214. baseWidth: number;
  44215. /**
  44216. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  44217. */
  44218. baseHeight: number;
  44219. /**
  44220. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  44221. */
  44222. baseDepth: number;
  44223. /**
  44224. * Gets a boolean indicating if the texture is inverted on Y axis
  44225. */
  44226. invertY: boolean;
  44227. /**
  44228. * Gets or set the previous tracker in the list
  44229. */
  44230. previous: Nullable<IInternalTextureTracker>;
  44231. /**
  44232. * Gets or set the next tracker in the list
  44233. */
  44234. next: Nullable<IInternalTextureTracker>;
  44235. /** @hidden */
  44236. _initialSlot: number;
  44237. /** @hidden */
  44238. _designatedSlot: number;
  44239. /** @hidden */
  44240. _dataSource: number;
  44241. /** @hidden */
  44242. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  44243. /** @hidden */
  44244. _bufferView: Nullable<ArrayBufferView>;
  44245. /** @hidden */
  44246. _bufferViewArray: Nullable<ArrayBufferView[]>;
  44247. /** @hidden */
  44248. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  44249. /** @hidden */
  44250. _size: number;
  44251. /** @hidden */
  44252. _extension: string;
  44253. /** @hidden */
  44254. _files: Nullable<string[]>;
  44255. /** @hidden */
  44256. _workingCanvas: HTMLCanvasElement;
  44257. /** @hidden */
  44258. _workingContext: CanvasRenderingContext2D;
  44259. /** @hidden */
  44260. _framebuffer: Nullable<WebGLFramebuffer>;
  44261. /** @hidden */
  44262. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  44263. /** @hidden */
  44264. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  44265. /** @hidden */
  44266. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  44267. /** @hidden */
  44268. _attachments: Nullable<number[]>;
  44269. /** @hidden */
  44270. _cachedCoordinatesMode: Nullable<number>;
  44271. /** @hidden */
  44272. _cachedWrapU: Nullable<number>;
  44273. /** @hidden */
  44274. _cachedWrapV: Nullable<number>;
  44275. /** @hidden */
  44276. _cachedWrapR: Nullable<number>;
  44277. /** @hidden */
  44278. _cachedAnisotropicFilteringLevel: Nullable<number>;
  44279. /** @hidden */
  44280. _isDisabled: boolean;
  44281. /** @hidden */
  44282. _compression: Nullable<string>;
  44283. /** @hidden */
  44284. _generateStencilBuffer: boolean;
  44285. /** @hidden */
  44286. _generateDepthBuffer: boolean;
  44287. /** @hidden */
  44288. _comparisonFunction: number;
  44289. /** @hidden */
  44290. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  44291. /** @hidden */
  44292. _lodGenerationScale: number;
  44293. /** @hidden */
  44294. _lodGenerationOffset: number;
  44295. /** @hidden */
  44296. _lodTextureHigh: BaseTexture;
  44297. /** @hidden */
  44298. _lodTextureMid: BaseTexture;
  44299. /** @hidden */
  44300. _lodTextureLow: BaseTexture;
  44301. /** @hidden */
  44302. _isRGBD: boolean;
  44303. /** @hidden */
  44304. _webGLTexture: Nullable<WebGLTexture>;
  44305. /** @hidden */
  44306. _references: number;
  44307. private _engine;
  44308. /**
  44309. * Gets the Engine the texture belongs to.
  44310. * @returns The babylon engine
  44311. */
  44312. getEngine(): Engine;
  44313. /**
  44314. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  44315. */
  44316. readonly dataSource: number;
  44317. /**
  44318. * Creates a new InternalTexture
  44319. * @param engine defines the engine to use
  44320. * @param dataSource defines the type of data that will be used
  44321. */
  44322. constructor(engine: Engine, dataSource: number);
  44323. /**
  44324. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  44325. */
  44326. incrementReferences(): void;
  44327. /**
  44328. * Change the size of the texture (not the size of the content)
  44329. * @param width defines the new width
  44330. * @param height defines the new height
  44331. * @param depth defines the new depth (1 by default)
  44332. */
  44333. updateSize(width: int, height: int, depth?: int): void;
  44334. /** @hidden */
  44335. _rebuild(): void;
  44336. /** @hidden */
  44337. _swapAndDie(target: InternalTexture): void;
  44338. /**
  44339. * Dispose the current allocated resources
  44340. */
  44341. dispose(): void;
  44342. }
  44343. }
  44344. declare module BABYLON {
  44345. /**
  44346. * This represents the required contract to create a new type of texture loader.
  44347. */
  44348. interface IInternalTextureLoader {
  44349. /**
  44350. * Defines wether the loader supports cascade loading the different faces.
  44351. */
  44352. supportCascades: boolean;
  44353. /**
  44354. * This returns if the loader support the current file information.
  44355. * @param extension defines the file extension of the file being loaded
  44356. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44357. * @param fallback defines the fallback internal texture if any
  44358. * @param isBase64 defines whether the texture is encoded as a base64
  44359. * @param isBuffer defines whether the texture data are stored as a buffer
  44360. * @returns true if the loader can load the specified file
  44361. */
  44362. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  44363. /**
  44364. * Transform the url before loading if required.
  44365. * @param rootUrl the url of the texture
  44366. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44367. * @returns the transformed texture
  44368. */
  44369. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  44370. /**
  44371. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  44372. * @param rootUrl the url of the texture
  44373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44374. * @returns the fallback texture
  44375. */
  44376. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  44377. /**
  44378. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  44379. * @param data contains the texture data
  44380. * @param texture defines the BabylonJS internal texture
  44381. * @param createPolynomials will be true if polynomials have been requested
  44382. * @param onLoad defines the callback to trigger once the texture is ready
  44383. * @param onError defines the callback to trigger in case of error
  44384. */
  44385. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  44386. /**
  44387. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  44388. * @param data contains the texture data
  44389. * @param texture defines the BabylonJS internal texture
  44390. * @param callback defines the method to call once ready to upload
  44391. */
  44392. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  44393. }
  44394. }
  44395. declare module BABYLON {
  44396. /**
  44397. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  44398. */
  44399. interface IInternalTextureTracker {
  44400. /**
  44401. * Gets or set the previous tracker in the list
  44402. */
  44403. previous: Nullable<IInternalTextureTracker>;
  44404. /**
  44405. * Gets or set the next tracker in the list
  44406. */
  44407. next: Nullable<IInternalTextureTracker>;
  44408. }
  44409. /**
  44410. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  44411. */
  44412. class DummyInternalTextureTracker {
  44413. /**
  44414. * Gets or set the previous tracker in the list
  44415. */
  44416. previous: Nullable<IInternalTextureTracker>;
  44417. /**
  44418. * Gets or set the next tracker in the list
  44419. */
  44420. next: Nullable<IInternalTextureTracker>;
  44421. }
  44422. }
  44423. declare module BABYLON {
  44424. /**
  44425. * Mirror texture can be used to simulate the view from a mirror in a scene.
  44426. * It will dynamically be rendered every frame to adapt to the camera point of view.
  44427. * You can then easily use it as a reflectionTexture on a flat surface.
  44428. * In case the surface is not a plane, please consider relying on reflection probes.
  44429. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  44430. */
  44431. class MirrorTexture extends RenderTargetTexture {
  44432. private scene;
  44433. /**
  44434. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  44435. * 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.
  44436. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  44437. */
  44438. mirrorPlane: Plane;
  44439. /**
  44440. * Define the blur ratio used to blur the reflection if needed.
  44441. */
  44442. blurRatio: number;
  44443. /**
  44444. * Define the adaptive blur kernel used to blur the reflection if needed.
  44445. * This will autocompute the closest best match for the `blurKernel`
  44446. */
  44447. adaptiveBlurKernel: number;
  44448. /**
  44449. * Define the blur kernel used to blur the reflection if needed.
  44450. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  44451. */
  44452. blurKernel: number;
  44453. /**
  44454. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  44455. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  44456. */
  44457. blurKernelX: number;
  44458. /**
  44459. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  44460. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  44461. */
  44462. blurKernelY: number;
  44463. private _autoComputeBlurKernel;
  44464. protected _onRatioRescale(): void;
  44465. private _updateGammaSpace;
  44466. private _imageProcessingConfigChangeObserver;
  44467. private _transformMatrix;
  44468. private _mirrorMatrix;
  44469. private _savedViewMatrix;
  44470. private _blurX;
  44471. private _blurY;
  44472. private _adaptiveBlurKernel;
  44473. private _blurKernelX;
  44474. private _blurKernelY;
  44475. private _blurRatio;
  44476. /**
  44477. * Instantiates a Mirror Texture.
  44478. * Mirror texture can be used to simulate the view from a mirror in a scene.
  44479. * It will dynamically be rendered every frame to adapt to the camera point of view.
  44480. * You can then easily use it as a reflectionTexture on a flat surface.
  44481. * In case the surface is not a plane, please consider relying on reflection probes.
  44482. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  44483. * @param name
  44484. * @param size
  44485. * @param scene
  44486. * @param generateMipMaps
  44487. * @param type
  44488. * @param samplingMode
  44489. * @param generateDepthBuffer
  44490. */
  44491. constructor(name: string, size: number | {
  44492. width: number;
  44493. height: number;
  44494. } | {
  44495. ratio: number;
  44496. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  44497. private _preparePostProcesses;
  44498. /**
  44499. * Clone the mirror texture.
  44500. * @returns the cloned texture
  44501. */
  44502. clone(): MirrorTexture;
  44503. /**
  44504. * Serialize the texture to a JSON representation you could use in Parse later on
  44505. * @returns the serialized JSON representation
  44506. */
  44507. serialize(): any;
  44508. /**
  44509. * Dispose the texture and release its associated resources.
  44510. */
  44511. dispose(): void;
  44512. }
  44513. }
  44514. declare module BABYLON {
  44515. /**
  44516. * Creation options of the multi render target texture.
  44517. */
  44518. interface IMultiRenderTargetOptions {
  44519. /**
  44520. * Define if the texture needs to create mip maps after render.
  44521. */
  44522. generateMipMaps?: boolean;
  44523. /**
  44524. * Define the types of all the draw buffers we want to create
  44525. */
  44526. types?: number[];
  44527. /**
  44528. * Define the sampling modes of all the draw buffers we want to create
  44529. */
  44530. samplingModes?: number[];
  44531. /**
  44532. * Define if a depth buffer is required
  44533. */
  44534. generateDepthBuffer?: boolean;
  44535. /**
  44536. * Define if a stencil buffer is required
  44537. */
  44538. generateStencilBuffer?: boolean;
  44539. /**
  44540. * Define if a depth texture is required instead of a depth buffer
  44541. */
  44542. generateDepthTexture?: boolean;
  44543. /**
  44544. * Define the number of desired draw buffers
  44545. */
  44546. textureCount?: number;
  44547. /**
  44548. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44549. */
  44550. doNotChangeAspectRatio?: boolean;
  44551. /**
  44552. * Define the default type of the buffers we are creating
  44553. */
  44554. defaultType?: number;
  44555. }
  44556. /**
  44557. * A multi render target, like a render target provides the ability to render to a texture.
  44558. * Unlike the render target, it can render to several draw buffers in one draw.
  44559. * This is specially interesting in deferred rendering or for any effects requiring more than
  44560. * just one color from a single pass.
  44561. */
  44562. class MultiRenderTarget extends RenderTargetTexture {
  44563. private _internalTextures;
  44564. private _textures;
  44565. private _multiRenderTargetOptions;
  44566. /**
  44567. * Get if draw buffers are currently supported by the used hardware and browser.
  44568. */
  44569. readonly isSupported: boolean;
  44570. /**
  44571. * Get the list of textures generated by the multi render target.
  44572. */
  44573. readonly textures: Texture[];
  44574. /**
  44575. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44576. */
  44577. readonly depthTexture: Texture;
  44578. /**
  44579. * Set the wrapping mode on U of all the textures we are rendering to.
  44580. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44581. */
  44582. wrapU: number;
  44583. /**
  44584. * Set the wrapping mode on V of all the textures we are rendering to.
  44585. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44586. */
  44587. wrapV: number;
  44588. /**
  44589. * Instantiate a new multi render target texture.
  44590. * A multi render target, like a render target provides the ability to render to a texture.
  44591. * Unlike the render target, it can render to several draw buffers in one draw.
  44592. * This is specially interesting in deferred rendering or for any effects requiring more than
  44593. * just one color from a single pass.
  44594. * @param name Define the name of the texture
  44595. * @param size Define the size of the buffers to render to
  44596. * @param count Define the number of target we are rendering into
  44597. * @param scene Define the scene the texture belongs to
  44598. * @param options Define the options used to create the multi render target
  44599. */
  44600. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44601. /** @hidden */
  44602. _rebuild(): void;
  44603. private _createInternalTextures;
  44604. private _createTextures;
  44605. /**
  44606. * Define the number of samples used if MSAA is enabled.
  44607. */
  44608. samples: number;
  44609. /**
  44610. * Resize all the textures in the multi render target.
  44611. * Be carrefull as it will recreate all the data in the new texture.
  44612. * @param size Define the new size
  44613. */
  44614. resize(size: any): void;
  44615. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44616. /**
  44617. * Dispose the render targets and their associated resources
  44618. */
  44619. dispose(): void;
  44620. /**
  44621. * Release all the underlying texture used as draw buffers.
  44622. */
  44623. releaseInternalTextures(): void;
  44624. }
  44625. }
  44626. declare module BABYLON {
  44627. /**
  44628. * Raw cube texture where the raw buffers are passed in
  44629. */
  44630. class RawCubeTexture extends CubeTexture {
  44631. /**
  44632. * Creates a cube texture where the raw buffers are passed in.
  44633. * @param scene defines the scene the texture is attached to
  44634. * @param data defines the array of data to use to create each face
  44635. * @param size defines the size of the textures
  44636. * @param format defines the format of the data
  44637. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  44638. * @param generateMipMaps defines if the engine should generate the mip levels
  44639. * @param invertY defines if data must be stored with Y axis inverted
  44640. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  44641. * @param compression defines the compression used (null by default)
  44642. */
  44643. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  44644. /**
  44645. * Updates the raw cube texture.
  44646. * @param data defines the data to store
  44647. * @param format defines the data format
  44648. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  44649. * @param invertY defines if data must be stored with Y axis inverted
  44650. * @param compression defines the compression used (null by default)
  44651. * @param level defines which level of the texture to update
  44652. */
  44653. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  44654. /**
  44655. * Updates a raw cube texture with RGBD encoded data.
  44656. * @param data defines the array of data [mipmap][face] to use to create each face
  44657. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  44658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44660. * @returns a promsie that resolves when the operation is complete
  44661. */
  44662. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  44663. /**
  44664. * Clones the raw cube texture.
  44665. * @return a new cube texture
  44666. */
  44667. clone(): CubeTexture;
  44668. /** @hidden */
  44669. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44670. }
  44671. }
  44672. declare module BABYLON {
  44673. /**
  44674. * Raw texture can help creating a texture directly from an array of data.
  44675. * This can be super useful if you either get the data from an uncompressed source or
  44676. * if you wish to create your texture pixel by pixel.
  44677. */
  44678. class RawTexture extends Texture {
  44679. format: number;
  44680. private _engine;
  44681. /**
  44682. * Instantiates a new RawTexture.
  44683. * Raw texture can help creating a texture directly from an array of data.
  44684. * This can be super useful if you either get the data from an uncompressed source or
  44685. * if you wish to create your texture pixel by pixel.
  44686. * @param data define the array of data to use to create the texture
  44687. * @param width define the width of the texture
  44688. * @param height define the height of the texture
  44689. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  44690. * @param scene define the scene the texture belongs to
  44691. * @param generateMipMaps define whether mip maps should be generated or not
  44692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  44693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  44694. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  44695. */
  44696. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  44697. /**
  44698. * Updates the texture underlying data.
  44699. * @param data Define the new data of the texture
  44700. */
  44701. update(data: ArrayBufferView): void;
  44702. /**
  44703. * Creates a luminance texture from some data.
  44704. * @param data Define the texture data
  44705. * @param width Define the width of the texture
  44706. * @param height Define the height of the texture
  44707. * @param scene Define the scene the texture belongs to
  44708. * @param generateMipMaps Define whether or not to create mip maps for the texture
  44709. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  44710. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  44711. * @returns the luminance texture
  44712. */
  44713. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  44714. /**
  44715. * Creates a luminance alpha texture from some data.
  44716. * @param data Define the texture data
  44717. * @param width Define the width of the texture
  44718. * @param height Define the height of the texture
  44719. * @param scene Define the scene the texture belongs to
  44720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  44721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  44722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  44723. * @returns the luminance alpha texture
  44724. */
  44725. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  44726. /**
  44727. * Creates an alpha texture from some data.
  44728. * @param data Define the texture data
  44729. * @param width Define the width of the texture
  44730. * @param height Define the height of the texture
  44731. * @param scene Define the scene the texture belongs to
  44732. * @param generateMipMaps Define whether or not to create mip maps for the texture
  44733. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  44734. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  44735. * @returns the alpha texture
  44736. */
  44737. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  44738. /**
  44739. * Creates a RGB texture from some data.
  44740. * @param data Define the texture data
  44741. * @param width Define the width of the texture
  44742. * @param height Define the height of the texture
  44743. * @param scene Define the scene the texture belongs to
  44744. * @param generateMipMaps Define whether or not to create mip maps for the texture
  44745. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  44746. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  44747. * @returns the RGB alpha texture
  44748. */
  44749. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  44750. /**
  44751. * Creates a RGBA texture from some data.
  44752. * @param data Define the texture data
  44753. * @param width Define the width of the texture
  44754. * @param height Define the height of the texture
  44755. * @param scene Define the scene the texture belongs to
  44756. * @param generateMipMaps Define whether or not to create mip maps for the texture
  44757. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  44758. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  44759. * @returns the RGBA texture
  44760. */
  44761. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  44762. /**
  44763. * Creates a R texture from some data.
  44764. * @param data Define the texture data
  44765. * @param width Define the width of the texture
  44766. * @param height Define the height of the texture
  44767. * @param scene Define the scene the texture belongs to
  44768. * @param generateMipMaps Define whether or not to create mip maps for the texture
  44769. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  44770. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  44771. * @returns the R texture
  44772. */
  44773. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  44774. }
  44775. }
  44776. declare module BABYLON {
  44777. /**
  44778. * Class used to store 3D textures containing user data
  44779. */
  44780. class RawTexture3D extends Texture {
  44781. /** Gets or sets the texture format to use */
  44782. format: number;
  44783. private _engine;
  44784. /**
  44785. * Create a new RawTexture3D
  44786. * @param data defines the data of the texture
  44787. * @param width defines the width of the texture
  44788. * @param height defines the height of the texture
  44789. * @param depth defines the depth of the texture
  44790. * @param format defines the texture format to use
  44791. * @param scene defines the hosting scene
  44792. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  44793. * @param invertY defines if texture must be stored with Y axis inverted
  44794. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  44795. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  44796. */
  44797. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  44798. /** Gets or sets the texture format to use */
  44799. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  44800. /**
  44801. * Update the texture with new data
  44802. * @param data defines the data to store in the texture
  44803. */
  44804. update(data: ArrayBufferView): void;
  44805. }
  44806. }
  44807. declare module BABYLON {
  44808. /**
  44809. * Creates a refraction texture used by refraction channel of the standard material.
  44810. * It is like a mirror but to see through a material.
  44811. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  44812. */
  44813. class RefractionTexture extends RenderTargetTexture {
  44814. /**
  44815. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  44816. * 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.
  44817. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  44818. */
  44819. refractionPlane: Plane;
  44820. /**
  44821. * Define how deep under the surface we should see.
  44822. */
  44823. depth: number;
  44824. /**
  44825. * Creates a refraction texture used by refraction channel of the standard material.
  44826. * It is like a mirror but to see through a material.
  44827. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  44828. * @param name Define the texture name
  44829. * @param size Define the size of the underlying texture
  44830. * @param scene Define the scene the refraction belongs to
  44831. * @param generateMipMaps Define if we need to generate mips level for the refraction
  44832. */
  44833. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  44834. /**
  44835. * Clone the refraction texture.
  44836. * @returns the cloned texture
  44837. */
  44838. clone(): RefractionTexture;
  44839. /**
  44840. * Serialize the texture to a JSON representation you could use in Parse later on
  44841. * @returns the serialized JSON representation
  44842. */
  44843. serialize(): any;
  44844. }
  44845. }
  44846. declare module BABYLON {
  44847. class RenderTargetTexture extends Texture {
  44848. isCube: boolean;
  44849. static _REFRESHRATE_RENDER_ONCE: number;
  44850. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  44851. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  44852. static readonly REFRESHRATE_RENDER_ONCE: number;
  44853. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  44854. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  44855. /**
  44856. * Use this predicate to dynamically define the list of mesh you want to render.
  44857. * If set, the renderList property will be overwritten.
  44858. */
  44859. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  44860. private _renderList;
  44861. /**
  44862. * Use this list to define the list of mesh you want to render.
  44863. */
  44864. renderList: Nullable<Array<AbstractMesh>>;
  44865. private _hookArray;
  44866. renderParticles: boolean;
  44867. renderSprites: boolean;
  44868. coordinatesMode: number;
  44869. activeCamera: Nullable<Camera>;
  44870. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  44871. useCameraPostProcesses: boolean;
  44872. ignoreCameraViewport: boolean;
  44873. private _postProcessManager;
  44874. private _postProcesses;
  44875. private _resizeObserver;
  44876. /**
  44877. * An event triggered when the texture is unbind.
  44878. */
  44879. onBeforeBindObservable: Observable<RenderTargetTexture>;
  44880. /**
  44881. * An event triggered when the texture is unbind.
  44882. */
  44883. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  44884. private _onAfterUnbindObserver;
  44885. onAfterUnbind: () => void;
  44886. /**
  44887. * An event triggered before rendering the texture
  44888. */
  44889. onBeforeRenderObservable: Observable<number>;
  44890. private _onBeforeRenderObserver;
  44891. onBeforeRender: (faceIndex: number) => void;
  44892. /**
  44893. * An event triggered after rendering the texture
  44894. */
  44895. onAfterRenderObservable: Observable<number>;
  44896. private _onAfterRenderObserver;
  44897. onAfterRender: (faceIndex: number) => void;
  44898. /**
  44899. * An event triggered after the texture clear
  44900. */
  44901. onClearObservable: Observable<Engine>;
  44902. private _onClearObserver;
  44903. onClear: (Engine: Engine) => void;
  44904. clearColor: Color4;
  44905. protected _size: number | {
  44906. width: number;
  44907. height: number;
  44908. };
  44909. protected _initialSizeParameter: number | {
  44910. width: number;
  44911. height: number;
  44912. } | {
  44913. ratio: number;
  44914. };
  44915. protected _sizeRatio: Nullable<number>;
  44916. /** @hidden */
  44917. _generateMipMaps: boolean;
  44918. protected _renderingManager: RenderingManager;
  44919. /** @hidden */
  44920. _waitingRenderList: string[];
  44921. protected _doNotChangeAspectRatio: boolean;
  44922. protected _currentRefreshId: number;
  44923. protected _refreshRate: number;
  44924. protected _textureMatrix: Matrix;
  44925. protected _samples: number;
  44926. protected _renderTargetOptions: RenderTargetCreationOptions;
  44927. readonly renderTargetOptions: RenderTargetCreationOptions;
  44928. protected _engine: Engine;
  44929. protected _onRatioRescale(): void;
  44930. /**
  44931. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  44932. * It must define where the camera used to render the texture is set
  44933. */
  44934. boundingBoxPosition: Vector3;
  44935. private _boundingBoxSize;
  44936. /**
  44937. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  44938. * When defined, the cubemap will switch to local mode
  44939. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  44940. * @example https://www.babylonjs-playground.com/#RNASML
  44941. */
  44942. boundingBoxSize: Vector3;
  44943. /**
  44944. * In case the RTT has been created with a depth texture, get the associated
  44945. * depth texture.
  44946. * Otherwise, return null.
  44947. */
  44948. depthStencilTexture: Nullable<InternalTexture>;
  44949. /**
  44950. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  44951. * or used a shadow, depth texture...
  44952. * @param name The friendly name of the texture
  44953. * @param size The size of the RTT (number if square, or {with: number, height:number} or {ratio:} to define a ratio from the main scene)
  44954. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  44955. * @param generateMipMaps True if mip maps need to be generated after render.
  44956. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  44957. * @param type The type of the buffer in the RTT (int, half float, float...)
  44958. * @param isCube True if a cube texture needs to be created
  44959. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  44960. * @param generateDepthBuffer True to generate a depth buffer
  44961. * @param generateStencilBuffer True to generate a stencil buffer
  44962. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  44963. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  44964. */
  44965. constructor(name: string, size: number | {
  44966. width: number;
  44967. height: number;
  44968. } | {
  44969. ratio: number;
  44970. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  44971. /**
  44972. * Creates a depth stencil texture.
  44973. * This is only available in WebGL 2 or with the depth texture extension available.
  44974. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  44975. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  44976. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  44977. */
  44978. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  44979. private _processSizeParameter;
  44980. samples: number;
  44981. /**
  44982. * Resets the refresh counter of the texture and start bak from scratch.
  44983. * Could be usefull to regenerate the texture if it is setup to render only once.
  44984. */
  44985. resetRefreshCounter(): void;
  44986. /**
  44987. * Define the refresh rate of the texture or the rendering frequency.
  44988. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  44989. */
  44990. refreshRate: number;
  44991. addPostProcess(postProcess: PostProcess): void;
  44992. clearPostProcesses(dispose?: boolean): void;
  44993. removePostProcess(postProcess: PostProcess): void;
  44994. /** @hidden */
  44995. _shouldRender(): boolean;
  44996. getRenderSize(): number;
  44997. getRenderWidth(): number;
  44998. getRenderHeight(): number;
  44999. readonly canRescale: boolean;
  45000. scale(ratio: number): void;
  45001. getReflectionTextureMatrix(): Matrix;
  45002. resize(size: number | {
  45003. width: number;
  45004. height: number;
  45005. } | {
  45006. ratio: number;
  45007. }): void;
  45008. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  45009. private _bestReflectionRenderTargetDimension;
  45010. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45011. private renderToTarget;
  45012. /**
  45013. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  45014. * This allowed control for front to back rendering or reversly depending of the special needs.
  45015. *
  45016. * @param renderingGroupId The rendering group id corresponding to its index
  45017. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  45018. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  45019. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  45020. */
  45021. 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;
  45022. /**
  45023. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  45024. *
  45025. * @param renderingGroupId The rendering group id corresponding to its index
  45026. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45027. */
  45028. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  45029. clone(): RenderTargetTexture;
  45030. serialize(): any;
  45031. disposeFramebufferObjects(): void;
  45032. dispose(): void;
  45033. /** @hidden */
  45034. _rebuild(): void;
  45035. /**
  45036. * Clear the info related to rendering groups preventing retention point in material dispose.
  45037. */
  45038. freeRenderingGroups(): void;
  45039. }
  45040. }
  45041. declare module BABYLON {
  45042. class Texture extends BaseTexture {
  45043. static NEAREST_SAMPLINGMODE: number;
  45044. static NEAREST_NEAREST_MIPLINEAR: number;
  45045. static BILINEAR_SAMPLINGMODE: number;
  45046. static LINEAR_LINEAR_MIPNEAREST: number;
  45047. static TRILINEAR_SAMPLINGMODE: number;
  45048. static LINEAR_LINEAR_MIPLINEAR: number;
  45049. static NEAREST_NEAREST_MIPNEAREST: number;
  45050. static NEAREST_LINEAR_MIPNEAREST: number;
  45051. static NEAREST_LINEAR_MIPLINEAR: number;
  45052. static NEAREST_LINEAR: number;
  45053. static NEAREST_NEAREST: number;
  45054. static LINEAR_NEAREST_MIPNEAREST: number;
  45055. static LINEAR_NEAREST_MIPLINEAR: number;
  45056. static LINEAR_LINEAR: number;
  45057. static LINEAR_NEAREST: number;
  45058. static EXPLICIT_MODE: number;
  45059. static SPHERICAL_MODE: number;
  45060. static PLANAR_MODE: number;
  45061. static CUBIC_MODE: number;
  45062. static PROJECTION_MODE: number;
  45063. static SKYBOX_MODE: number;
  45064. static INVCUBIC_MODE: number;
  45065. static EQUIRECTANGULAR_MODE: number;
  45066. static FIXED_EQUIRECTANGULAR_MODE: number;
  45067. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  45068. static readonly CLAMP_ADDRESSMODE: number;
  45069. static readonly WRAP_ADDRESSMODE: number;
  45070. static readonly MIRROR_ADDRESSMODE: number;
  45071. /**
  45072. * 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
  45073. */
  45074. static UseSerializedUrlIfAny: boolean;
  45075. url: Nullable<string>;
  45076. uOffset: number;
  45077. vOffset: number;
  45078. uScale: number;
  45079. vScale: number;
  45080. uAng: number;
  45081. vAng: number;
  45082. wAng: number;
  45083. /**
  45084. * Defines the center of rotation (U)
  45085. */
  45086. uRotationCenter: number;
  45087. /**
  45088. * Defines the center of rotation (V)
  45089. */
  45090. vRotationCenter: number;
  45091. /**
  45092. * Defines the center of rotation (W)
  45093. */
  45094. wRotationCenter: number;
  45095. readonly noMipmap: boolean;
  45096. private _noMipmap;
  45097. /** @hidden */
  45098. _invertY: boolean;
  45099. private _rowGenerationMatrix;
  45100. private _cachedTextureMatrix;
  45101. private _projectionModeMatrix;
  45102. private _t0;
  45103. private _t1;
  45104. private _t2;
  45105. private _cachedUOffset;
  45106. private _cachedVOffset;
  45107. private _cachedUScale;
  45108. private _cachedVScale;
  45109. private _cachedUAng;
  45110. private _cachedVAng;
  45111. private _cachedWAng;
  45112. private _cachedProjectionMatrixId;
  45113. private _cachedCoordinatesMode;
  45114. /** @hidden */
  45115. _samplingMode: number;
  45116. /** @hidden */
  45117. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  45118. private _deleteBuffer;
  45119. protected _format: Nullable<number>;
  45120. private _delayedOnLoad;
  45121. private _delayedOnError;
  45122. protected _onLoadObservable: Nullable<Observable<Texture>>;
  45123. protected _isBlocking: boolean;
  45124. isBlocking: boolean;
  45125. readonly samplingMode: number;
  45126. 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);
  45127. /**
  45128. * Update the url (and optional buffer) of this texture if url was null during construction.
  45129. * @param url the url of the texture
  45130. * @param buffer the buffer of the texture (defaults to null)
  45131. */
  45132. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  45133. delayLoad(): void;
  45134. /**
  45135. * Default is Trilinear mode.
  45136. *
  45137. * | Value | Type | Description |
  45138. * | ----- | ------------------ | ----------- |
  45139. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  45140. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  45141. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  45142. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  45143. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  45144. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  45145. * | 7 | NEAREST_LINEAR | |
  45146. * | 8 | NEAREST_NEAREST | |
  45147. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  45148. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  45149. * | 11 | LINEAR_LINEAR | |
  45150. * | 12 | LINEAR_NEAREST | |
  45151. *
  45152. * > _mag_: magnification filter (close to the viewer)
  45153. * > _min_: minification filter (far from the viewer)
  45154. * > _mip_: filter used between mip map levels
  45155. *
  45156. */
  45157. updateSamplingMode(samplingMode: number): void;
  45158. private _prepareRowForTextureGeneration;
  45159. getTextureMatrix(): Matrix;
  45160. getReflectionTextureMatrix(): Matrix;
  45161. clone(): Texture;
  45162. readonly onLoadObservable: Observable<Texture>;
  45163. serialize(): any;
  45164. getClassName(): string;
  45165. dispose(): void;
  45166. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  45167. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  45168. 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;
  45169. }
  45170. }
  45171. declare module BABYLON {
  45172. /**
  45173. * Settings for finer control over video usage
  45174. */
  45175. interface VideoTextureSettings {
  45176. /**
  45177. * Applies `autoplay` to video, if specified
  45178. */
  45179. autoPlay?: boolean;
  45180. /**
  45181. * Applies `loop` to video, if specified
  45182. */
  45183. loop?: boolean;
  45184. /**
  45185. * Automatically updates internal texture from video at every frame in the render loop
  45186. */
  45187. autoUpdateTexture: boolean;
  45188. /**
  45189. * Image src displayed during the video loading or until the user interacts with the video.
  45190. */
  45191. poster?: string;
  45192. }
  45193. /**
  45194. * If you want to display a video in your scene, this is the special texture for that.
  45195. * This special texture works similar to other textures, with the exception of a few parameters.
  45196. * @see https://doc.babylonjs.com/how_to/video_texture
  45197. */
  45198. class VideoTexture extends Texture {
  45199. /**
  45200. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  45201. */
  45202. readonly autoUpdateTexture: boolean;
  45203. /**
  45204. * The video instance used by the texture internally
  45205. */
  45206. readonly video: HTMLVideoElement;
  45207. private _onUserActionRequestedObservable;
  45208. /**
  45209. * Event triggerd when a dom action is required by the user to play the video.
  45210. * This happens due to recent changes in browser policies preventing video to auto start.
  45211. */
  45212. readonly onUserActionRequestedObservable: Observable<Texture>;
  45213. private _generateMipMaps;
  45214. private _engine;
  45215. private _stillImageCaptured;
  45216. private _poster;
  45217. /**
  45218. * Creates a video texture.
  45219. * If you want to display a video in your scene, this is the special texture for that.
  45220. * This special texture works similar to other textures, with the exception of a few parameters.
  45221. * @see https://doc.babylonjs.com/how_to/video_texture
  45222. * @param {string | null} name optional name, will detect from video source, if not defined
  45223. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  45224. * @param {BABYLON.Scene} scene is obviously the current scene.
  45225. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  45226. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  45227. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  45228. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  45229. */
  45230. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  45231. private _getName;
  45232. private _getVideo;
  45233. private _createInternalTexture;
  45234. private reset;
  45235. /**
  45236. * @hidden Internal method to initiate `update`.
  45237. */
  45238. _rebuild(): void;
  45239. /**
  45240. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  45241. */
  45242. update(): void;
  45243. /**
  45244. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  45245. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  45246. */
  45247. updateTexture(isVisible: boolean): void;
  45248. protected _updateInternalTexture: (e?: Event | undefined) => void;
  45249. /**
  45250. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  45251. * @param url New url.
  45252. */
  45253. updateURL(url: string): void;
  45254. /**
  45255. * Dispose the texture and release its associated resources.
  45256. */
  45257. dispose(): void;
  45258. /**
  45259. * Creates a video texture straight from your WebCam video feed.
  45260. * @param scene Define the scene the texture should be created in
  45261. * @param onReady Define a callback to triggered once the texture will be ready
  45262. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  45263. */
  45264. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  45265. minWidth: number;
  45266. maxWidth: number;
  45267. minHeight: number;
  45268. maxHeight: number;
  45269. deviceId: string;
  45270. }): void;
  45271. }
  45272. }
  45273. declare var DracoDecoderModule: any;
  45274. declare var WebAssembly: any;
  45275. declare module BABYLON {
  45276. /**
  45277. * Configuration for Draco compression
  45278. */
  45279. interface IDracoCompressionConfiguration {
  45280. /**
  45281. * Configuration for the decoder.
  45282. */
  45283. decoder?: {
  45284. /**
  45285. * The url to the WebAssembly module.
  45286. */
  45287. wasmUrl?: string;
  45288. /**
  45289. * The url to the WebAssembly binary.
  45290. */
  45291. wasmBinaryUrl?: string;
  45292. /**
  45293. * The url to the fallback JavaScript module.
  45294. */
  45295. fallbackUrl?: string;
  45296. };
  45297. }
  45298. /**
  45299. * Draco compression (https://google.github.io/draco/)
  45300. *
  45301. * This class wraps the Draco module.
  45302. *
  45303. * **Encoder**
  45304. *
  45305. * The encoder is not currently implemented.
  45306. *
  45307. * **Decoder**
  45308. *
  45309. * 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.
  45310. *
  45311. * To update the configuration, use the following code:
  45312. * ```javascript
  45313. * BABYLON.DracoCompression.Configuration = {
  45314. * decoder: {
  45315. * wasmUrl: "<url to the WebAssembly library>",
  45316. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  45317. * fallbackUrl: "<url to the fallback JavaScript library>",
  45318. * }
  45319. * };
  45320. * ```
  45321. *
  45322. * 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.
  45323. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  45324. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  45325. *
  45326. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  45327. * ```javascript
  45328. * var dracoCompression = new BABYLON.DracoCompression();
  45329. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  45330. * [BABYLON.VertexBuffer.PositionKind]: 0
  45331. * });
  45332. * ```
  45333. *
  45334. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  45335. */
  45336. class DracoCompression implements IDisposable {
  45337. private static _DecoderModulePromise;
  45338. /**
  45339. * The configuration. Defaults to the following urls:
  45340. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  45341. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  45342. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  45343. */
  45344. static Configuration: IDracoCompressionConfiguration;
  45345. /**
  45346. * Returns true if the decoder is available.
  45347. */
  45348. static readonly DecoderAvailable: boolean;
  45349. /**
  45350. * Constructor
  45351. */
  45352. constructor();
  45353. /**
  45354. * Stop all async operations and release resources.
  45355. */
  45356. dispose(): void;
  45357. /**
  45358. * Decode Draco compressed mesh data to vertex data.
  45359. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  45360. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  45361. * @returns A promise that resolves with the decoded vertex data
  45362. */
  45363. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  45364. [kind: string]: number;
  45365. }): Promise<VertexData>;
  45366. private static _GetDecoderModule;
  45367. private static _LoadScriptAsync;
  45368. private static _LoadFileAsync;
  45369. }
  45370. }
  45371. declare module BABYLON {
  45372. /**
  45373. * Particle emitter emitting particles from the inside of a box.
  45374. * It emits the particles randomly between 2 given directions.
  45375. */
  45376. class BoxParticleEmitter implements IParticleEmitterType {
  45377. /**
  45378. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  45379. */
  45380. direction1: Vector3;
  45381. /**
  45382. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  45383. */
  45384. direction2: Vector3;
  45385. /**
  45386. * 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.
  45387. */
  45388. minEmitBox: Vector3;
  45389. /**
  45390. * 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.
  45391. */
  45392. maxEmitBox: Vector3;
  45393. /**
  45394. * Creates a new instance BoxParticleEmitter
  45395. */
  45396. constructor();
  45397. /**
  45398. * Called by the particle System when the direction is computed for the created particle.
  45399. * @param worldMatrix is the world matrix of the particle system
  45400. * @param directionToUpdate is the direction vector to update with the result
  45401. * @param particle is the particle we are computed the direction for
  45402. */
  45403. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  45404. /**
  45405. * Called by the particle System when the position is computed for the created particle.
  45406. * @param worldMatrix is the world matrix of the particle system
  45407. * @param positionToUpdate is the position vector to update with the result
  45408. * @param particle is the particle we are computed the position for
  45409. */
  45410. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  45411. /**
  45412. * Clones the current emitter and returns a copy of it
  45413. * @returns the new emitter
  45414. */
  45415. clone(): BoxParticleEmitter;
  45416. /**
  45417. * Called by the GPUParticleSystem to setup the update shader
  45418. * @param effect defines the update shader
  45419. */
  45420. applyToShader(effect: Effect): void;
  45421. /**
  45422. * Returns a string to use to update the GPU particles update shader
  45423. * @returns a string containng the defines string
  45424. */
  45425. getEffectDefines(): string;
  45426. /**
  45427. * Returns the string "BoxParticleEmitter"
  45428. * @returns a string containing the class name
  45429. */
  45430. getClassName(): string;
  45431. /**
  45432. * Serializes the particle system to a JSON object.
  45433. * @returns the JSON object
  45434. */
  45435. serialize(): any;
  45436. /**
  45437. * Parse properties from a JSON object
  45438. * @param serializationObject defines the JSON object
  45439. */
  45440. parse(serializationObject: any): void;
  45441. }
  45442. }
  45443. declare module BABYLON {
  45444. /**
  45445. * Particle emitter emitting particles from the inside of a cone.
  45446. * It emits the particles alongside the cone volume from the base to the particle.
  45447. * The emission direction might be randomized.
  45448. */
  45449. class ConeParticleEmitter implements IParticleEmitterType {
  45450. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  45451. directionRandomizer: number;
  45452. private _radius;
  45453. private _angle;
  45454. private _height;
  45455. /**
  45456. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  45457. */
  45458. radiusRange: number;
  45459. /**
  45460. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  45461. */
  45462. heightRange: number;
  45463. /**
  45464. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  45465. */
  45466. emitFromSpawnPointOnly: boolean;
  45467. /**
  45468. * Gets or sets the radius of the emission cone
  45469. */
  45470. radius: number;
  45471. /**
  45472. * Gets or sets the angle of the emission cone
  45473. */
  45474. angle: number;
  45475. private _buildHeight;
  45476. /**
  45477. * Creates a new instance ConeParticleEmitter
  45478. * @param radius the radius of the emission cone (1 by default)
  45479. * @param angles the cone base angle (PI by default)
  45480. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  45481. */
  45482. constructor(radius?: number, angle?: number,
  45483. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  45484. directionRandomizer?: number);
  45485. /**
  45486. * Called by the particle System when the direction is computed for the created particle.
  45487. * @param worldMatrix is the world matrix of the particle system
  45488. * @param directionToUpdate is the direction vector to update with the result
  45489. * @param particle is the particle we are computed the direction for
  45490. */
  45491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  45492. /**
  45493. * Called by the particle System when the position is computed for the created particle.
  45494. * @param worldMatrix is the world matrix of the particle system
  45495. * @param positionToUpdate is the position vector to update with the result
  45496. * @param particle is the particle we are computed the position for
  45497. */
  45498. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  45499. /**
  45500. * Clones the current emitter and returns a copy of it
  45501. * @returns the new emitter
  45502. */
  45503. clone(): ConeParticleEmitter;
  45504. /**
  45505. * Called by the GPUParticleSystem to setup the update shader
  45506. * @param effect defines the update shader
  45507. */
  45508. applyToShader(effect: Effect): void;
  45509. /**
  45510. * Returns a string to use to update the GPU particles update shader
  45511. * @returns a string containng the defines string
  45512. */
  45513. getEffectDefines(): string;
  45514. /**
  45515. * Returns the string "ConeParticleEmitter"
  45516. * @returns a string containing the class name
  45517. */
  45518. getClassName(): string;
  45519. /**
  45520. * Serializes the particle system to a JSON object.
  45521. * @returns the JSON object
  45522. */
  45523. serialize(): any;
  45524. /**
  45525. * Parse properties from a JSON object
  45526. * @param serializationObject defines the JSON object
  45527. */
  45528. parse(serializationObject: any): void;
  45529. }
  45530. }
  45531. declare module BABYLON {
  45532. /**
  45533. * Particle emitter emitting particles from the inside of a cylinder.
  45534. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  45535. */
  45536. class CylinderParticleEmitter implements IParticleEmitterType {
  45537. /**
  45538. * The radius of the emission cylinder.
  45539. */
  45540. radius: number;
  45541. /**
  45542. * The height of the emission cylinder.
  45543. */
  45544. height: number;
  45545. /**
  45546. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  45547. */
  45548. radiusRange: number;
  45549. /**
  45550. * How much to randomize the particle direction [0-1].
  45551. */
  45552. directionRandomizer: number;
  45553. /**
  45554. * Creates a new instance CylinderParticleEmitter
  45555. * @param radius the radius of the emission cylinder (1 by default)
  45556. * @param height the height of the emission cylinder (1 by default)
  45557. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  45558. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  45559. */
  45560. constructor(
  45561. /**
  45562. * The radius of the emission cylinder.
  45563. */
  45564. radius?: number,
  45565. /**
  45566. * The height of the emission cylinder.
  45567. */
  45568. height?: number,
  45569. /**
  45570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  45571. */
  45572. radiusRange?: number,
  45573. /**
  45574. * How much to randomize the particle direction [0-1].
  45575. */
  45576. directionRandomizer?: number);
  45577. /**
  45578. * Called by the particle System when the direction is computed for the created particle.
  45579. * @param worldMatrix is the world matrix of the particle system
  45580. * @param directionToUpdate is the direction vector to update with the result
  45581. * @param particle is the particle we are computed the direction for
  45582. */
  45583. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  45584. /**
  45585. * Called by the particle System when the position is computed for the created particle.
  45586. * @param worldMatrix is the world matrix of the particle system
  45587. * @param positionToUpdate is the position vector to update with the result
  45588. * @param particle is the particle we are computed the position for
  45589. */
  45590. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  45591. /**
  45592. * Clones the current emitter and returns a copy of it
  45593. * @returns the new emitter
  45594. */
  45595. clone(): CylinderParticleEmitter;
  45596. /**
  45597. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  45598. * @param effect defines the update shader
  45599. */
  45600. applyToShader(effect: Effect): void;
  45601. /**
  45602. * Returns a string to use to update the GPU particles update shader
  45603. * @returns a string containng the defines string
  45604. */
  45605. getEffectDefines(): string;
  45606. /**
  45607. * Returns the string "CylinderParticleEmitter"
  45608. * @returns a string containing the class name
  45609. */
  45610. getClassName(): string;
  45611. /**
  45612. * Serializes the particle system to a JSON object.
  45613. * @returns the JSON object
  45614. */
  45615. serialize(): any;
  45616. /**
  45617. * Parse properties from a JSON object
  45618. * @param serializationObject defines the JSON object
  45619. */
  45620. parse(serializationObject: any): void;
  45621. }
  45622. /**
  45623. * Particle emitter emitting particles from the inside of a cylinder.
  45624. * It emits the particles randomly between two vectors.
  45625. */
  45626. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  45627. /**
  45628. * The min limit of the emission direction.
  45629. */
  45630. direction1: Vector3;
  45631. /**
  45632. * The max limit of the emission direction.
  45633. */
  45634. direction2: Vector3;
  45635. /**
  45636. * Creates a new instance CylinderDirectedParticleEmitter
  45637. * @param radius the radius of the emission cylinder (1 by default)
  45638. * @param height the height of the emission cylinder (1 by default)
  45639. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  45640. * @param direction1 the min limit of the emission direction (up vector by default)
  45641. * @param direction2 the max limit of the emission direction (up vector by default)
  45642. */
  45643. constructor(radius?: number, height?: number, radiusRange?: number,
  45644. /**
  45645. * The min limit of the emission direction.
  45646. */
  45647. direction1?: Vector3,
  45648. /**
  45649. * The max limit of the emission direction.
  45650. */
  45651. direction2?: Vector3);
  45652. /**
  45653. * Called by the particle System when the direction is computed for the created particle.
  45654. * @param worldMatrix is the world matrix of the particle system
  45655. * @param directionToUpdate is the direction vector to update with the result
  45656. * @param particle is the particle we are computed the direction for
  45657. */
  45658. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  45659. /**
  45660. * Clones the current emitter and returns a copy of it
  45661. * @returns the new emitter
  45662. */
  45663. clone(): CylinderDirectedParticleEmitter;
  45664. /**
  45665. * Called by the GPUParticleSystem to setup the update shader
  45666. * @param effect defines the update shader
  45667. */
  45668. applyToShader(effect: Effect): void;
  45669. /**
  45670. * Returns a string to use to update the GPU particles update shader
  45671. * @returns a string containng the defines string
  45672. */
  45673. getEffectDefines(): string;
  45674. /**
  45675. * Returns the string "CylinderDirectedParticleEmitter"
  45676. * @returns a string containing the class name
  45677. */
  45678. getClassName(): string;
  45679. /**
  45680. * Serializes the particle system to a JSON object.
  45681. * @returns the JSON object
  45682. */
  45683. serialize(): any;
  45684. /**
  45685. * Parse properties from a JSON object
  45686. * @param serializationObject defines the JSON object
  45687. */
  45688. parse(serializationObject: any): void;
  45689. }
  45690. }
  45691. declare module BABYLON {
  45692. /**
  45693. * Particle emitter emitting particles from the inside of a hemisphere.
  45694. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  45695. */
  45696. class HemisphericParticleEmitter implements IParticleEmitterType {
  45697. /**
  45698. * The radius of the emission hemisphere.
  45699. */
  45700. radius: number;
  45701. /**
  45702. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  45703. */
  45704. radiusRange: number;
  45705. /**
  45706. * How much to randomize the particle direction [0-1].
  45707. */
  45708. directionRandomizer: number;
  45709. /**
  45710. * Creates a new instance HemisphericParticleEmitter
  45711. * @param radius the radius of the emission hemisphere (1 by default)
  45712. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  45713. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  45714. */
  45715. constructor(
  45716. /**
  45717. * The radius of the emission hemisphere.
  45718. */
  45719. radius?: number,
  45720. /**
  45721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  45722. */
  45723. radiusRange?: number,
  45724. /**
  45725. * How much to randomize the particle direction [0-1].
  45726. */
  45727. directionRandomizer?: number);
  45728. /**
  45729. * Called by the particle System when the direction is computed for the created particle.
  45730. * @param worldMatrix is the world matrix of the particle system
  45731. * @param directionToUpdate is the direction vector to update with the result
  45732. * @param particle is the particle we are computed the direction for
  45733. */
  45734. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  45735. /**
  45736. * Called by the particle System when the position is computed for the created particle.
  45737. * @param worldMatrix is the world matrix of the particle system
  45738. * @param positionToUpdate is the position vector to update with the result
  45739. * @param particle is the particle we are computed the position for
  45740. */
  45741. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  45742. /**
  45743. * Clones the current emitter and returns a copy of it
  45744. * @returns the new emitter
  45745. */
  45746. clone(): HemisphericParticleEmitter;
  45747. /**
  45748. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  45749. * @param effect defines the update shader
  45750. */
  45751. applyToShader(effect: Effect): void;
  45752. /**
  45753. * Returns a string to use to update the GPU particles update shader
  45754. * @returns a string containng the defines string
  45755. */
  45756. getEffectDefines(): string;
  45757. /**
  45758. * Returns the string "HemisphericParticleEmitter"
  45759. * @returns a string containing the class name
  45760. */
  45761. getClassName(): string;
  45762. /**
  45763. * Serializes the particle system to a JSON object.
  45764. * @returns the JSON object
  45765. */
  45766. serialize(): any;
  45767. /**
  45768. * Parse properties from a JSON object
  45769. * @param serializationObject defines the JSON object
  45770. */
  45771. parse(serializationObject: any): void;
  45772. }
  45773. }
  45774. declare module BABYLON {
  45775. /**
  45776. * Particle emitter represents a volume emitting particles.
  45777. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  45778. */
  45779. interface IParticleEmitterType {
  45780. /**
  45781. * Called by the particle System when the direction is computed for the created particle.
  45782. * @param worldMatrix is the world matrix of the particle system
  45783. * @param directionToUpdate is the direction vector to update with the result
  45784. * @param particle is the particle we are computed the direction for
  45785. */
  45786. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  45787. /**
  45788. * Called by the particle System when the position is computed for the created particle.
  45789. * @param worldMatrix is the world matrix of the particle system
  45790. * @param positionToUpdate is the position vector to update with the result
  45791. * @param particle is the particle we are computed the position for
  45792. */
  45793. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  45794. /**
  45795. * Clones the current emitter and returns a copy of it
  45796. * @returns the new emitter
  45797. */
  45798. clone(): IParticleEmitterType;
  45799. /**
  45800. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  45801. * @param effect defines the update shader
  45802. */
  45803. applyToShader(effect: Effect): void;
  45804. /**
  45805. * Returns a string to use to update the GPU particles update shader
  45806. * @returns the effect defines string
  45807. */
  45808. getEffectDefines(): string;
  45809. /**
  45810. * Returns a string representing the class name
  45811. * @returns a string containing the class name
  45812. */
  45813. getClassName(): string;
  45814. /**
  45815. * Serializes the particle system to a JSON object.
  45816. * @returns the JSON object
  45817. */
  45818. serialize(): any;
  45819. /**
  45820. * Parse properties from a JSON object
  45821. * @param serializationObject defines the JSON object
  45822. */
  45823. parse(serializationObject: any): void;
  45824. }
  45825. }
  45826. declare module BABYLON {
  45827. /**
  45828. * Particle emitter emitting particles from a point.
  45829. * It emits the particles randomly between 2 given directions.
  45830. */
  45831. class PointParticleEmitter implements IParticleEmitterType {
  45832. /**
  45833. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  45834. */
  45835. direction1: Vector3;
  45836. /**
  45837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  45838. */
  45839. direction2: Vector3;
  45840. /**
  45841. * Creates a new instance PointParticleEmitter
  45842. */
  45843. constructor();
  45844. /**
  45845. * Called by the particle System when the direction is computed for the created particle.
  45846. * @param worldMatrix is the world matrix of the particle system
  45847. * @param directionToUpdate is the direction vector to update with the result
  45848. * @param particle is the particle we are computed the direction for
  45849. */
  45850. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  45851. /**
  45852. * Called by the particle System when the position is computed for the created particle.
  45853. * @param worldMatrix is the world matrix of the particle system
  45854. * @param positionToUpdate is the position vector to update with the result
  45855. * @param particle is the particle we are computed the position for
  45856. */
  45857. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  45858. /**
  45859. * Clones the current emitter and returns a copy of it
  45860. * @returns the new emitter
  45861. */
  45862. clone(): PointParticleEmitter;
  45863. /**
  45864. * Called by the GPUParticleSystem to setup the update shader
  45865. * @param effect defines the update shader
  45866. */
  45867. applyToShader(effect: Effect): void;
  45868. /**
  45869. * Returns a string to use to update the GPU particles update shader
  45870. * @returns a string containng the defines string
  45871. */
  45872. getEffectDefines(): string;
  45873. /**
  45874. * Returns the string "PointParticleEmitter"
  45875. * @returns a string containing the class name
  45876. */
  45877. getClassName(): string;
  45878. /**
  45879. * Serializes the particle system to a JSON object.
  45880. * @returns the JSON object
  45881. */
  45882. serialize(): any;
  45883. /**
  45884. * Parse properties from a JSON object
  45885. * @param serializationObject defines the JSON object
  45886. */
  45887. parse(serializationObject: any): void;
  45888. }
  45889. }
  45890. declare module BABYLON {
  45891. /**
  45892. * Particle emitter emitting particles from the inside of a sphere.
  45893. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  45894. */
  45895. class SphereParticleEmitter implements IParticleEmitterType {
  45896. /**
  45897. * The radius of the emission sphere.
  45898. */
  45899. radius: number;
  45900. /**
  45901. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  45902. */
  45903. radiusRange: number;
  45904. /**
  45905. * How much to randomize the particle direction [0-1].
  45906. */
  45907. directionRandomizer: number;
  45908. /**
  45909. * Creates a new instance SphereParticleEmitter
  45910. * @param radius the radius of the emission sphere (1 by default)
  45911. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  45912. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  45913. */
  45914. constructor(
  45915. /**
  45916. * The radius of the emission sphere.
  45917. */
  45918. radius?: number,
  45919. /**
  45920. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  45921. */
  45922. radiusRange?: number,
  45923. /**
  45924. * How much to randomize the particle direction [0-1].
  45925. */
  45926. directionRandomizer?: number);
  45927. /**
  45928. * Called by the particle System when the direction is computed for the created particle.
  45929. * @param worldMatrix is the world matrix of the particle system
  45930. * @param directionToUpdate is the direction vector to update with the result
  45931. * @param particle is the particle we are computed the direction for
  45932. */
  45933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  45934. /**
  45935. * Called by the particle System when the position is computed for the created particle.
  45936. * @param worldMatrix is the world matrix of the particle system
  45937. * @param positionToUpdate is the position vector to update with the result
  45938. * @param particle is the particle we are computed the position for
  45939. */
  45940. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  45941. /**
  45942. * Clones the current emitter and returns a copy of it
  45943. * @returns the new emitter
  45944. */
  45945. clone(): SphereParticleEmitter;
  45946. /**
  45947. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  45948. * @param effect defines the update shader
  45949. */
  45950. applyToShader(effect: Effect): void;
  45951. /**
  45952. * Returns a string to use to update the GPU particles update shader
  45953. * @returns a string containng the defines string
  45954. */
  45955. getEffectDefines(): string;
  45956. /**
  45957. * Returns the string "SphereParticleEmitter"
  45958. * @returns a string containing the class name
  45959. */
  45960. getClassName(): string;
  45961. /**
  45962. * Serializes the particle system to a JSON object.
  45963. * @returns the JSON object
  45964. */
  45965. serialize(): any;
  45966. /**
  45967. * Parse properties from a JSON object
  45968. * @param serializationObject defines the JSON object
  45969. */
  45970. parse(serializationObject: any): void;
  45971. }
  45972. /**
  45973. * Particle emitter emitting particles from the inside of a sphere.
  45974. * It emits the particles randomly between two vectors.
  45975. */
  45976. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  45977. /**
  45978. * The min limit of the emission direction.
  45979. */
  45980. direction1: Vector3;
  45981. /**
  45982. * The max limit of the emission direction.
  45983. */
  45984. direction2: Vector3;
  45985. /**
  45986. * Creates a new instance SphereDirectedParticleEmitter
  45987. * @param radius the radius of the emission sphere (1 by default)
  45988. * @param direction1 the min limit of the emission direction (up vector by default)
  45989. * @param direction2 the max limit of the emission direction (up vector by default)
  45990. */
  45991. constructor(radius?: number,
  45992. /**
  45993. * The min limit of the emission direction.
  45994. */
  45995. direction1?: Vector3,
  45996. /**
  45997. * The max limit of the emission direction.
  45998. */
  45999. direction2?: Vector3);
  46000. /**
  46001. * Called by the particle System when the direction is computed for the created particle.
  46002. * @param worldMatrix is the world matrix of the particle system
  46003. * @param directionToUpdate is the direction vector to update with the result
  46004. * @param particle is the particle we are computed the direction for
  46005. */
  46006. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  46007. /**
  46008. * Clones the current emitter and returns a copy of it
  46009. * @returns the new emitter
  46010. */
  46011. clone(): SphereDirectedParticleEmitter;
  46012. /**
  46013. * Called by the GPUParticleSystem to setup the update shader
  46014. * @param effect defines the update shader
  46015. */
  46016. applyToShader(effect: Effect): void;
  46017. /**
  46018. * Returns a string to use to update the GPU particles update shader
  46019. * @returns a string containng the defines string
  46020. */
  46021. getEffectDefines(): string;
  46022. /**
  46023. * Returns the string "SphereDirectedParticleEmitter"
  46024. * @returns a string containing the class name
  46025. */
  46026. getClassName(): string;
  46027. /**
  46028. * Serializes the particle system to a JSON object.
  46029. * @returns the JSON object
  46030. */
  46031. serialize(): any;
  46032. /**
  46033. * Parse properties from a JSON object
  46034. * @param serializationObject defines the JSON object
  46035. */
  46036. parse(serializationObject: any): void;
  46037. }
  46038. }
  46039. declare module BABYLON {
  46040. /** @hidden */
  46041. class CannonJSPlugin implements IPhysicsEnginePlugin {
  46042. private _useDeltaForWorldStep;
  46043. world: any;
  46044. name: string;
  46045. private _physicsMaterials;
  46046. private _fixedTimeStep;
  46047. BJSCANNON: any;
  46048. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  46049. setGravity(gravity: Vector3): void;
  46050. setTimeStep(timeStep: number): void;
  46051. getTimeStep(): number;
  46052. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  46053. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46054. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46055. generatePhysicsBody(impostor: PhysicsImpostor): void;
  46056. private _processChildMeshes;
  46057. removePhysicsBody(impostor: PhysicsImpostor): void;
  46058. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  46059. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  46060. private _addMaterial;
  46061. private _checkWithEpsilon;
  46062. private _createShape;
  46063. private _createHeightmap;
  46064. private _minus90X;
  46065. private _plus90X;
  46066. private _tmpPosition;
  46067. private _tmpDeltaPosition;
  46068. private _tmpUnityRotation;
  46069. private _updatePhysicsBodyTransformation;
  46070. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  46071. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  46072. isSupported(): boolean;
  46073. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46074. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46075. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46076. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46077. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  46078. getBodyMass(impostor: PhysicsImpostor): number;
  46079. getBodyFriction(impostor: PhysicsImpostor): number;
  46080. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  46081. getBodyRestitution(impostor: PhysicsImpostor): number;
  46082. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  46083. sleepBody(impostor: PhysicsImpostor): void;
  46084. wakeUpBody(impostor: PhysicsImpostor): void;
  46085. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  46086. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  46087. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  46088. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  46089. getRadius(impostor: PhysicsImpostor): number;
  46090. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  46091. dispose(): void;
  46092. private _extendNamespace;
  46093. }
  46094. }
  46095. declare module BABYLON {
  46096. /** @hidden */
  46097. class OimoJSPlugin implements IPhysicsEnginePlugin {
  46098. world: any;
  46099. name: string;
  46100. BJSOIMO: any;
  46101. constructor(iterations?: number);
  46102. setGravity(gravity: Vector3): void;
  46103. setTimeStep(timeStep: number): void;
  46104. getTimeStep(): number;
  46105. private _tmpImpostorsArray;
  46106. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  46107. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46108. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46109. generatePhysicsBody(impostor: PhysicsImpostor): void;
  46110. private _tmpPositionVector;
  46111. removePhysicsBody(impostor: PhysicsImpostor): void;
  46112. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  46113. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  46114. isSupported(): boolean;
  46115. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  46116. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  46117. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46118. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46119. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46120. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46121. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  46122. getBodyMass(impostor: PhysicsImpostor): number;
  46123. getBodyFriction(impostor: PhysicsImpostor): number;
  46124. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  46125. getBodyRestitution(impostor: PhysicsImpostor): number;
  46126. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  46127. sleepBody(impostor: PhysicsImpostor): void;
  46128. wakeUpBody(impostor: PhysicsImpostor): void;
  46129. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  46130. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  46131. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  46132. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  46133. getRadius(impostor: PhysicsImpostor): number;
  46134. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  46135. dispose(): void;
  46136. }
  46137. }
  46138. declare module BABYLON {
  46139. /**
  46140. * This represents a set of one or more post processes in Babylon.
  46141. * A post process can be used to apply a shader to a texture after it is rendered.
  46142. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  46143. */
  46144. class PostProcessRenderEffect {
  46145. private _postProcesses;
  46146. private _getPostProcesses;
  46147. private _singleInstance;
  46148. private _cameras;
  46149. private _indicesForCamera;
  46150. /**
  46151. * Name of the effect
  46152. * @hidden
  46153. */
  46154. _name: string;
  46155. /**
  46156. * Instantiates a post process render effect.
  46157. * A post process can be used to apply a shader to a texture after it is rendered.
  46158. * @param engine The engine the effect is tied to
  46159. * @param name The name of the effect
  46160. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  46161. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  46162. */
  46163. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  46164. /**
  46165. * Checks if all the post processes in the effect are supported.
  46166. */
  46167. readonly isSupported: boolean;
  46168. /**
  46169. * Updates the current state of the effect
  46170. * @hidden
  46171. */
  46172. _update(): void;
  46173. /**
  46174. * Attaches the effect on cameras
  46175. * @param cameras The camera to attach to.
  46176. * @hidden
  46177. */
  46178. _attachCameras(cameras: Camera): void;
  46179. /**
  46180. * Attaches the effect on cameras
  46181. * @param cameras The camera to attach to.
  46182. * @hidden
  46183. */
  46184. _attachCameras(cameras: Camera[]): void;
  46185. /**
  46186. * Detatches the effect on cameras
  46187. * @param cameras The camera to detatch from.
  46188. * @hidden
  46189. */
  46190. _detachCameras(cameras: Camera): void;
  46191. /**
  46192. * Detatches the effect on cameras
  46193. * @param cameras The camera to detatch from.
  46194. * @hidden
  46195. */
  46196. _detachCameras(cameras: Camera[]): void;
  46197. /**
  46198. * Enables the effect on given cameras
  46199. * @param cameras The camera to enable.
  46200. * @hidden
  46201. */
  46202. _enable(cameras: Camera): void;
  46203. /**
  46204. * Enables the effect on given cameras
  46205. * @param cameras The camera to enable.
  46206. * @hidden
  46207. */
  46208. _enable(cameras: Nullable<Camera[]>): void;
  46209. /**
  46210. * Disables the effect on the given cameras
  46211. * @param cameras The camera to disable.
  46212. * @hidden
  46213. */
  46214. _disable(cameras: Camera): void;
  46215. /**
  46216. * Disables the effect on the given cameras
  46217. * @param cameras The camera to disable.
  46218. * @hidden
  46219. */
  46220. _disable(cameras: Nullable<Camera[]>): void;
  46221. /**
  46222. * Gets a list of the post processes contained in the effect.
  46223. * @param camera The camera to get the post processes on.
  46224. * @returns The list of the post processes in the effect.
  46225. */
  46226. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /**
  46231. * PostProcessRenderPipeline
  46232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  46233. */
  46234. class PostProcessRenderPipeline {
  46235. private engine;
  46236. private _renderEffects;
  46237. private _renderEffectsForIsolatedPass;
  46238. /**
  46239. * @hidden
  46240. */
  46241. protected _cameras: Camera[];
  46242. /** @hidden */
  46243. _name: string;
  46244. /**
  46245. * Initializes a PostProcessRenderPipeline
  46246. * @param engine engine to add the pipeline to
  46247. * @param name name of the pipeline
  46248. */
  46249. constructor(engine: Engine, name: string);
  46250. /**
  46251. * "PostProcessRenderPipeline"
  46252. * @returns "PostProcessRenderPipeline"
  46253. */
  46254. getClassName(): string;
  46255. /**
  46256. * If all the render effects in the pipeline are support
  46257. */
  46258. readonly isSupported: boolean;
  46259. /**
  46260. * Adds an effect to the pipeline
  46261. * @param renderEffect the effect to add
  46262. */
  46263. addEffect(renderEffect: PostProcessRenderEffect): void;
  46264. /** @hidden */
  46265. _rebuild(): void;
  46266. /** @hidden */
  46267. _enableEffect(renderEffectName: string, cameras: Camera): void;
  46268. /** @hidden */
  46269. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  46270. /** @hidden */
  46271. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  46272. /** @hidden */
  46273. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  46274. /** @hidden */
  46275. _attachCameras(cameras: Camera, unique: boolean): void;
  46276. /** @hidden */
  46277. _attachCameras(cameras: Camera[], unique: boolean): void;
  46278. /** @hidden */
  46279. _detachCameras(cameras: Camera): void;
  46280. /** @hidden */
  46281. _detachCameras(cameras: Nullable<Camera[]>): void;
  46282. /** @hidden */
  46283. _update(): void;
  46284. /** @hidden */
  46285. _reset(): void;
  46286. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  46287. /**
  46288. * Disposes of the pipeline
  46289. */
  46290. dispose(): void;
  46291. }
  46292. }
  46293. declare module BABYLON {
  46294. /**
  46295. * PostProcessRenderPipelineManager class
  46296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  46297. */
  46298. class PostProcessRenderPipelineManager {
  46299. private _renderPipelines;
  46300. /**
  46301. * Initializes a PostProcessRenderPipelineManager
  46302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  46303. */
  46304. constructor();
  46305. /**
  46306. * Adds a pipeline to the manager
  46307. * @param renderPipeline The pipeline to add
  46308. */
  46309. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  46310. /**
  46311. * Attaches a camera to the pipeline
  46312. * @param renderPipelineName The name of the pipeline to attach to
  46313. * @param cameras the camera to attach
  46314. * @param unique if the camera can be attached multiple times to the pipeline
  46315. */
  46316. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  46317. /**
  46318. * Detaches a camera from the pipeline
  46319. * @param renderPipelineName The name of the pipeline to detach from
  46320. * @param cameras the camera to detach
  46321. */
  46322. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  46323. /**
  46324. * Enables an effect by name on a pipeline
  46325. * @param renderPipelineName the name of the pipeline to enable the effect in
  46326. * @param renderEffectName the name of the effect to enable
  46327. * @param cameras the cameras that the effect should be enabled on
  46328. */
  46329. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  46330. /**
  46331. * Disables an effect by name on a pipeline
  46332. * @param renderPipelineName the name of the pipeline to disable the effect in
  46333. * @param renderEffectName the name of the effect to disable
  46334. * @param cameras the cameras that the effect should be disabled on
  46335. */
  46336. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  46337. /**
  46338. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  46339. */
  46340. update(): void;
  46341. /** @hidden */
  46342. _rebuild(): void;
  46343. /**
  46344. * Disposes of the manager and pipelines
  46345. */
  46346. dispose(): void;
  46347. }
  46348. }
  46349. declare module BABYLON {
  46350. interface Scene {
  46351. /** @hidden (Backing field) */
  46352. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  46353. /**
  46354. * Gets the postprocess render pipeline manager
  46355. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  46356. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  46357. */
  46358. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  46359. }
  46360. /**
  46361. * Defines the Render Pipeline scene component responsible to rendering pipelines
  46362. */
  46363. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  46364. /**
  46365. * The component name helpfull to identify the component in the list of scene components.
  46366. */
  46367. readonly name: string;
  46368. /**
  46369. * The scene the component belongs to.
  46370. */
  46371. scene: Scene;
  46372. /**
  46373. * Creates a new instance of the component for the given scene
  46374. * @param scene Defines the scene to register the component in
  46375. */
  46376. constructor(scene: Scene);
  46377. /**
  46378. * Registers the component in a given scene
  46379. */
  46380. register(): void;
  46381. /**
  46382. * Rebuilds the elements related to this component in case of
  46383. * context lost for instance.
  46384. */
  46385. rebuild(): void;
  46386. /**
  46387. * Disposes the component and the associated ressources
  46388. */
  46389. dispose(): void;
  46390. private _gatherRenderTargets;
  46391. }
  46392. }
  46393. declare module BABYLON {
  46394. /**
  46395. * Helper class dealing with the extraction of spherical polynomial dataArray
  46396. * from a cube map.
  46397. */
  46398. class CubeMapToSphericalPolynomialTools {
  46399. private static FileFaces;
  46400. /**
  46401. * Converts a texture to the according Spherical Polynomial data.
  46402. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46403. *
  46404. * @param texture The texture to extract the information from.
  46405. * @return The Spherical Polynomial data.
  46406. */
  46407. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46408. /**
  46409. * Converts a cubemap to the according Spherical Polynomial data.
  46410. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46411. *
  46412. * @param cubeInfo The Cube map to extract the information from.
  46413. * @return The Spherical Polynomial data.
  46414. */
  46415. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46416. }
  46417. }
  46418. declare module BABYLON {
  46419. /**
  46420. * Header information of HDR texture files.
  46421. */
  46422. interface HDRInfo {
  46423. /**
  46424. * The height of the texture in pixels.
  46425. */
  46426. height: number;
  46427. /**
  46428. * The width of the texture in pixels.
  46429. */
  46430. width: number;
  46431. /**
  46432. * The index of the beginning of the data in the binary file.
  46433. */
  46434. dataPosition: number;
  46435. }
  46436. /**
  46437. * This groups tools to convert HDR texture to native colors array.
  46438. */
  46439. class HDRTools {
  46440. private static Ldexp;
  46441. private static Rgbe2float;
  46442. private static readStringLine;
  46443. /**
  46444. * Reads header information from an RGBE texture stored in a native array.
  46445. * More information on this format are available here:
  46446. * https://en.wikipedia.org/wiki/RGBE_image_format
  46447. *
  46448. * @param uint8array The binary file stored in native array.
  46449. * @return The header information.
  46450. */
  46451. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46452. /**
  46453. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46454. * This RGBE texture needs to store the information as a panorama.
  46455. *
  46456. * More information on this format are available here:
  46457. * https://en.wikipedia.org/wiki/RGBE_image_format
  46458. *
  46459. * @param buffer The binary file stored in an array buffer.
  46460. * @param size The expected size of the extracted cubemap.
  46461. * @return The Cube Map information.
  46462. */
  46463. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46464. /**
  46465. * Returns the pixels data extracted from an RGBE texture.
  46466. * This pixels will be stored left to right up to down in the R G B order in one array.
  46467. *
  46468. * More information on this format are available here:
  46469. * https://en.wikipedia.org/wiki/RGBE_image_format
  46470. *
  46471. * @param uint8array The binary file stored in an array buffer.
  46472. * @param hdrInfo The header information of the file.
  46473. * @return The pixels data in RGB right to left up to down order.
  46474. */
  46475. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46476. private static RGBE_ReadPixels_RLE;
  46477. }
  46478. }
  46479. declare module BABYLON {
  46480. /**
  46481. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46482. */
  46483. interface CubeMapInfo {
  46484. /**
  46485. * The pixel array for the front face.
  46486. * This is stored in format, left to right, up to down format.
  46487. */
  46488. front: Nullable<ArrayBufferView>;
  46489. /**
  46490. * The pixel array for the back face.
  46491. * This is stored in format, left to right, up to down format.
  46492. */
  46493. back: Nullable<ArrayBufferView>;
  46494. /**
  46495. * The pixel array for the left face.
  46496. * This is stored in format, left to right, up to down format.
  46497. */
  46498. left: Nullable<ArrayBufferView>;
  46499. /**
  46500. * The pixel array for the right face.
  46501. * This is stored in format, left to right, up to down format.
  46502. */
  46503. right: Nullable<ArrayBufferView>;
  46504. /**
  46505. * The pixel array for the up face.
  46506. * This is stored in format, left to right, up to down format.
  46507. */
  46508. up: Nullable<ArrayBufferView>;
  46509. /**
  46510. * The pixel array for the down face.
  46511. * This is stored in format, left to right, up to down format.
  46512. */
  46513. down: Nullable<ArrayBufferView>;
  46514. /**
  46515. * The size of the cubemap stored.
  46516. *
  46517. * Each faces will be size * size pixels.
  46518. */
  46519. size: number;
  46520. /**
  46521. * The format of the texture.
  46522. *
  46523. * RGBA, RGB.
  46524. */
  46525. format: number;
  46526. /**
  46527. * The type of the texture data.
  46528. *
  46529. * UNSIGNED_INT, FLOAT.
  46530. */
  46531. type: number;
  46532. /**
  46533. * Specifies whether the texture is in gamma space.
  46534. */
  46535. gammaSpace: boolean;
  46536. }
  46537. /**
  46538. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  46539. */
  46540. class PanoramaToCubeMapTools {
  46541. private static FACE_FRONT;
  46542. private static FACE_BACK;
  46543. private static FACE_RIGHT;
  46544. private static FACE_LEFT;
  46545. private static FACE_DOWN;
  46546. private static FACE_UP;
  46547. /**
  46548. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46549. *
  46550. * @param float32Array The source data.
  46551. * @param inputWidth The width of the input panorama.
  46552. * @param inputhHeight The height of the input panorama.
  46553. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46554. * @return The cubemap data
  46555. */
  46556. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46557. private static CreateCubemapTexture;
  46558. private static CalcProjectionSpherical;
  46559. }
  46560. }
  46561. declare module BABYLON {
  46562. }
  46563. declare module BABYLON {
  46564. }
  46565. declare module BABYLON {
  46566. }
  46567. declare module BABYLON {
  46568. }
  46569. declare module BABYLON {
  46570. /**
  46571. * 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.
  46572. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46573. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46574. */
  46575. class CustomProceduralTexture extends ProceduralTexture {
  46576. private _animate;
  46577. private _time;
  46578. private _config;
  46579. private _texturePath;
  46580. /**
  46581. * Instantiates a new Custom Procedural Texture.
  46582. * 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.
  46583. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46584. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46585. * @param name Define the name of the texture
  46586. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  46587. * @param size Define the size of the texture to create
  46588. * @param scene Define the scene the texture belongs to
  46589. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  46590. * @param generateMipMaps Define if the texture should creates mip maps or not
  46591. */
  46592. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46593. private _loadJson;
  46594. /**
  46595. * Is the texture ready to be used ? (rendered at least once)
  46596. * @returns true if ready, otherwise, false.
  46597. */
  46598. isReady(): boolean;
  46599. /**
  46600. * Render the texture to its associated render target.
  46601. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  46602. */
  46603. render(useCameraPostProcess?: boolean): void;
  46604. /**
  46605. * Update the list of dependant textures samplers in the shader.
  46606. */
  46607. updateTextures(): void;
  46608. /**
  46609. * Update the uniform values of the procedural texture in the shader.
  46610. */
  46611. updateShaderUniforms(): void;
  46612. /**
  46613. * Define if the texture animates or not.
  46614. */
  46615. animate: boolean;
  46616. }
  46617. }
  46618. declare module BABYLON {
  46619. /**
  46620. * Class used to generate noise procedural textures
  46621. */
  46622. class NoiseProceduralTexture extends ProceduralTexture {
  46623. private _time;
  46624. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  46625. brightness: number;
  46626. /** Defines the number of octaves to process */
  46627. octaves: number;
  46628. /** Defines the level of persistence (0.8 by default) */
  46629. persistence: number;
  46630. /** Gets or sets animation speed factor (default is 1) */
  46631. animationSpeedFactor: number;
  46632. /**
  46633. * Creates a new NoiseProceduralTexture
  46634. * @param name defines the name fo the texture
  46635. * @param size defines the size of the texture (default is 256)
  46636. * @param scene defines the hosting scene
  46637. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  46638. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  46639. */
  46640. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46641. private _updateShaderUniforms;
  46642. protected _getDefines(): string;
  46643. /** Generate the current state of the procedural texture */
  46644. render(useCameraPostProcess?: boolean): void;
  46645. /**
  46646. * Serializes this noise procedural texture
  46647. * @returns a serialized noise procedural texture object
  46648. */
  46649. serialize(): any;
  46650. /**
  46651. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  46652. * @param parsedTexture defines parsed texture data
  46653. * @param scene defines the current scene
  46654. * @param rootUrl defines the root URL containing noise procedural texture information
  46655. * @returns a parsed NoiseProceduralTexture
  46656. */
  46657. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  46658. }
  46659. }
  46660. declare module BABYLON {
  46661. /**
  46662. * 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.
  46663. * This is the base class of any Procedural texture and contains most of the shareable code.
  46664. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  46665. */
  46666. class ProceduralTexture extends Texture {
  46667. isCube: boolean;
  46668. /**
  46669. * Define if the texture is enabled or not (disabled texture will not render)
  46670. */
  46671. isEnabled: boolean;
  46672. /**
  46673. * Callback called when the texture is generated
  46674. */
  46675. onGenerated: () => void;
  46676. /**
  46677. * Event raised when the texture is generated
  46678. */
  46679. onGeneratedObservable: Observable<ProceduralTexture>;
  46680. /** @hidden */
  46681. _generateMipMaps: boolean;
  46682. /** @hidden **/
  46683. _effect: Effect;
  46684. /** @hidden */
  46685. _textures: {
  46686. [key: string]: Texture;
  46687. };
  46688. private _size;
  46689. private _currentRefreshId;
  46690. private _refreshRate;
  46691. private _vertexBuffers;
  46692. private _indexBuffer;
  46693. private _uniforms;
  46694. private _samplers;
  46695. private _fragment;
  46696. private _floats;
  46697. private _ints;
  46698. private _floatsArrays;
  46699. private _colors3;
  46700. private _colors4;
  46701. private _vectors2;
  46702. private _vectors3;
  46703. private _matrices;
  46704. private _fallbackTexture;
  46705. private _fallbackTextureUsed;
  46706. private _engine;
  46707. private _cachedDefines;
  46708. private _contentUpdateId;
  46709. private _contentData;
  46710. /**
  46711. * Instantiates a new procedural texture.
  46712. * 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.
  46713. * This is the base class of any Procedural texture and contains most of the shareable code.
  46714. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  46715. * @param name Define the name of the texture
  46716. * @param size Define the size of the texture to create
  46717. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  46718. * @param scene Define the scene the texture belongs to
  46719. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  46720. * @param generateMipMaps Define if the texture should creates mip maps or not
  46721. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  46722. */
  46723. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  46724. /**
  46725. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  46726. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  46727. */
  46728. getContent(): Nullable<ArrayBufferView>;
  46729. private _createIndexBuffer;
  46730. /** @hidden */
  46731. _rebuild(): void;
  46732. /**
  46733. * Resets the texture in order to recreate its associated resources.
  46734. * This can be called in case of context loss
  46735. */
  46736. reset(): void;
  46737. protected _getDefines(): string;
  46738. /**
  46739. * Is the texture ready to be used ? (rendered at least once)
  46740. * @returns true if ready, otherwise, false.
  46741. */
  46742. isReady(): boolean;
  46743. /**
  46744. * Resets the refresh counter of the texture and start bak from scratch.
  46745. * Could be usefull to regenerate the texture if it is setup to render only once.
  46746. */
  46747. resetRefreshCounter(): void;
  46748. /**
  46749. * Set the fragment shader to use in order to render the texture.
  46750. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  46751. */
  46752. setFragment(fragment: any): void;
  46753. /**
  46754. * Define the refresh rate of the texture or the rendering frequency.
  46755. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  46756. */
  46757. refreshRate: number;
  46758. /** @hidden */
  46759. _shouldRender(): boolean;
  46760. /**
  46761. * Get the size the texture is rendering at.
  46762. * @returns the size (texture is always squared)
  46763. */
  46764. getRenderSize(): number;
  46765. /**
  46766. * Resize the texture to new value.
  46767. * @param size Define the new size the texture should have
  46768. * @param generateMipMaps Define whether the new texture should create mip maps
  46769. */
  46770. resize(size: number, generateMipMaps: boolean): void;
  46771. private _checkUniform;
  46772. /**
  46773. * Set a texture in the shader program used to render.
  46774. * @param name Define the name of the uniform samplers as defined in the shader
  46775. * @param texture Define the texture to bind to this sampler
  46776. * @return the texture itself allowing "fluent" like uniform updates
  46777. */
  46778. setTexture(name: string, texture: Texture): ProceduralTexture;
  46779. /**
  46780. * Set a float in the shader.
  46781. * @param name Define the name of the uniform as defined in the shader
  46782. * @param value Define the value to give to the uniform
  46783. * @return the texture itself allowing "fluent" like uniform updates
  46784. */
  46785. setFloat(name: string, value: number): ProceduralTexture;
  46786. /**
  46787. * Set a int in the shader.
  46788. * @param name Define the name of the uniform as defined in the shader
  46789. * @param value Define the value to give to the uniform
  46790. * @return the texture itself allowing "fluent" like uniform updates
  46791. */
  46792. setInt(name: string, value: number): ProceduralTexture;
  46793. /**
  46794. * Set an array of floats in the shader.
  46795. * @param name Define the name of the uniform as defined in the shader
  46796. * @param value Define the value to give to the uniform
  46797. * @return the texture itself allowing "fluent" like uniform updates
  46798. */
  46799. setFloats(name: string, value: number[]): ProceduralTexture;
  46800. /**
  46801. * Set a vec3 in the shader from a Color3.
  46802. * @param name Define the name of the uniform as defined in the shader
  46803. * @param value Define the value to give to the uniform
  46804. * @return the texture itself allowing "fluent" like uniform updates
  46805. */
  46806. setColor3(name: string, value: Color3): ProceduralTexture;
  46807. /**
  46808. * Set a vec4 in the shader from a Color4.
  46809. * @param name Define the name of the uniform as defined in the shader
  46810. * @param value Define the value to give to the uniform
  46811. * @return the texture itself allowing "fluent" like uniform updates
  46812. */
  46813. setColor4(name: string, value: Color4): ProceduralTexture;
  46814. /**
  46815. * Set a vec2 in the shader from a Vector2.
  46816. * @param name Define the name of the uniform as defined in the shader
  46817. * @param value Define the value to give to the uniform
  46818. * @return the texture itself allowing "fluent" like uniform updates
  46819. */
  46820. setVector2(name: string, value: Vector2): ProceduralTexture;
  46821. /**
  46822. * Set a vec3 in the shader from a Vector3.
  46823. * @param name Define the name of the uniform as defined in the shader
  46824. * @param value Define the value to give to the uniform
  46825. * @return the texture itself allowing "fluent" like uniform updates
  46826. */
  46827. setVector3(name: string, value: Vector3): ProceduralTexture;
  46828. /**
  46829. * Set a mat4 in the shader from a MAtrix.
  46830. * @param name Define the name of the uniform as defined in the shader
  46831. * @param value Define the value to give to the uniform
  46832. * @return the texture itself allowing "fluent" like uniform updates
  46833. */
  46834. setMatrix(name: string, value: Matrix): ProceduralTexture;
  46835. /**
  46836. * Render the texture to its associated render target.
  46837. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  46838. */
  46839. render(useCameraPostProcess?: boolean): void;
  46840. /**
  46841. * Clone the texture.
  46842. * @returns the cloned texture
  46843. */
  46844. clone(): ProceduralTexture;
  46845. /**
  46846. * Dispose the texture and release its asoociated resources.
  46847. */
  46848. dispose(): void;
  46849. }
  46850. }
  46851. declare module BABYLON {
  46852. interface AbstractScene {
  46853. /**
  46854. * The list of procedural textures added to the scene
  46855. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  46856. */
  46857. proceduralTextures: Array<ProceduralTexture>;
  46858. }
  46859. /**
  46860. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  46861. * in a given scene.
  46862. */
  46863. class ProceduralTextureSceneComponent implements ISceneComponent {
  46864. /**
  46865. * The component name helpfull to identify the component in the list of scene components.
  46866. */
  46867. readonly name: string;
  46868. /**
  46869. * The scene the component belongs to.
  46870. */
  46871. scene: Scene;
  46872. /**
  46873. * Creates a new instance of the component for the given scene
  46874. * @param scene Defines the scene to register the component in
  46875. */
  46876. constructor(scene: Scene);
  46877. /**
  46878. * Registers the component in a given scene
  46879. */
  46880. register(): void;
  46881. /**
  46882. * Rebuilds the elements related to this component in case of
  46883. * context lost for instance.
  46884. */
  46885. rebuild(): void;
  46886. /**
  46887. * Disposes the component and the associated ressources.
  46888. */
  46889. dispose(): void;
  46890. private _beforeClear;
  46891. }
  46892. }
  46893. declare module BABYLON {
  46894. /**
  46895. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  46896. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  46897. */
  46898. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  46899. private _scene;
  46900. private _camerasToBeAttached;
  46901. /**
  46902. * ID of the sharpen post process,
  46903. */
  46904. private readonly SharpenPostProcessId;
  46905. /**
  46906. * @ignore
  46907. * ID of the image processing post process;
  46908. */
  46909. readonly ImageProcessingPostProcessId: string;
  46910. /**
  46911. * @ignore
  46912. * ID of the Fast Approximate Anti-Aliasing post process;
  46913. */
  46914. readonly FxaaPostProcessId: string;
  46915. /**
  46916. * ID of the chromatic aberration post process,
  46917. */
  46918. private readonly ChromaticAberrationPostProcessId;
  46919. /**
  46920. * ID of the grain post process
  46921. */
  46922. private readonly GrainPostProcessId;
  46923. /**
  46924. * Sharpen post process which will apply a sharpen convolution to enhance edges
  46925. */
  46926. sharpen: SharpenPostProcess;
  46927. private _sharpenEffect;
  46928. private bloom;
  46929. /**
  46930. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  46931. */
  46932. depthOfField: DepthOfFieldEffect;
  46933. /**
  46934. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  46935. */
  46936. fxaa: FxaaPostProcess;
  46937. /**
  46938. * Image post processing pass used to perform operations such as tone mapping or color grading.
  46939. */
  46940. imageProcessing: ImageProcessingPostProcess;
  46941. /**
  46942. * Chromatic aberration post process which will shift rgb colors in the image
  46943. */
  46944. chromaticAberration: ChromaticAberrationPostProcess;
  46945. private _chromaticAberrationEffect;
  46946. /**
  46947. * Grain post process which add noise to the image
  46948. */
  46949. grain: GrainPostProcess;
  46950. private _grainEffect;
  46951. /**
  46952. * Glow post process which adds a glow to emmisive areas of the image
  46953. */
  46954. private _glowLayer;
  46955. /**
  46956. * Animations which can be used to tweak settings over a period of time
  46957. */
  46958. animations: Animation[];
  46959. private _imageProcessingConfigurationObserver;
  46960. private _sharpenEnabled;
  46961. private _bloomEnabled;
  46962. private _depthOfFieldEnabled;
  46963. private _depthOfFieldBlurLevel;
  46964. private _fxaaEnabled;
  46965. private _imageProcessingEnabled;
  46966. private _defaultPipelineTextureType;
  46967. private _bloomScale;
  46968. private _chromaticAberrationEnabled;
  46969. private _grainEnabled;
  46970. private _buildAllowed;
  46971. /**
  46972. * Enable or disable the sharpen process from the pipeline
  46973. */
  46974. sharpenEnabled: boolean;
  46975. private _resizeObserver;
  46976. private _hardwareScaleLevel;
  46977. private _bloomKernel;
  46978. /**
  46979. * Specifies the size of the bloom blur kernel, relative to the final output size
  46980. */
  46981. bloomKernel: number;
  46982. /**
  46983. * Specifies the weight of the bloom in the final rendering
  46984. */
  46985. private _bloomWeight;
  46986. /**
  46987. * Specifies the luma threshold for the area that will be blurred by the bloom
  46988. */
  46989. private _bloomThreshold;
  46990. private _hdr;
  46991. /**
  46992. * The strength of the bloom.
  46993. */
  46994. bloomWeight: number;
  46995. /**
  46996. * The strength of the bloom.
  46997. */
  46998. bloomThreshold: number;
  46999. /**
  47000. * The scale of the bloom, lower value will provide better performance.
  47001. */
  47002. bloomScale: number;
  47003. /**
  47004. * Enable or disable the bloom from the pipeline
  47005. */
  47006. bloomEnabled: boolean;
  47007. private _rebuildBloom;
  47008. /**
  47009. * If the depth of field is enabled.
  47010. */
  47011. depthOfFieldEnabled: boolean;
  47012. /**
  47013. * Blur level of the depth of field effect. (Higher blur will effect performance)
  47014. */
  47015. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  47016. /**
  47017. * If the anti aliasing is enabled.
  47018. */
  47019. fxaaEnabled: boolean;
  47020. private _samples;
  47021. /**
  47022. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  47023. */
  47024. samples: number;
  47025. /**
  47026. * If image processing is enabled.
  47027. */
  47028. imageProcessingEnabled: boolean;
  47029. /**
  47030. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  47031. */
  47032. glowLayerEnabled: boolean;
  47033. /**
  47034. * Enable or disable the chromaticAberration process from the pipeline
  47035. */
  47036. chromaticAberrationEnabled: boolean;
  47037. /**
  47038. * Enable or disable the grain process from the pipeline
  47039. */
  47040. grainEnabled: boolean;
  47041. /**
  47042. * @constructor
  47043. * @param {string} name - The rendering pipeline name (default: "")
  47044. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  47045. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  47046. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  47047. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  47048. */
  47049. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  47050. /**
  47051. * Force the compilation of the entire pipeline.
  47052. */
  47053. prepare(): void;
  47054. private _hasCleared;
  47055. private _prevPostProcess;
  47056. private _prevPrevPostProcess;
  47057. private _setAutoClearAndTextureSharing;
  47058. private _depthOfFieldSceneObserver;
  47059. private _buildPipeline;
  47060. private _disposePostProcesses;
  47061. /**
  47062. * Adds a camera to the pipeline
  47063. * @param camera the camera to be added
  47064. */
  47065. addCamera(camera: Camera): void;
  47066. /**
  47067. * Removes a camera from the pipeline
  47068. * @param camera the camera to remove
  47069. */
  47070. removeCamera(camera: Camera): void;
  47071. /**
  47072. * Dispose of the pipeline and stop all post processes
  47073. */
  47074. dispose(): void;
  47075. /**
  47076. * Serialize the rendering pipeline (Used when exporting)
  47077. * @returns the serialized object
  47078. */
  47079. serialize(): any;
  47080. /**
  47081. * Parse the serialized pipeline
  47082. * @param source Source pipeline.
  47083. * @param scene The scene to load the pipeline to.
  47084. * @param rootUrl The URL of the serialized pipeline.
  47085. * @returns An instantiated pipeline from the serialized object.
  47086. */
  47087. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  47088. }
  47089. }
  47090. declare module BABYLON {
  47091. class LensRenderingPipeline extends PostProcessRenderPipeline {
  47092. /**
  47093. * The chromatic aberration PostProcess id in the pipeline
  47094. */
  47095. LensChromaticAberrationEffect: string;
  47096. /**
  47097. * The highlights enhancing PostProcess id in the pipeline
  47098. */
  47099. HighlightsEnhancingEffect: string;
  47100. /**
  47101. * The depth-of-field PostProcess id in the pipeline
  47102. */
  47103. LensDepthOfFieldEffect: string;
  47104. private _scene;
  47105. private _depthTexture;
  47106. private _grainTexture;
  47107. private _chromaticAberrationPostProcess;
  47108. private _highlightsPostProcess;
  47109. private _depthOfFieldPostProcess;
  47110. private _edgeBlur;
  47111. private _grainAmount;
  47112. private _chromaticAberration;
  47113. private _distortion;
  47114. private _highlightsGain;
  47115. private _highlightsThreshold;
  47116. private _dofDistance;
  47117. private _dofAperture;
  47118. private _dofDarken;
  47119. private _dofPentagon;
  47120. private _blurNoise;
  47121. /**
  47122. * @constructor
  47123. *
  47124. * Effect parameters are as follow:
  47125. * {
  47126. * chromatic_aberration: number; // from 0 to x (1 for realism)
  47127. * edge_blur: number; // from 0 to x (1 for realism)
  47128. * distortion: number; // from 0 to x (1 for realism)
  47129. * grain_amount: number; // from 0 to 1
  47130. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  47131. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  47132. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  47133. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  47134. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  47135. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  47136. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  47137. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  47138. * }
  47139. * Note: if an effect parameter is unset, effect is disabled
  47140. *
  47141. * @param {string} name - The rendering pipeline name
  47142. * @param {object} parameters - An object containing all parameters (see above)
  47143. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  47144. * @param {number} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  47145. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  47146. */
  47147. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  47148. setEdgeBlur(amount: number): void;
  47149. disableEdgeBlur(): void;
  47150. setGrainAmount(amount: number): void;
  47151. disableGrain(): void;
  47152. setChromaticAberration(amount: number): void;
  47153. disableChromaticAberration(): void;
  47154. setEdgeDistortion(amount: number): void;
  47155. disableEdgeDistortion(): void;
  47156. setFocusDistance(amount: number): void;
  47157. disableDepthOfField(): void;
  47158. setAperture(amount: number): void;
  47159. setDarkenOutOfFocus(amount: number): void;
  47160. enablePentagonBokeh(): void;
  47161. disablePentagonBokeh(): void;
  47162. enableNoiseBlur(): void;
  47163. disableNoiseBlur(): void;
  47164. setHighlightsGain(amount: number): void;
  47165. setHighlightsThreshold(amount: number): void;
  47166. disableHighlights(): void;
  47167. /**
  47168. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  47169. */
  47170. dispose(disableDepthRender?: boolean): void;
  47171. private _createChromaticAberrationPostProcess;
  47172. private _createHighlightsPostProcess;
  47173. private _createDepthOfFieldPostProcess;
  47174. private _createGrainTexture;
  47175. }
  47176. }
  47177. declare module BABYLON {
  47178. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  47179. /**
  47180. * The PassPostProcess id in the pipeline that contains the original scene color
  47181. */
  47182. SSAOOriginalSceneColorEffect: string;
  47183. /**
  47184. * The SSAO PostProcess id in the pipeline
  47185. */
  47186. SSAORenderEffect: string;
  47187. /**
  47188. * The horizontal blur PostProcess id in the pipeline
  47189. */
  47190. SSAOBlurHRenderEffect: string;
  47191. /**
  47192. * The vertical blur PostProcess id in the pipeline
  47193. */
  47194. SSAOBlurVRenderEffect: string;
  47195. /**
  47196. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  47197. */
  47198. SSAOCombineRenderEffect: string;
  47199. /**
  47200. * The output strength of the SSAO post-process. Default value is 1.0.
  47201. */
  47202. totalStrength: number;
  47203. /**
  47204. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  47205. */
  47206. maxZ: number;
  47207. /**
  47208. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  47209. */
  47210. minZAspect: number;
  47211. private _samples;
  47212. /**
  47213. * Number of samples used for the SSAO calculations. Default value is 8
  47214. */
  47215. samples: number;
  47216. private _textureSamples;
  47217. /**
  47218. * Number of samples to use for antialiasing
  47219. */
  47220. textureSamples: number;
  47221. /**
  47222. * Ratio object used for SSAO ratio and blur ratio
  47223. */
  47224. private _ratio;
  47225. /**
  47226. * Dynamically generated sphere sampler.
  47227. */
  47228. private _sampleSphere;
  47229. /**
  47230. * Blur filter offsets
  47231. */
  47232. private _samplerOffsets;
  47233. /**
  47234. * Are we using bilateral blur ?
  47235. */
  47236. private _expensiveBlur;
  47237. expensiveBlur: boolean;
  47238. /**
  47239. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  47240. */
  47241. radius: number;
  47242. /**
  47243. * The base color of the SSAO post-process
  47244. * The final result is "base + ssao" between [0, 1]
  47245. */
  47246. base: number;
  47247. /**
  47248. * Support test.
  47249. */
  47250. static readonly IsSupported: boolean;
  47251. private _scene;
  47252. private _depthTexture;
  47253. private _normalTexture;
  47254. private _randomTexture;
  47255. private _originalColorPostProcess;
  47256. private _ssaoPostProcess;
  47257. private _blurHPostProcess;
  47258. private _blurVPostProcess;
  47259. private _ssaoCombinePostProcess;
  47260. private _firstUpdate;
  47261. /**
  47262. * @constructor
  47263. * @param {string} name - The rendering pipeline name
  47264. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  47265. * @param {any} 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 }
  47266. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  47267. */
  47268. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  47269. /**
  47270. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  47271. */
  47272. dispose(disableGeometryBufferRenderer?: boolean): void;
  47273. private _createBlurPostProcess;
  47274. /** @hidden */
  47275. _rebuild(): void;
  47276. private _bits;
  47277. private _radicalInverse_VdC;
  47278. private _hammersley;
  47279. private _hemisphereSample_uniform;
  47280. private _generateHemisphere;
  47281. private _createSSAOPostProcess;
  47282. private _createSSAOCombinePostProcess;
  47283. private _createRandomTexture;
  47284. /**
  47285. * Serialize the rendering pipeline (Used when exporting)
  47286. * @returns the serialized object
  47287. */
  47288. serialize(): any;
  47289. /**
  47290. * Parse the serialized pipeline
  47291. * @param source Source pipeline.
  47292. * @param scene The scene to load the pipeline to.
  47293. * @param rootUrl The URL of the serialized pipeline.
  47294. * @returns An instantiated pipeline from the serialized object.
  47295. */
  47296. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  47297. }
  47298. }
  47299. declare module BABYLON {
  47300. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  47301. /**
  47302. * The PassPostProcess id in the pipeline that contains the original scene color
  47303. */
  47304. SSAOOriginalSceneColorEffect: string;
  47305. /**
  47306. * The SSAO PostProcess id in the pipeline
  47307. */
  47308. SSAORenderEffect: string;
  47309. /**
  47310. * The horizontal blur PostProcess id in the pipeline
  47311. */
  47312. SSAOBlurHRenderEffect: string;
  47313. /**
  47314. * The vertical blur PostProcess id in the pipeline
  47315. */
  47316. SSAOBlurVRenderEffect: string;
  47317. /**
  47318. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  47319. */
  47320. SSAOCombineRenderEffect: string;
  47321. /**
  47322. * The output strength of the SSAO post-process. Default value is 1.0.
  47323. */
  47324. totalStrength: number;
  47325. /**
  47326. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  47327. */
  47328. radius: number;
  47329. /**
  47330. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  47331. * Must not be equal to fallOff and superior to fallOff.
  47332. * Default value is 0.975
  47333. */
  47334. area: number;
  47335. /**
  47336. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  47337. * Must not be equal to area and inferior to area.
  47338. * Default value is 0.0
  47339. */
  47340. fallOff: number;
  47341. /**
  47342. * The base color of the SSAO post-process
  47343. * The final result is "base + ssao" between [0, 1]
  47344. */
  47345. base: number;
  47346. private _scene;
  47347. private _depthTexture;
  47348. private _randomTexture;
  47349. private _originalColorPostProcess;
  47350. private _ssaoPostProcess;
  47351. private _blurHPostProcess;
  47352. private _blurVPostProcess;
  47353. private _ssaoCombinePostProcess;
  47354. private _firstUpdate;
  47355. /**
  47356. * @constructor
  47357. * @param {string} name - The rendering pipeline name
  47358. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  47359. * @param {any} ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  47360. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  47361. */
  47362. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  47363. /**
  47364. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  47365. */
  47366. dispose(disableDepthRender?: boolean): void;
  47367. private _createBlurPostProcess;
  47368. /** @hidden */
  47369. _rebuild(): void;
  47370. private _createSSAOPostProcess;
  47371. private _createSSAOCombinePostProcess;
  47372. private _createRandomTexture;
  47373. }
  47374. }
  47375. declare module BABYLON {
  47376. /**
  47377. * Standard rendering pipeline
  47378. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  47379. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  47380. */
  47381. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  47382. /**
  47383. * Public members
  47384. */
  47385. /**
  47386. * Post-process which contains the original scene color before the pipeline applies all the effects
  47387. */
  47388. originalPostProcess: Nullable<PostProcess>;
  47389. /**
  47390. * Post-process used to down scale an image x4
  47391. */
  47392. downSampleX4PostProcess: Nullable<PostProcess>;
  47393. /**
  47394. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  47395. */
  47396. brightPassPostProcess: Nullable<PostProcess>;
  47397. /**
  47398. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  47399. */
  47400. blurHPostProcesses: PostProcess[];
  47401. /**
  47402. * Post-process array storing all the vertical blur post-processes used by the pipeline
  47403. */
  47404. blurVPostProcesses: PostProcess[];
  47405. /**
  47406. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  47407. */
  47408. textureAdderPostProcess: Nullable<PostProcess>;
  47409. /**
  47410. * Post-process used to create volumetric lighting effect
  47411. */
  47412. volumetricLightPostProcess: Nullable<PostProcess>;
  47413. /**
  47414. * Post-process used to smooth the previous volumetric light post-process on the X axis
  47415. */
  47416. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  47417. /**
  47418. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  47419. */
  47420. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  47421. /**
  47422. * Post-process used to merge the volumetric light effect and the real scene color
  47423. */
  47424. volumetricLightMergePostProces: Nullable<PostProcess>;
  47425. /**
  47426. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  47427. */
  47428. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  47429. /**
  47430. * Base post-process used to calculate the average luminance of the final image for HDR
  47431. */
  47432. luminancePostProcess: Nullable<PostProcess>;
  47433. /**
  47434. * Post-processes used to create down sample post-processes in order to get
  47435. * the average luminance of the final image for HDR
  47436. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  47437. */
  47438. luminanceDownSamplePostProcesses: PostProcess[];
  47439. /**
  47440. * Post-process used to create a HDR effect (light adaptation)
  47441. */
  47442. hdrPostProcess: Nullable<PostProcess>;
  47443. /**
  47444. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  47445. */
  47446. textureAdderFinalPostProcess: Nullable<PostProcess>;
  47447. /**
  47448. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  47449. */
  47450. lensFlareFinalPostProcess: Nullable<PostProcess>;
  47451. /**
  47452. * Post-process used to merge the final HDR post-process and the real scene color
  47453. */
  47454. hdrFinalPostProcess: Nullable<PostProcess>;
  47455. /**
  47456. * Post-process used to create a lens flare effect
  47457. */
  47458. lensFlarePostProcess: Nullable<PostProcess>;
  47459. /**
  47460. * Post-process that merges the result of the lens flare post-process and the real scene color
  47461. */
  47462. lensFlareComposePostProcess: Nullable<PostProcess>;
  47463. /**
  47464. * Post-process used to create a motion blur effect
  47465. */
  47466. motionBlurPostProcess: Nullable<PostProcess>;
  47467. /**
  47468. * Post-process used to create a depth of field effect
  47469. */
  47470. depthOfFieldPostProcess: Nullable<PostProcess>;
  47471. /**
  47472. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  47473. */
  47474. fxaaPostProcess: Nullable<FxaaPostProcess>;
  47475. /**
  47476. * Represents the brightness threshold in order to configure the illuminated surfaces
  47477. */
  47478. brightThreshold: number;
  47479. /**
  47480. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  47481. */
  47482. blurWidth: number;
  47483. /**
  47484. * Sets if the blur for highlighted surfaces must be only horizontal
  47485. */
  47486. horizontalBlur: boolean;
  47487. /**
  47488. * Sets the overall exposure used by the pipeline
  47489. */
  47490. exposure: number;
  47491. /**
  47492. * Texture used typically to simulate "dirty" on camera lens
  47493. */
  47494. lensTexture: Nullable<Texture>;
  47495. /**
  47496. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  47497. */
  47498. volumetricLightCoefficient: number;
  47499. /**
  47500. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  47501. */
  47502. volumetricLightPower: number;
  47503. /**
  47504. * Used the set the blur intensity to smooth the volumetric lights
  47505. */
  47506. volumetricLightBlurScale: number;
  47507. /**
  47508. * Light (spot or directional) used to generate the volumetric lights rays
  47509. * The source light must have a shadow generate so the pipeline can get its
  47510. * depth map
  47511. */
  47512. sourceLight: Nullable<SpotLight | DirectionalLight>;
  47513. /**
  47514. * For eye adaptation, represents the minimum luminance the eye can see
  47515. */
  47516. hdrMinimumLuminance: number;
  47517. /**
  47518. * For eye adaptation, represents the decrease luminance speed
  47519. */
  47520. hdrDecreaseRate: number;
  47521. /**
  47522. * For eye adaptation, represents the increase luminance speed
  47523. */
  47524. hdrIncreaseRate: number;
  47525. /**
  47526. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  47527. */
  47528. lensColorTexture: Nullable<Texture>;
  47529. /**
  47530. * The overall strengh for the lens flare effect
  47531. */
  47532. lensFlareStrength: number;
  47533. /**
  47534. * Dispersion coefficient for lens flare ghosts
  47535. */
  47536. lensFlareGhostDispersal: number;
  47537. /**
  47538. * Main lens flare halo width
  47539. */
  47540. lensFlareHaloWidth: number;
  47541. /**
  47542. * Based on the lens distortion effect, defines how much the lens flare result
  47543. * is distorted
  47544. */
  47545. lensFlareDistortionStrength: number;
  47546. /**
  47547. * Lens star texture must be used to simulate rays on the flares and is available
  47548. * in the documentation
  47549. */
  47550. lensStarTexture: Nullable<Texture>;
  47551. /**
  47552. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  47553. * flare effect by taking account of the dirt texture
  47554. */
  47555. lensFlareDirtTexture: Nullable<Texture>;
  47556. /**
  47557. * Represents the focal length for the depth of field effect
  47558. */
  47559. depthOfFieldDistance: number;
  47560. /**
  47561. * Represents the blur intensity for the blurred part of the depth of field effect
  47562. */
  47563. depthOfFieldBlurWidth: number;
  47564. /**
  47565. * For motion blur, defines how much the image is blurred by the movement
  47566. */
  47567. motionStrength: number;
  47568. /**
  47569. * List of animations for the pipeline (IAnimatable implementation)
  47570. */
  47571. animations: Animation[];
  47572. /**
  47573. * Private members
  47574. */
  47575. private _scene;
  47576. private _currentDepthOfFieldSource;
  47577. private _basePostProcess;
  47578. private _hdrCurrentLuminance;
  47579. private _floatTextureType;
  47580. private _ratio;
  47581. private _bloomEnabled;
  47582. private _depthOfFieldEnabled;
  47583. private _vlsEnabled;
  47584. private _lensFlareEnabled;
  47585. private _hdrEnabled;
  47586. private _motionBlurEnabled;
  47587. private _fxaaEnabled;
  47588. private _motionBlurSamples;
  47589. private _volumetricLightStepsCount;
  47590. private _samples;
  47591. /**
  47592. * Specifies if the bloom pipeline is enabled
  47593. */
  47594. BloomEnabled: boolean;
  47595. /**
  47596. * Specifies if the depth of field pipeline is enabed
  47597. */
  47598. DepthOfFieldEnabled: boolean;
  47599. /**
  47600. * Specifies if the lens flare pipeline is enabed
  47601. */
  47602. LensFlareEnabled: boolean;
  47603. /**
  47604. * Specifies if the HDR pipeline is enabled
  47605. */
  47606. HDREnabled: boolean;
  47607. /**
  47608. * Specifies if the volumetric lights scattering effect is enabled
  47609. */
  47610. VLSEnabled: boolean;
  47611. /**
  47612. * Specifies if the motion blur effect is enabled
  47613. */
  47614. MotionBlurEnabled: boolean;
  47615. /**
  47616. * Specifies if anti-aliasing is enabled
  47617. */
  47618. fxaaEnabled: boolean;
  47619. /**
  47620. * Specifies the number of steps used to calculate the volumetric lights
  47621. * Typically in interval [50, 200]
  47622. */
  47623. volumetricLightStepsCount: number;
  47624. /**
  47625. * Specifies the number of samples used for the motion blur effect
  47626. * Typically in interval [16, 64]
  47627. */
  47628. motionBlurSamples: number;
  47629. /**
  47630. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  47631. */
  47632. samples: number;
  47633. /**
  47634. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  47635. * @constructor
  47636. * @param {string} name - The rendering pipeline name
  47637. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  47638. * @param {any} ratio - The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  47639. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  47640. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  47641. */
  47642. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  47643. private _buildPipeline;
  47644. private _createDownSampleX4PostProcess;
  47645. private _createBrightPassPostProcess;
  47646. private _createBlurPostProcesses;
  47647. private _createTextureAdderPostProcess;
  47648. private _createVolumetricLightPostProcess;
  47649. private _createLuminancePostProcesses;
  47650. private _createHdrPostProcess;
  47651. private _createLensFlarePostProcess;
  47652. private _createDepthOfFieldPostProcess;
  47653. private _createMotionBlurPostProcess;
  47654. private _getDepthTexture;
  47655. private _disposePostProcesses;
  47656. /**
  47657. * Dispose of the pipeline and stop all post processes
  47658. */
  47659. dispose(): void;
  47660. /**
  47661. * Serialize the rendering pipeline (Used when exporting)
  47662. * @returns the serialized object
  47663. */
  47664. serialize(): any;
  47665. /**
  47666. * Parse the serialized pipeline
  47667. * @param source Source pipeline.
  47668. * @param scene The scene to load the pipeline to.
  47669. * @param rootUrl The URL of the serialized pipeline.
  47670. * @returns An instantiated pipeline from the serialized object.
  47671. */
  47672. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  47673. static LuminanceSteps: number;
  47674. }
  47675. }